[jetty-dev] [jira] (JETTY-1517) Resolve submodule artifacts in reactor builds with Maven 3

"Thomas Broyer (JIRA)" <[email protected]> Tue, 12 Mar 2013 04:28:52 -0500 (CDT)
Newsgroups gmane.comp.java.jetty.general
Message-ID <JIRA.137070.1337554948694.4486.1363080532953@codehaus01.managed.contegix.com>


























<style>
/* Changing the layout to use less space for mobiles */
@media screen and (max-device-width: 480px), screen and (-webkit-min-device=
-pixel-ratio: 2) {
    #email-body { min-width: 30em !important; }
    #email-page { padding: 8px !important; }
    #email-banner { padding: 8px 8px 0 8px !important; }
    #email-avatar { margin: 1px 8px 8px 0 !important; padding: 0 !important=
; }
    #email-fields { padding: 0 8px 8px 8px !important; }
    #email-gutter { width: 0 !important; }
}
</style>
<div id=3D"email-body">
<table id=3D"email-wrap" align=3D"center" border=3D"0" cellpadding=3D"0" ce=
llspacing=3D"0" style=3D"background-color:#f0f0f0;color:#000000;width:100%;=
">
    <tr valign=3D"top">
        <td id=3D"email-page" style=3D"padding:16px !important;">
            <table align=3D"center" border=3D"0" cellpadding=3D"0" cellspac=
ing=3D"0" style=3D"background-color:#ffffff;border:1px solid #bbbbbb;color:=
#000000;width:100%;">
                <tr valign=3D"top">
                    <td bgcolor=3D"#ffffff" style=3D"background-color:#ffff=
ff;color:#00AA00;font-family:Arial,FreeSans,Helvetica,sans-serif;font-size:=
12px;line-height:1;"><img src=3D"http://www.codehaus.org/codehaus-small.gif=
" alt=3D"" style=3D"vertical-align:top;" /></td>
                </tr><tr valign=3D"top">
    <td id=3D"email-banner" style=3D"padding:32px 32px 0 32px;">

               =20
       =20
       =20
            <table align=3D"left" border=3D"0" cellpadding=3D"0" cellspacin=
g=3D"0" width=3D"100%" style=3D"width:100%;">
    <tr valign=3D"top">
        <td style=3D"color:#505050;font-family:Arial,FreeSans,Helvetica,san=
s-serif;padding:0;">
                            &nbsp;                         <div id=3D"email=
-action" style=3D"padding: 0 0 8px 0;font-size:12px;line-height:18px;">
                                    <a class=3D"user-hover" rel=3D"t.broyer=
" id=3D"email_t.broyer" href=3D"https://jira.codehaus.org/secure/ViewProfil=
e.jspa?name=3Dt.broyer" style=3D"color:#005500;">Thomas Broyer</a>
     edited a comment on <img src=3D"https://jira.codehaus.org/images/icons=
/issuetypes/improvement.png" height=3D"16" width=3D"16" border=3D"0" align=
=3D"absmiddle" alt=3D"Improvement"> <a style=3D'color:#005500;text-decorati=
on:none;' href=3D'https://jira.codehaus.org/browse/JETTY-1517'>JETTY-1517</=
a>
            </div>
                        <div id=3D"email-summary" style=3D"font-size:16px;l=
ine-height:20px;padding:2px 0 16px 0;">
                <a style=3D'color:#005500;text-decoration:none;' href=3D'ht=
tps://jira.codehaus.org/browse/JETTY-1517'><strong>Resolve submodule artifa=
cts in reactor builds with Maven 3</strong></a>
            </div>
                    </td>
    </tr>
</table>
       =20
    </td>
</tr>
<tr valign=3D"top">
    <td id=3D"email-fields" style=3D"padding:0 32px 32px 32px;">
        <table border=3D"0" cellpadding=3D"0" cellspacing=3D"0" style=3D"pa=
dding:0;text-align:left;width:100%;" width=3D"100%">
            <tr valign=3D"top">
                <td id=3D"email-gutter" style=3D"width:64px;white-space:now=
rap;"></td>
                <td>
                    <table border=3D"0" cellpadding=3D"0" cellspacing=3D"0"=
 width=3D"100%">
                        <tr valign=3D"top">
    <td colspan=3D"2" style=3D"color:#000000;font-family:Arial,FreeSans,Hel=
