禁用 mvn 快照不起作用
disable mvn snapshot didn't working
根据 this 的回答,我试图通过 <enabled>false</enabled>
避免快照人工制品,但 Maven 仍然从快照存储库下载人工制品并且不会使构建失败。
<repositories>
<repository>
<id>s3-snapshot</id>
<url>s3://my_url/snapshot</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
强制 Maven 不使用快照工件的最佳方法是什么?
在回答这个问题时:
What can be best way to enforce maven to not use snapshot artefacts ?
如果在您的项目依赖项中找到任何快照版本,Maven Enforcer 插件的 requireReleaseDeps 规则将导致构建失败。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M1</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>
更新 回复:
how could I make this rule conditional e.g. I want to run this rule only if cmd-line param -DisRelease=true
只需将插件定义移动到配置文件下,例如...
<profiles>
<profile>
<id>release</id>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M1</version>
...
</plugin>
</plugins>
</profile>
</profiles>
...然后执行如下:
mvn clean install -Prelease
根据 this 的回答,我试图通过 <enabled>false</enabled>
避免快照人工制品,但 Maven 仍然从快照存储库下载人工制品并且不会使构建失败。
<repositories>
<repository>
<id>s3-snapshot</id>
<url>s3://my_url/snapshot</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
强制 Maven 不使用快照工件的最佳方法是什么?
在回答这个问题时:
What can be best way to enforce maven to not use snapshot artefacts ?
如果在您的项目依赖项中找到任何快照版本,Maven Enforcer 插件的 requireReleaseDeps 规则将导致构建失败。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M1</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>
更新 回复:
how could I make this rule conditional e.g. I want to run this rule only if cmd-line param -DisRelease=true
只需将插件定义移动到配置文件下,例如...
<profiles>
<profile>
<id>release</id>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M1</version>
...
</plugin>
</plugins>
</profile>
</profiles>
...然后执行如下:
mvn clean install -Prelease