2013-01-08 56 views
17

如何配置maven項目以將快照和發佈版本部署到Nexus?如何配置maven項目以將快照和發佈版本部署到Nexus?

<distributionManagement> 
    <repository> 
     <id>InternalReleases</id> 
     <name>Internal Releases</name> 
     <url>http://192.168.16.232:8081/nexus/content/repositories/releases/</url> 
    </repository> 
    <repository> 
     <id>InternalSnapshots</id> 
     <name>Internal Snapshots</name> 
     <url>http://192.168.16.232:8081/nexus/content/repositories/snapshots/</url> 
    </repository> 
</distributionManagement> 

這種配置在Eclipse 3.8與M2E 1.2

Project build error: Non-parseable POM D:\Workspaces\W\Parent\pom.xml: Duplicated tag: 'repository' (position: START_TAG 
seen ... 

我要部署到InternalSnapshots庫神器當POM版的後綴有-SNAPSHOT並部署到InternalReleases庫裏創建了錯誤,當它是RELEASE。這應該使用相同的pom.xml文件並執行相同的mvn deploy命令。

回答

28

您需要區分版本和快照存儲庫。 <distributionManagement>只允許一個<repository>和一個<snapshotRepository>孩子。

http://maven.apache.org/pom.html#Distribution_Management

+1

配置文件允許一個使用不同部分。如果您有多個,那麼您可以使用不同的配置文件來完成它。 –

18

例pom.xml的配置

<!-- http://maven.apache.org/pom.html#Distribution_Management --> 
<distributionManagement> 
    <snapshotRepository> 
     <id>InternalSnapshots</id> 
     <name>Internal Snapshots</name> 
     <url>http://192.168.16.232:8081/nexus/content/repositories/snapshots/</url> 
    </snapshotRepository> 
    <repository> 
     <id>InternalReleases</id> 
     <name>Internal Releases</name> 
     <url>http://192.168.16.232:8081/nexus/content/repositories/releases/</url> 
    </repository> 
</distributionManagement> 

片段的.m2目錄/ settings.xml中默認的Nexus安裝

<server> 
    <id>thirdparty</id> 
    <username>deployment</username> 
    <password>deployment123</password> 
</server> 
<server> 
    <id>InternalReleases</id> 
    <username>deployment</username> 
    <password>deployment123</password> 
</server> 
<server> 
    <id>InternalSnapshots</id> 
    <username>deployment</username> 
    <password>deployment123</password> 
</server> 

0

你都可以做的。

添加行家釋放小插件2.5.3

運行以下命令:

MVN部署清潔:發佈版本:準備發佈:執行

+1

這很好,但它需要Maven和項目已經配置好了,這就是問題的關鍵:如何配置 –