【问题标题】:Maven Versions Plugin - Skip running maven versions plugin during mvn build installMaven 版本插件 - 在 mvn 构建安装期间跳过运行的 Maven 版本插件
【发布时间】:2021-10-02 19:02:03
【问题描述】:

每当我运行 mvn clean install 时,我都希望运行 mvn 版本插件,这就是我的项目当前的运行方式。这是完美的,但有时我可能不想运行 maven 版本插件以加快构建时间(这种情况更多是规则的例外)。

但无论如何我都找不到跳过它...(没有 -DskipVersions=true AFAIK)。

有谁知道我怎样才能跳过只执行这个插件?

maven-versions-plugin: https://www.mojohaus.org/versions-maven-plugin/

【问题讨论】:

  • 第一个问题:为什么每次构建都会运行?此外,您真的需要mvn clean install 还是mvn clean verify 足够...?
  • 您能展示一下您是如何使用版本插件的吗?
  • 每次我运行 mvn clean install 时它都会运行,因为我希望它在每次构建时通知我们可用的 dep 更新
  • 我会每周只运行一次新版本的报告,或者可能每晚运行一次,但不是每次构建都运行...这是在浪费时间...
  • 是的,我知道这是在浪费时间。但这并不能回答问题,是否可以使用类似于 -Dskiptests=true 的标志跳过插件执行?

标签: java maven version pom.xml mvn-repo


【解决方案1】:

使用 maven 配置文件执行版本 maven 插件。当 activeByDefault 时,您不需要为 maven build 添加配置文件。

<profiles>
  <profile>
    <id>useVersion</id>
    <activation>
      <activeByDefault>true</activeByDefault>
    </activation>
    <plugins>
         <plugin>
             ...
             <groupId>org.codehaus.mojo</groupId>
             <artifactId>versions-maven-plugin</artifactId>        
              ...
          </plugin>
    </plugins>
  </profile>
</profiles>

您可以使用 ! 禁用配置文件

mvn clean install -P !useVersion

更多信息请关注https://maven.apache.org/guides/introduction/introduction-to-profiles.html

【讨论】:

  • 这完成了工作,非常感谢!我只需要在个人资料名称周围添加单引号!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-06-26
  • 2015-07-11
  • 2013-01-16
  • 2020-09-07
  • 1970-01-01
  • 2014-08-01
相关资源
最近更新 更多