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

10,308

Solution 1

packaging should be as below.

<packaging>war</packaging>

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

Solution 2

in your project definition , please check if packaging is missing or not , it should be some thing like this .

   <groupId>some.groupid</groupId>
   <artifactId>My Web Application</artifactId>
   <version>0.0.1</version>
   <packaging>war</packaging>
   <description>My First Web Application</description>

By default maven war plugin binds to package phase of the lifecycle ,so its important that we should mention the type of packaging we want once the build is done.

I would like to suggest to have a look at the Maven specs for war plugin.

Share:
10,308
Eternal Learner
Author by

Eternal Learner

Trying to understand how this world works.

Updated on June 04, 2022

Comments

  • Eternal Learner
    Eternal Learner almost 2 years

    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?