2015-04-01 63 views
1

我有安裝在其上構建框:有沒有像本地遠程Maven倉庫這樣的事情?

  • Maven的
  • Archiva

我已經配置竹子從遠程的Git源搶我的Maven項目,然後建設它與目標'乾淨安裝'。

我有兩個回購配置Archiva:

  1. 鏡 - 中央
  2. dev的的鏡 - 回購爲我的工件

我已作了如下改動的Maven的settings.xml :

# Define local repo - this is the same location as i have set up for the Archiva 'dev' repo. 
<localRepository>/opt/maven-repo/dev</localRepository> 

# Define the Archiva mirror i set up 
<mirror> 
    <id>mirror</id> 
    <url>http://localhost:8080/repository/mirror/</url> 
    <mirrorOf>external:*</mirrorOf> 
</mirror> 

當我執行構建時,Maven通過th e鏡像,然後將構建的工件添加到dev,以及從鏡像中抓取的其他jar。所以,我現在有一些重複的罐子...

\回購\後視鏡\的JUnit \ JUnit的 \回購\後視鏡\ classworlds \ classworlds \回購\ dev的\的JUnit \ JUnit的 \回購\ dev的\ classworlds \ classworlds \ repo \ dev \ me \ myartifact

我的問題是,是正確的方法嗎?真的,我想保留'開發'只有我的文物和鏡像與中央的一切 - 我不想重複。

我應該在settings.xml中使用LocalRepository配置,還是應該使用'mvn deploy'通過其他方法將工件放入我的Archiva存儲庫中?

有人可以澄清本地和遠程存儲庫的不同用例嗎?

最後,我應該如何定義我的POM?目前,我剛剛定義了

<distributionManagement> 
    <repository> 
     <id>dev</id> 
     <url>file:///repo/dev</url> 
    </repository> 
</distributionManagement> 

我應該在鏡子中加入嗎?

回答

0

要將工件放入資源庫管理器,您應該使用默認值maven-deploy-plugin,它可以由distributionManagement控制。通過定義distributionManagement來控制放置這些東西的目標。

<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"> 
    ... 
    <distributionManagement> 
    <repository> 
     <id>releases</id> 
     <name>Release</name> 
     <url>http://urlArchiva/releases/</url> 
    </repository> 
    <snapshotRepository> 
     <id>snapshots</id> 
     <name>Snapshots</name> 
     <url>http://urlArchiva/snapshots/</url> 
    </snapshotRepository> 
    ... 
    </distributionManagement> 
    ... 
</project> 

這是用來消費的文物是從在settings.xml定義

<settings> 
    <mirrors> 
    <mirror> 
     <!--This sends everything else to /public --> 
     <id>nexus</id> 
     <mirrorOf>*</mirrorOf> 
     <url>http://serverUrlArchiva/public/</url> 
    </mirror> 
    </mirrors> 
    <profiles> 
    <profile> 
     <id>nexus</id> 
     <repositories> 
     <repository> 
      <id>central</id> 
      <url>http://central</url> 
      <releases><enabled>true</enabled></releases> 
      <snapshots><enabled>true</enabled></snapshots> 
     </repository> 
     </repositories> 
    <pluginRepositories> 
     <pluginRepository> 
      <id>central</id> 
      <url>http://central</url> 
      <releases><enabled>true</enabled></releases> 
      <snapshots><enabled>true</enabled></snapshots> 
     </pluginRepository> 
     </pluginRepositories> 
    </profile> 
    </profiles> 
    <activeProfiles> 
    <!--make the profile active all the time --> 
    <activeProfile>nexus</activeProfile> 
    </activeProfiles> 
</settings> 

竹,你應該能夠控制哪些的settings.xml用於有每一個本地倉庫的庫使構建彼此獨立的構建。

相關問題