vetica,sans-serif;font-size:12px;padding:0 0 16px 0;width:100%;">
        <div class=3D"comment-block" style=3D"background-color:#edf5ff;bord=
er:1px solid #dddddd;color:#000000;padding:12px;"><p>You're right, it comes=
 <em>for free</em> with dependency resolution. It looks like the only issue=
 is that <tt>jetty:run</tt> does not ignore non-war projects (see below). N=
ote that it would then work but would include the dependent projects' <tt>b=
uild.outputDirectory</tt> to the <tt>setWebInfLib</tt>, which is weird (add=
ing a directory to what is expected to be a list of JARs); but that's a det=
ail.</p>

<p>As for <tt>mvn jetty:run -pl my-webapp -am</tt> it'll invoke <tt>jetty:r=
un</tt> on each project, starting with the reactor. For example, in a proje=
ct where <tt>basic-server</tt> depends on <tt>basic-shared:jar</tt> and <tt=
>basic-client:war</tt>, with <tt>basic</tt> being the parent/reactor module=
, <tt>mvn -pl basic-server -am jetty:run</tt> gives the following:</p>
<div class=3D"preformatted panel" style=3D"border-width: 1px;"><div class=
=3D"preformattedContent panelContent">
<pre>[INFO] Scanning for projects...
[INFO] --------------------------------------------------------------------=
----
[INFO] Reactor Build Order:
[INFO]=20
[INFO] basic
[INFO] basic-shared
[INFO] basic-client
[INFO] basic-server
[INFO]                                                                     =
   =20
[INFO] --------------------------------------------------------------------=
----
[INFO] Building basic 0.1-SNAPSHOT
[INFO] --------------------------------------------------------------------=
----
[INFO]=20
[INFO] &gt;&gt;&gt; jetty-maven-plugin:8.1.3.v20120416:run (default-cli) @ =
basic &gt;&gt;&gt;
[INFO]=20
[INFO] &lt;&lt;&lt; jetty-maven-plugin:8.1.3.v20120416:run (default-cli) @ =
basic &lt;&lt;&lt;
[INFO]=20
[INFO] --- jetty-maven-plugin:8.1.3.v20120416:run (default-cli) @ basic ---
[INFO] Configuring Jetty for project: basic
[INFO] webAppSourceDirectory /home/=85/basic/src/main/webapp does not exist=
. Defaulting to /home/=85/basic/src/main/webapp
[INFO] Reload Mechanic: automatic
[INFO] Classes directory /home/=85/basic/target/classes does not exist
[INFO] Context path =3D /
[INFO] Tmp directory =3D /home/=85/basic/target/tmp
[INFO] Web defaults =3D org/eclipse/jetty/webapp/webdefault.xml
[INFO] Web overrides =3D  none
[INFO] web.xml file =3D null
[INFO] Webapp directory =3D /home/=85/basic/src/main/webapp
2012-08-21 10:49:04.473:INFO:oejs.Server:jetty-8.1.3.v20120416
2012-08-21 10:49:04.617:INFO:oejpw.PlusConfiguration:No Transaction manager=
 found - if your webapp requires one, please configure one.
2012-08-21 10:49:04.986:INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebA=
ppContext{/,file:/home/=85/basic/src/main/webapp},file:/home/=85/basic/src/=
main/webapp
2012-08-21 10:49:04.986:INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebA=
ppContext{/,file:/home/=85/basic/src/main/webapp},file:/home/=85/basic/src/=
main/webapp
2012-08-21 10:49:04.986:INFO:oejsh.ContextHandler:started o.m.j.p.JettyWebA=
ppContext{/,file:/home/=85/basic/src/main/webapp},file:/home/=85/basic/src/=
main/webapp
2012-08-21 10:49:05.068:INFO:oejs.AbstractConnector:Started SelectChannelCo=
[email protected]:8080
[INFO] Started Jetty Server
</pre>
</div></div>

<p>With Tomcat, each project would be compiled (due to the <tt>@Execute( ph=
ase =3D LifecyclePhase.PROCESS_CLASSES )</tt> annotation on the mojo) but t=
hen the mojo would skip the module unless it's of type <tt>war</tt> (in my =
case, I then simply configure the plugin to <tt>skip</tt> the <tt>basic-cli=
ent</tt> module, as it's only ever used as an overlay in <tt>basic-server</=
tt> and cannot be run standalone, so that <tt>mvn tomcat7:run -pl basic-ser=
ver -am</tt> compiles all the <tt>basic-server</tt> dependencies and ends u=
p launching <tt>basic-server</tt> in Tomcat).</p>

