Search code examples
javamavenmaven-3war

Maven 3: Overlay is not a dependency of the project


I'm trying to test the overlay functionality of the maven-war-plugin. Basically I need to merge two war projects.

So I defined a war as dependency:

<dependency> 
  <groupId>my.group.id</groupId> 
  <artifactId>my-legacy-war-project</artifactId> 
  <version>${project.version}</version> 
  <type>war</type> 
</dependency>

And then configured the overlay:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
    <overlays>
      <overlay>
        <groupId>my.group.id</groupId>
        <artifactId>my-legacy-war-project</artifactId>
        <targetPath>legacy</targetPath>
      </overlay>
    </overlays>
  </configuration>
</plugin>

But Maven fails to build this project, complaining about this dependency:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.3:exploded (default) on project my-project: overlay [ id my.group.id:my-legacy-war-project] is not a dependency of the project. -> [Help 1]

The overlay is supposed to work with Maven 3.0.5? Why the build is complaining about a dependency that's declared?


Solution

  • Not sure why, but using id instead of groupId and artifactId in the overlay worked:

      <configuration>
        <overlays>
          <overlay>
            <id>my-legacy-war-project</id>
            <targetPath>legacy</targetPath>
          </overlay>
        </overlays>
      </configuration>