1

I have a War file that has dependencies and class files that I need in it that I am trying to include in my project with Maven. Inside the War file, there is a WEB-INF that contains those libs and classes. I have tried everything that I know to try to get this going, but my knowledge of Maven is limited.

  • I have tried simply listing the War as a dependency and following the process described here to install the third-party library, but when I do that Maven says it can't find my packages that I need when I try to install.

  • I have tried overlaying the War as described here with no luck.

  • I have tried maven-warpath-plugin but didn't really have any luck either.

Should any of these tools solve my problem? Is how I am trying to solve the problem possible in this way? Or am I completely off base?

Here are the important parts of my pom.xml from using the maven-warpath-plugin:

<build>
    ...
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.appfuse</groupId>
                <artifactId>maven-warpath-plugin</artifactId>
                <version>1.0-SNAPSHOT</version>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <goals>
                            <goal>add-classes</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
         </plugins>
    </pluginManagement>
    ...
</build>
<repositories>
    <repository>
        <id>data-local</id>
        <name>data</name>
        <url>file://${project.basedir}/o</url>
    </repository>
</repositories>
<dependencies>
...
    <dependency>
        <groupId>my.local.dep</groupId>
        <artifactId>MyLocalDep</artifactId>
        <version>1.1.1.1</version>
        <type>war</type>
    </dependency>
    <dependency>
        <groupId>my.local.dep</groupId>
        <artifactId>MyLocalDep</artifactId>
        <version>1.1.1.1</version>
        <type>warpath</type>
    </dependency>
</dependencies>
loganhuskins
  • 1,399
  • 3
  • 15
  • 33
  • The maven-warpath-plugin should be a good start. What did you try? Do you have an example pom.xml which does not work using this plugin? – Florian Albrecht Dec 21 '16 at 15:00
  • I added the pom, sorry. – loganhuskins Dec 21 '16 at 15:55
  • A war file can't be use a dependency to be on the classpath only jar's. The war project might need to create a separate jar with the appropriate classes (see [maven-war-plguin](http://maven.apache.org/plugins/maven-war-plugin/war-mojo.html) archiveClasses, attachClasses configuration...those created jar's you could use.. – khmarbaise Dec 22 '16 at 06:39
  • Is this not [overlaying the war](http://maven.apache.org/plugins/maven-war-plugin/overlays.html) does? It talks about how you should be able to have a project depend on another war artifact, unless I am completely off base. – loganhuskins Dec 22 '16 at 18:48
  • Try to use not `pluginManagement`, but `plugins` as surrounding section (remove the `pluginManagement` tags). Does that help? – Florian Albrecht Dec 22 '16 at 21:28

1 Answers1

0

Unpack the war in a separate clean step first and add the unpacked jars as system dependency in the main step.

Idea is from here: https://stackoverflow.com/a/6120395/503025

weberjn
  • 1,840
  • 20
  • 24