2015-11-03 102 views
0

您好,我一直在嘗試創建一個適當的Maven構建版本。我創造了我的pom.xml文件,該文件是這樣的:使用Maven構建

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.mycompany.app</groupId> 
    <artifactId>my-app</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>XO Artifactory</name> 
    <url>artifactory:8081/artifactory/webapp/home.html?0</url> 

    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.8.2</version> 
     <scope>test</scope> 
    </dependency> 
    </dependencies> 

</project> 

我想有構建發佈到artifactory的,我也想有建立依賴關係是artifactory的爲好。爲了構建發佈到artifactory,它將在settings.xml中正確設置?

將Settings.xml:

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 
         http://maven.apache.org/xsd/settings-1.0.0.xsd"> 
    <servers> 
    <server> 
     <id>artifactory:8081/artifactory/webapp/home.html?0</id> 
     <username>mhopper</username> 
     <password>*******</password> 
    </server> 
    </servers> 

</settings> 
+0

你正在運行的所有行家的命令已經盡力做到這一點?如果是這樣,你可以分享他們嗎? –

+0

現在我正在使用「mvn package」 – Macauley

+0

你會想看看部署階段 - https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html –

回答

1

需要在此兩個步驟:

  1. 添加適當的服務器設置到本地〜/ .m2目錄/包含的ID的settings.xml你服務器和憑據來訪問它:

    <servers> 
        <server> 
        <id>deployment</id> 
        <username>deployment</username> 
        <password>deployment123</password> 
        </server> 
    </servers> 
    
  2. Backref在你的項目的ID pom.xml的,你定義實際網址是:

    <distributionManagement> 
        <repository> 
        <id>deployment</id> 
        <name>Internal Releases</name> 
        <url>artifactory:8081/artifactory/releases</url> 
        </repository> 
        <snapshotRepository> 
        <id>deployment</id> 
        <name>Internal Snapshots</name> 
        <url>artifactory:8081/artifactory/snapshots</url> 
        </snapshotRepository> 
    </distributionManagement> 
    
+0

我有一個設置.xml文件我將在我的初始描述中添加它!我也會編輯我的Pom.xml文件,看看它是否有效! – Macauley

+0

在你的settings.xml中,應該有一個id而不是工件庫的完整URL。 – ferdy