所以我已经完成了 mvn release:clean 和 mvn release:prepare。
因此,我的 subversion 上有一个干净的标签,其中包含我的 Artifact 的最新版本 1.3.3。
现在我想在本地 Maven 存储库 (.m2) 上安装该版本 1.3.3,而不是安装到远程中央 Maven 存储库。
如何做到这一点?
我需要更改我的settings.xml 中的某些内容吗???
我需要运行 mvn release:perform 并使用某种本地选项吗???现在,如果我运行 mvn release:perform ,它将尝试将我的 Artifact 发布到 Maven 中央存储库,这正是我不想要的。我想将其本地发布到我的其他本地项目,所以我可以这样做:
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>myartifact</artifactId>
<version>1.3.3</version>
</dependency>
有趣的是,快照工作正常:
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>myartifact</artifactId>
<version>1.3.4-SNAPSHOT</version>
</dependency>
所以我正在安装快照,但不是完整版本。
这是我的settings.xml:
<settings>
<profiles>
<profile>
<id>allow-snapshots</id>
<activation><activeByDefault>true</activeByDefault></activation>
<repositories>
<repository>
<id>snapshots-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>mac-profile</id>
<properties>
<project.build.sourceEncoding>
UTF-8
</project.build.sourceEncoding>
<project.reporting.outputEncoding>
UTF-8
</project.reporting.outputEncoding>
</properties>
</profile>
</profiles>
<activeProfiles>
<activeProfile>mac-profile</activeProfile>
</activeProfiles>
<pluginGroups>
<pluginGroup>org.sonatype.plugins</pluginGroup>
</pluginGroups>
<servers>
<server>
<id>sonatype-nexus-snapshots</id>
<username>myUsername</username>
<password>myPassword</password>
</server>
<server>
<id>sonatype-nexus-staging</id>
<username>myUsername</username>
<password>myPassword</password>
</server>
</servers>
</settings>
最佳答案
最简单的做法是 checkout 另一个目录中的标签,然后运行
mvn install
但是,如果你想使用release:perform,你需要改变目标。
http://maven.apache.org/maven-release/maven-release-plugin/perform-mojo.html#goals是参数,请将其设置为 install
而不是 deploy
。
关于java - 如何在本地安装项目的标记版本(即不是快照)而不是安装到 Maven 中心?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22387502/