Why would a maven-war-plugin generate a JAR instead of a WAR?

Eternal Learner picture Eternal Learner · Aug 2, 2013 · Viewed 9.6k times · Source

I am following this Contract first using CXF tutorial and while the resulting pom.xml generates sources and even completes build successfully, it fails to create a WAR file.

Instead, it creates a JAR file.

My understanding is that the part in the pom.xml that's responsible for creating the WAR is:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <version>2.1.1</version>
  <configuration>
    <outputDirectory>D:/path/to/profile/autodeploy</outputDirectory>
  </configuration>
 </plugin>

I don't see any <goal> or <execution> element there (unlike in the build-helper-maven-plugin one), but I also understand that with this plugin this is implied as even the official usage page demonstrates:

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <webappDirectory>/sample/servlet/container/deploy/directory</webappDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
</project>

So... what am I missing?

What could possibly explain a maven-war-plugin that behaves in unexpected way like this and produces a JAR instead of a WAR by default?

Is there a way to force it to produce a WAR?

Answer

Jaffar Ramay picture Jaffar Ramay · Aug 2, 2013

packaging should be as below.

<packaging>war</packaging>

if it won't help then try binding your plug-in configuration with a lifecycle phase.