23

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

I want to skip these plugin execution by passing Command Line Arguments I tried below command to skip them like normal plugins, but didn't work though!

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

RaceBase
  • 18,428
  • 47
  • 141
  • 202

3 Answers3

33

UPDATE: Starting with version 1.4.0 the former name skip has been changed into exec.skip.

This page should tell you that the name of the argument to be passed by cmdline (i.e. the user property) was called skip, which was a poorly chosen name. To fix this you could do the following:

<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>
Robert Scholte
  • 11,889
  • 2
  • 35
  • 44
  • thanks for that. somehow I missed that. Can you please tell me for rpm-maven-plugin too? I have seen their project page, couldn't find anything :( – RaceBase Oct 30 '14 at 03:12
  • rpm-maven-plugin doesn't have a skip property, that's why you can't find it. AFAIK the rpm is the end/package result, so I wonder if it makes sense to skip it. IMHO, most of the time if you need to skip things, it's a sign that either your process or your pom structure/hierarchy is incorrect. – Robert Scholte Oct 30 '14 at 20:32
  • 1
    It doesn't work in local Macbook. RPM plugin still has issues with mac os and I just want to skip for local builds – RaceBase Oct 31 '14 at 08:03
  • In that case, move the rpm-maven-plugin to a profile (http://maven.apache.org/pom.html#Activation) with activation `!mac`, see also http://maven.apache.org/enforcer/enforcer-rules/requireOS.html . Even though I often write that profiles are often misused, since this is an OS specific request, a profile is allowed. And since it's all open source, why not contact the mojo team and try to fix it for Mac as well. – Robert Scholte Oct 31 '14 at 12:33
15

Try -Dexec.skip from specification:

http://www.mojohaus.org/exec-maven-plugin/java-mojo.html#skip

Grim
  • 1,938
  • 10
  • 56
  • 123
4

Using profiles (as little as possible) and execution phase you may 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>

Invocation:

mvn package -Drpm.package=true [...]
Ananda
  • 41
  • 1