Maven检查所有依赖项已被释放 [英] Maven check that all dependencies have been released

查看:195
本文介绍了Maven检查所有依赖项已被释放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为发布过程的一部分,我使用mvn versions:use-releases目标用发布的版本替换所有-SNAPSHOT依赖项.之后,我要检查是否所有的SNAPSHOT依赖项都已被发行版取代.

As part of my release process, I use mvn versions:use-releases goal to replace all -SNAPSHOT dependencies with released versions. After this, I want to check if all the SNAPSHOT dependencies have been replaced with releases or not.

问题:如何检查?

我知道,maven发行插件会执行这样的检查,作为release-prepare目标的一部分,但我不想使用发行插件.

I know, the maven release plugin performs such a check as part of release-prepare goal, but I don't want to use release plugin.

推荐答案

您可以使用 maven-enforcer-plugin 仔细检查是否仍然存在任何SNAPSHOT依赖项.

You can use the maven-enforcer-plugin to double check whether any SNAPSHOT dependency is still there or not.

来自requireReleaseDeps规则的官方示例:

From the official example of its requireReleaseDeps rule:

<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <version>1.4.1</version>
        <executions>
          <execution>
            <id>enforce-no-snapshots</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireReleaseDeps>
                  <message>No Snapshots Allowed!</message>
                </requireReleaseDeps>
              </rules>
              <fail>true</fail>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  [...]
</project>

请注意将fail元素设置为true,在这种情况下,如果找到任何SNAPSHOT依赖项,构建将失败.

Note the fail element set to true, in this case the build would fail if any SNAPSHOT dependency was found.

您可以将这样的配置放置在 maven配置文件中,然后在需要时将其激活(因此必须在执行此检查时).

You could place such configuration in a maven profile and activate it when required (hence whenever this check must be performed).

这篇关于Maven检查所有依赖项已被释放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