从Maven的Command Line Argument中跳过exec-maven-plugin

Red*_*ddy 13 plugins skip execution maven

默认情况下,我的项目POM exec-maven-plugin, rpm-maven-plugin将被执行,这在本地编译/构建中是不需要的.

我想通过传递命令行参数来跳过这些插件执行,我尝试下面的命令跳过它们像普通的插件,但不起作用!

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

Rob*_*lte 20

页面应该告诉您调用cmdline传递的参数的名称(即用户属性)skip,这是一个选择不当的名称.要解决此问题,请执

<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>
Run Code Online (Sandbox Code Playgroud)


小智 5

使用配置文件(尽可能少)和执行阶段,您可以实现您想要的不处理跳过属性的插件:

插件配置:

<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>
Run Code Online (Sandbox Code Playgroud)

配置文件配置:

<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>
Run Code Online (Sandbox Code Playgroud)

调用:

mvn package -Drpm.package=true [...]
Run Code Online (Sandbox Code Playgroud)