Skip exec-maven plugin from command line argument in Maven

By default, my POM project will execute exec-maven-plugin, rpm-maven-plugin which is not required in local compilation / assembly.

I want to skip the execution of this plugin by passing command line arguments. I tried the command below to skip them like regular plugins, but it doesn’t work!

mvn install -Dmaven.test.skip = true -Dmaven.exec.skip = true -Dmaven.rpm.skip = true

+6
source share
3 answers

This page should tell you that the name of the argument passed by cmdline (i.e. the user property) is called skip , which is a poorly chosen name. To fix this, follow these steps:

 <properties> <maven.exec.skip>false</maven.exec.skip> <!-- default --> </properties> ... <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.3.2</version> <configuration> <skip>${maven.exec.skip}</skip> </configuration> </plugin> 
+13
source

Using profiles (as little as possible) and a run time, you can achieve what you want for plugins that do not handle the skip property:

Plugin Configuration:

 <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>rpm-maven-plugin</artifactId> <executions> <execution> <phase>${rpmPackagePhase}</phase> <id>generate-rpm</id> <goals> <goal>rpm</goal> </goals> </execution> </executions> <configuration> ... </configuration> </plugin> 

Profile Configuration:

 <profiles> <profile> <id>default</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <rpmPackagePhase>none</rpmPackagePhase> </properties> </profile> <profile> <id>rpmPackage</id> <activation> <property> <name>rpm.package</name> <value>true</value> </property> </activation> <properties> <rpmPackagePhase>package</rpmPackagePhase> </properties> </profile> </profiles> 

Vocation:

 mvn package -Drpm.package=true [...] 
0
source

Source: https://habr.com/ru/post/977430/


All Articles