Maven检查是否已释放所有依赖项

时间:2016-06-30 03:56:21

标签: maven maven-release-plugin versions-maven-plugin

作为发布过程的一部分,我使用mvn versions:use-releases目标将所有-SNAPSHOT依赖项替换为已发布的版本。在此之后,我想检查所有SNAPSHOT依赖项是否已被版本替换。

问题:如何查看?

我知道,maven发布插件会在release-prepare目标中执行此类检查,但我不想使用发布插件。

1 个答案:

答案 0 :(得分:5)

您可以使用maven-enforcer-plugin仔细检查是否仍存在任何SNAPSHOT依赖关系。

来自其requireReleaseDeps规则的the official example

<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依赖项,构建将失败。

您可以将此类配置放在maven profile中并在需要时激活它(因此每当必须执行此检查时)。

相关问题