【问题标题】:Skip exec-maven-plugin from Command Line Argument in Maven从 Maven 的命令行参数中跳过 exec-maven-plugin
【发布时间】:2014-12-25 13:49:27
【问题描述】:

默认在我的项目POM中,exec-maven-plugin, rpm-maven-plugin会被执行, 这在本地编译/构建中不是必需的。

我想通过传递命令行参数来跳过这些插件执行 我试过下面的命令像普通插件一样跳过它们,但是没有用!

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

【问题讨论】:

    标签: maven plugins execution skip


    【解决方案1】:

    这个page 应该告诉你,要通过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>
    

    【讨论】:

    • 谢谢。不知何故,我错过了。你能告诉我rpm-maven-plugin吗?我看过他们的项目页面,找不到任何东西:(
    • rpm-maven-plugin 没有 skip 属性,这就是你找不到它的原因。 AFAIK rpm 是最终/打包结果,所以我想知道跳过它是否有意义。恕我直言,大多数情况下,如果您需要跳过某些内容,则表明您的流程或 pom 结构/层次结构不正确。
    • 它在本地 Macbook 中不起作用。 RPM 插件在 mac os 上仍然存在问题,我只想跳过本地构建
    • 在这种情况下,将 rpm-maven-plugin 移动到配置文件 (maven.apache.org/pom.html#Activation) 并激活 &lt;os&gt;&lt;family&gt;!mac&lt;/family&gt;&lt;/os&gt;,另请参阅 maven.apache.org/enforcer/enforcer-rules/requireOS.html。尽管我经常写配置文件经常被滥用,但由于这是操作系统特定的请求,所以允许配置文件。既然它都是开源的,为什么不联系 mojo 团队并尝试为 Mac 修复它。
    【解决方案2】:

    【讨论】:

      【解决方案3】:

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

      插件配置:

      <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>
      

      配置文件配置:

      <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>
      

      调用:

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

      【讨论】:

        猜你喜欢
        • 2018-12-24
        • 1970-01-01
        • 2021-09-29
        • 1970-01-01
        • 1970-01-01
        • 2011-03-26
        • 2014-04-23
        • 2015-07-06
        • 2012-03-13
        相关资源
        最近更新 更多