【问题标题】:Run Maven Enforcer Plugin rule on command line在命令行上运行 Maven Enforcer Plugin 规则
【发布时间】:2014-03-03 21:18:53
【问题描述】:

我想在没有任何 POM 配置的 Maven 项目上强制执行 Maven Enforcer 插件的 requireReleaseDeps 规则,只需作为命令行调用。

根据文档,我应该能够像这样传递规则参数

mvn enforcer:enforce -Drules=requireReleaseDeps

或者这应该可以工作

mvn enforcer:enforce -Drules=org.apache.maven.plugins.enforcer.RequireReleaseDeps

但是这两个调用都会导致

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (default-cli) on project hel
lo-world: The parameters 'rules' for goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce are missing or in
valid -> [Help 1]

任何人都知道这个使用场景是否真的以某种方式工作,还是我必须在这个阶段深入调试插件才能解决这个问题?

【问题讨论】:

  • 我查看了docs for the enforce goal,并没有为rules参数设置用户属性,根据我的经验,这意味着您无法从命令行使用-D定义属性。跨度>
  • 你能给我们看看你的 pom 吗?
  • pom 中没有任何有趣的内容。它应该适用于任何项目。
  • @ManfredMoser 这是不久前的事了,但是.. 你找到/应用任何解决方案了吗?
  • 不...在某个阶段,我将不得不为插件创建一个补丁。只需要找时间这样做..

标签: maven maven-enforcer-plugin


【解决方案1】:

它适用于3.0.0-M3 版本:

mvn org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-M3:enforce -Drules=requireReleaseDeps

【讨论】:

    【解决方案2】:

    随着插件版本 3.0.0-M3 和更新版本的发布,enforcer 目标现在支持规则参数和命令行执行,而无需在 pom 中进行配置。更多信息请访问https://maven.apache.org/enforcer/maven-enforcer-plugin/enforce-mojo.html#commandLineRules

    很遗憾目前没有这样的功能但已经有JIRA Issue for that

    【讨论】:

    • 可惜 JIRA 票自 2012 年以来就在那里,但仍然没有任何行动
    • 为此提供补丁怎么样?
    • 似乎这个功能会出现。至少在 2 天前版本 3.0.0-SNAPSHOT 中已经提交了代码。干得好 Maven 开发者!
    • @FrancoisMarot 谢谢。
    【解决方案3】:

    从 3.0.0 开始提供。已接受答案中的 Jira 问题已解决:https://issues.apache.org/jira/browse/MENFORCER-142

    mvn enforcer:enforce -Drules=alwaysPass,alwaysFail
    

    【讨论】:

    【解决方案4】:

    使用 Atlassian 的插件分支为我工作: mvn org.apache.maven.plugins:maven-enforcer-plugin:3.0.0-atlassian-m01:enforce -Drules=...

    我必须声明他们的插件库:

    <pluginRepositories>
        ....
        <pluginRepository>
            <id>atlassian-3rdparty</id>
            <url>https://maven.atlassian.com/3rdparty</url>
        </pluginRepository>
    </pluginRepositories>
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-23
      • 1970-01-01
      • 1970-01-01
      • 2019-02-24
      • 2017-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多