UserName
UserName

Reputation: 1

How to add jars inside another war file for Maven dependencies?

I have a legacy ant project that takes a third party war, unjars it and then uses the resources and libraries (100+ jars) inside it for the Build.

In Maven, I am able to get this war file from the repository and unpack it. But how do I include the jars in the unpacked directory for compilation?

Also, how do I make sure that the compile happens after the unpack?

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="\[http://maven.apache.org/POM/4.0.0\](http://maven.apache.org/POM/4.0.0)" xmlns:xsi="\[http://www.w3.org/2001/XMLSchema-instance\](http://www.w3.org/2001/XMLSchema-instance)" xsi:schemaLocation="\[http://maven.apache.org/POM/4.0.0\](http://maven.apache.org/POM/4.0.0) \[http://maven.apache.org/xsd/maven-4.0.0.xsd\](http://maven.apache.org/xsd/maven-4.0.0.xsd)">
<modelVersion>4.0.0</modelVersion>
<groupId>project1</groupId>
<artifactId>project1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>project1 Maven Webapp</name>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.10</version>
            <executions>
                <execution>
                    <id>unpack</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>unpack</goal>
                    </goals>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>com.abc.third-party</groupId>
                                <artifactId>externalWar</artifactId>
                                <version>1.0.0</version>
                                <type>war</type>
                                <overWrite>false</overWrite>
                                <outputDirectory>target</outputDirectory>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
</project>

Upvotes: 0

Views: 95

Answers (1)

jazz64
jazz64

Reputation: 349

As a first step, try to bind the dependency plugin to a lifecycle phase running before the compile, e.g.: generate-sources. So you ensure the unpacked sources to exist while the compile phase runs.

Upvotes: 2

Related Questions