Include Maven dependencies in team war?

I am creating an assembly with packaging=war

. I need to include multiple jars that have been declared as project dependent in the pom.xml in my war ( web-inf/lib

)

How can i do this?

Edited 10/15 - My project creates multiple assemblies, one of which is to provide war type packaging. Some jar files that are project dependencies (and were declared in pom.xml) need to be included in the war under WEB-INF. How can I enable them or how can I specify their paths to my local nexus repository path?

+2


source to share


1 answer


Can you clarify? By default, when you run a command mvn clean install

in a project, war

Maven 2 will include all dependencies in directories WEB-INF/lib

, excluding those scoped test

and provided

.


If you create your war file using assembly , you have a file assembly.xml

that defines the content of your final war file. In this file, you can specify a list of dependencies that 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 dependencies log4j

and commons-lang

). For each dependency, you need to specify the groupId and artifactId. The version is automatically detected against the list of dependencies installed in the file pom.xml

.

+9


source







All Articles