Home > Back-end >  Hot to add a war dependency in maven without having it overlayed
Hot to add a war dependency in maven without having it overlayed

Time:04-14

We are developing a Java web application to be deployed as a war file in Tomcat9.

We want to have some other war files that need to be deployed separate war files due to the system architecture. They are commercial and out of my control.

I want to have this separate wars added in the pom as runtime, so pom we use to deploy the application knows that they are needed and deploys also any war dependency i the webapps dir.

The problem I have is that in the moment I include this war runtime dependencies, the package phase add them as overlays to our war application file.

What I want is to avoid having this war files added as overlays to our war file.

I have found no reference on how to avoid that maven behavior.

I can't share the real pom files due to NDA constraints. This is a incomplete example of what I have build now.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>myOrg</groupId>
        <artifactId>myApp</artifactId>
        <version>1.0</version>
    </parent>

    <artifactId>myApp-war</artifactId>
    <packaging>war</packaging>
    <name>internal-app-war</name>
    <version>2.8</version>

    <dependencies>
        <dependency>
            <groupId>com.exampleorg</groupId>
            <artifactId>ExampleA</artifactId>
            <type>war</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.exampleorg</groupId>
            <artifactId>ExampleB</artifactId>
            <type>war</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            All jar dependencies with compile scope
        </dependency>
    </dependencies>
</project>

Can any one propose a way to achieve that?

Thanks in advance.

CodePudding user response:

You are misusing <dependencies> here.

If you want to make sure that other WARs are deployed on the same server, then you need to manage that outside of Maven, e.g. with Puppet/Chef/... or through a docker container.

Maven dependencies are only meant for the build itself.

  • Related