Best way to hand a WAR file from one Maven project to another, to use with Embedded Jetty? -


i thought simple, having problems:

  • project1 of type war. creates entire webapp .war file, including apache modules (solr/lucene), , of our custom code.
  • project2 existing application. needs launch embedded jetty queries against project1's war file. (see code below)

main problem:

  • when project2 instantiates jetty, needs pass in full path war file, changes each time. maven adds version number stuff project1's war file.

assemblies rescue?

  • i'm able custom assembly work, can't rid of versioning stamp project1.

but wind project1-1.4.1-20120530.233546-2.war. it's in more convenient place, name still weird.

jetty code in project2:

    // context     webappcontext webapp = new webappcontext();     webapp.setcontextpath("/");     string jettyhome = system.getproperty( "jetty.home", ".." );     string fullwarname = ...;    // project1's war file. path changes     webapp.setwar( fullwarname );     // server     server server = new server( kport ); // todo: config     server.sethandler(webapp);     server.start();     server.join(); 

other considerations:

  • i realize there maven-jetty plugin, don't believe that's appropriate here. seems targeted @ unit tests, , our application stack doesn't use maven @ runtime launch services.
  • i'm aware solr has embedded version doesn't require web container, that's been deprecated while , not idea use.

is there better way refactor project? maybe isn't "the maven way" ?

it turns out didn't need assembly (advice had got internally), instead there's easier in main pom. also, having war unpacked here turned out nice idea.

at top of project1's pom.xml have:

 <groupid>com.my.group</groupid>  <artifactid>project-one</artifactid>  <version>1.2.3-snapshot</version>  <packaging>war</packaging> 

this goes near bottom of project2's pom.xml

<plugin>   <groupid>org.apache.maven.plugins</groupid>   <artifactid>maven-dependency-plugin</artifactid>   <executions>     <execution>       <id>unpack-webapp</id>       <phase>package</phase>       <goals>         <goal>unpack</goal>       </goals>       <configuration>           <artifactitems>            <artifactitem>             <groupid>com.my.group</groupid>             <artifactid>project-one</artifactid>             <version>1.2.3-snapshot</version>             <type>war</type>             <overwrite>true</overwrite>             <outputdirectory>${project.build.directory}/webapps/project-one</outputdirectory>            </artifactitem>          </artifactitems>       </configuration>     </execution>   </executions> </plugin> 

then when launching jetty have:

webapp.setwar( "target/webapps/project-one" ); 

i still think there might issues jetty settings, think right direction.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -