Maven check that all dependencies have been released

佐手、 提交于 2019-12-12 10:48:38

问题


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.

Question: How can I check it?

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.


回答1:


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

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>

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

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



来源:https://stackoverflow.com/questions/38113721/maven-check-that-all-dependencies-have-been-released

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!