tags:

views:

1127

answers:

1

Hi

I am creating an assembly with packaging=war. I need to include few of the jars, which have been declared as project dependencies in pom.xml in my war (web-inf/lib)

How can I do this?

Edited on 15/10- My project creates few assemblies, one of which is supposed to give packaging of type-war. Some jar files, which are dependencies for the project(and have been declared in pom.xml)need be included in war under WEB-INF. How can I include them or how can i point out their paths to my local nexus repository path?

+3  A: 

Can you be more precise? By default, when you run the mvn clean install command on a war project, Maven 2 will include all dependencies in WEB-INF/lib directories, excluding the ones with the scope test and provided.


If you create your war file using an assembly, then you have an assembly.xml file, which defines the content of your final war file. In this file, you can specify the list of dependencies you want to include:

<assembly>
    ...
    <dependencySets>
        <dependencySet>
           <includes>
               <include>log4j:log4j</include>
               <include>commons-lang:commons-lang</include>
               ...
           </includes>
           <unpack>false</unpack>
           <outputDirectory>WEB-INF/lib</outputDirectory>
        </dependencySet>
    </dependencySets>
</assembly>

(in this example, I asked to add log4j and commons-lang dependencies). For each dependency, you need to specify the groupId and the artifactId. The version is automatically detected regarding the list of dependencies you have set in your pom.xml file.

romaintaz
@romaintaz, the scopes included in the war are runtime and compile. test and provided are not included
Rich Seller
Yes, I made a little mistake. As the scope "compile" is the default scope, it's better if Maven2 include them directly in the war indeed ;)
romaintaz
I have edited the question.Please help
I have edited my answer in order to consider the case where you are indeed using the assembly plugin to build your war file.
romaintaz
+1 for the update and assembly includes
Rich Seller