Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven Dependency Plugin not copying libraries to war file

Tags:

java

maven

I'm using below configuration to copy the system dependencies in maven.

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.8</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
                            <includeScope>system</includeScope>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.4</version>
            </plugin>

on "mvn package goal" , the strange thing is happening .

I can see all the system dependencies in "${project.build.directory}/${project.build.finalName}/WEB-INF/lib" target directory as configured in maven-dependency-plugin. But those dependencies are missing in war file.

Can someone please share the ideas ?

like image 218
srinannapa Avatar asked Oct 15 '25 09:10

srinannapa


1 Answers

Try configuring the maven-war-plugin like this:

    <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.4</version>
        <configuration>
            <packagingIncludes>WEB-INF/lib/*.jar</packagingIncludes>
        </configuration>
    </plugin>

If doesn't help, then I guess Kristoffer E is right: your war is packaged before the dependencies are copied. In that case you should change the phase from package to process-sources in the maven-dependency-plugin so it will be executed earlier.

like image 54
Tamas G. Avatar answered Oct 16 '25 21:10

Tamas G.