[英]How do I add a Maven dependency in VS Code for a simple Java project (i.e. an unmanaged folder without any build tools)?
[英]How to install a tagged version (i.e. not a snapshot) of your project locally and not to the maven central?
所以我完成了 mvn release:clean 和 mvn release:prepare。
結果,我的 subversion 上有一個干凈的標簽,其中包含我的工件的最新版本 1.3.3。
現在我想在我的本地 maven 存儲庫 (.m2) 上安裝該版本 1.3.3,而不是遠程中央 maven 存儲庫。
怎么做?
我需要更改我的 settings.xml 中的某些內容嗎???
我需要使用某種本地選項運行 mvn release:perform 嗎??? 現在,如果我運行 mvn release:perform,它會嘗試將我的工件發布到 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>
所以我正在安裝快照,而不是完整版本。
這是我的設置。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>
最簡單的操作是在另一個目錄中簽出標簽,然后運行
mvn install
但是,如果要使用release:perform,則需要更改目標。
http://maven.apache.org/maven-release/maven-release-plugin/perform-mojo.html#goals是參數,請說install
而不是deploy
。
您要做的就是:
mvn clean install
我遇到了類似的情況,我需要在執行mvn release:clean release:prepare
時將版本 jars 安裝到本地存儲庫中。 以下對我有用:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<!-- this should do the trick -->
<preparationGoals>install</preparationGoals>
</configuration>
</plugin>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.