<p>This lead me to find a workaround to make it work like Tomcat: declare i=
n the parent module that the jetty-maven-plugin is skipped by default (set =
<tt>skip</tt> to <tt>true</tt> in <tt>build/pluginManagement</tt>) and then=
 set <tt>skip</tt> back to <tt>false</tt> in <tt>basic-server</tt>.<br/>
I.e. in <tt>basic</tt>:</p>
<div class=3D"code panel" style=3D"border-width: 1px;"><div class=3D"codeCo=
ntent panelContent">
<pre class=3D"code-xml">
  <span class=3D"code-tag">&lt;build&gt;</span>
    <span class=3D"code-tag">&lt;pluginManagement&gt;</span>
      <span class=3D"code-tag">&lt;plugins&gt;</span>
        <span class=3D"code-tag">&lt;plugin&gt;</span>
          <span class=3D"code-tag">&lt;groupId&gt;</span>org.mortbay.jetty<=
span class=3D"code-tag">&lt;/groupId&gt;</span>
          <span class=3D"code-tag">&lt;artifactId&gt;</span>jetty-maven-plu=
gin<span class=3D"code-tag">&lt;/artifactId&gt;</span>
          <span class=3D"code-tag">&lt;version&gt;</span>${jetty-maven-plug=
in.version}<span class=3D"code-tag">&lt;/version&gt;</span>
          <span class=3D"code-tag">&lt;configuration&gt;</span>
            <span class=3D"code-tag">&lt;skip&gt;</span>true<span class=3D"=
code-tag">&lt;/skip&gt;</span>
          <span class=3D"code-tag">&lt;/configuration&gt;</span>
        <span class=3D"code-tag">&lt;/plugin&gt;</span>
</pre>
</div></div>
<p>and then in <tt>basic-server</tt>:</p>
<div class=3D"code panel" style=3D"border-width: 1px;"><div class=3D"codeCo=
ntent panelContent">
<pre class=3D"code-xml">
  <span class=3D"code-tag">&lt;properties&gt;</span>
    <span class=3D"code-tag">&lt;jetty.skip&gt;</span>false<span class=3D"c=
ode-tag">&lt;/jetty.skip&gt;</span>
  <span class=3D"code-tag">&lt;/properties&gt;</span>

  <span class=3D"code-tag">&lt;build&gt;</span>
    <span class=3D"code-tag">&lt;pluginManagement&gt;</span>
      <span class=3D"code-tag">&lt;plugins&gt;</span>
        <span class=3D"code-tag">&lt;plugin&gt;</span>
          <span class=3D"code-tag">&lt;groupId&gt;</span>org.mortbay.jetty<=
span class=3D"code-tag">&lt;/groupId&gt;</span>
          <span class=3D"code-tag">&lt;artifactId&gt;</span>jetty-maven-plu=
gin<span class=3D"code-tag">&lt;/artifactId&gt;</span>
          <span class=3D"code-tag">&lt;configuration&gt;</span>
            <span class=3D"code-tag">&lt;skip&gt;</span>${jetty.skip}<span =
class=3D"code-tag">&lt;/skip&gt;</span>
          <span class=3D"code-tag">&lt;/configuration&gt;</span>
        <span class=3D"code-tag">&lt;/plugin&gt;</span>
</pre>
</div></div>

<p>(or some variant using e.g. the <tt>default-cli</tt> execution ID)</p></=
div>
        <div style=3D"color:#505050;padding:4px 0 0 0;">                </d=
iv>
    </td>
</tr>
                    </table>
                </td>
            </tr>
        </table>
    </td>
</tr>













            </table>
        </td><!-- End #email-page -->
    </tr>
    <tr valign=3D"top">
        <td style=3D"color:#505050;font-family:Arial,FreeSans,Helvetica,san=
s-serif;font-size:10px;line-height:14px;padding: 0 16px 16px 16px;text-alig=
n:center;">
            This message is automatically generated by JIRA.<br />
            If you think it was sent incorrectly, please contact your JIRA =
administrators<br />
            For more information on JIRA, see: <a style=3D'color:#005500;' =
href=3D'http://www.atlassian.com/software/jira'>http://www.atlassian.com/so=
ftware/jira</a>
        </td>
    </tr>
</table><!-- End #email-wrap -->
</div><!-- End #email-body -->

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email