Woodchuck
Woodchuck

Reputation: 4414

skip the execution of maven-war-plugin

How do I skip the execution of the maven-war-plugin during a mvn command?

Based on the documentation, it seems like I should be able to do so by running something like the following, using -Dmaven.war.skip=true:

mvn verify -P integration-test -Dmaven.war.skip=true

But when I do that the maven-war-plugin still gets executed.

Also strange is that when I remove the maven-war-plugin from my pom altogether, it still gets executed. That leaves me wondering why maven-war-plugin is getting executed at all, as I don't have it mentioned anywhere in my pom.xml.

So maybe a better question is: what brings the maven-war-plugin into the project if I don't have it listed as a plugin?

Upvotes: 3

Views: 1797

Answers (3)

CHW
CHW

Reputation: 2664

You must override the default war execution.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>3.3.2</version>
    <configuration>
        <skip>true</skip>
    </configuration>
    <executions>
        <execution>
            <phase>package</phase>
            <goals>
                <goal>war</goal>
            </goals>
        </execution>
    </executions>
</plugin>

Explanation

By default, the war goal binds to the package lifecylcle phase as stated in the documentation.

So we override the package execution in the pom with the skip configuration.

Upvotes: 2

Woodchuck
Woodchuck

Reputation: 4414

As it turns out, removing the packaging of my pom to war (<!--<packaging>war</packaging>-->) keeps the maven-war-plugin from executing. The maven-jar-plugin gets executed instead. That's not really what I want (I just want to run integration tests via mvn verify without taking too long). But it runs quicker at least.

Upvotes: 1

oneat
oneat

Reputation: 10994

You need to override executions configuration of maven war plugin:

            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <webappDirectory>target/stampli-output/</webappDirectory>
                </configuration>
                <executions combine.children="override">
                </executions>
            </plugin>

It should do.

Why those instructions?
There is something like super-pom for every pom that has some standard defaults.
These defaults will be merged with your configuration if you don't override them.
Therefore also executions will be merged, which bind plugin goals with phase in mvn.

Links to read:

Upvotes: 0

Related Questions