Richard Chamberlain wrote at Mittwoch, 10. Dezember 2008 14:48:

> Hi,
> 
>  
> 
> I've got a standard war project. I'd like to jar up my source code and
> put it in WEB-INF/lib instead of compiling it to WEB-INF/classes.
> 
>  
> 
> This would allow me to overlay it into another war project without
> mixing up WEB-INF/classes
> 
>  
> 
> Is this possible/advisable?

We do this all the time. That way the jar "transports" the dependencies and
the war file can be used for overlays. However to get the jar into the lib
directory you have to create the jar before the war. Therefore you have to
set the type of your project to "jar" and configure for the war-plugin a
classifier:

        <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                        
<outputDirectory>${our.webapp.directory}/WEB-INF/lib</outputDirectory>
                </configuration>
        </plugin>
        <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <executions>
                        <execution>
                                <id>war</id>
                                <phase>package</phase>
                                <goals>
                                        <goal>war</goal>
                                </goals>
                                <configuration>
                                        <classifier>webapp</classifier>
                                        
<webappDirectory>${our.webapp.directory}</webappDirectory>
                                </configuration>
                        </execution>
                </executions>
        </plugin>

Caveats:
- You should declare the war artifact in a dependencyManagement section
always with the scope "provided" and only in projects where you use this
war for an overlay you should declare it as runtime. The overlay mechanism
will otherwise overlay all dependend war artifacts again.
- You can no longer overlay the resources (property files) or class files.
They are now part of the jar and if you have a deeper dependency tree the
sequence of the jars in the class path is no longer deterministic.

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to