2012-09-04 23 views
12

我想用nexus創建公司本地的maven知識庫。存儲庫不應該從公共互聯網下載任何東西,所有需要的東西都會被添加到回購中。開發人員的本地maven instanses應該從公司網站下載所需的庫和工具。我已設法在settings.xml中使用鏡子這樣做:如何只使用公司本地nexus知識庫

<mirror> 
    <id>company-repository</id> 
    <name>Company releases repository</name> 
    <url>http://nexus.company.com/nexus/content/repositories/releases</url> 
    <mirrorOf>*</mirrorOf> 
</mirror> 

問題該解決方案是,我只能指向版本庫,我想包括第三方和快照庫搜索以及。有沒有人知道應該怎麼做?鏡像標籤只有一個網址。

我也試圖與定義這樣的默認配置文件:

<profile>    
    <id>defaultProfile</id> 
    <activation> 
     <activeByDefault>true</activeByDefault> 
    </activation> 
    <repositories> 
     <repository> 
      <id>company-thirdparty-repo</id> 
      <url>http://nexus.company.com//nexus/content/repositories/thirdparty</url> 
      <releases> 
       <checksumPolicy>fail</checksumPolicy> 
      </releases> 
      <snapshots> 
       <enabled>false</enabled> 
      </snapshots> 
     </repository> 
     <repository> 
      <id>company-releases-repo</id> 
      <url>http://nexus.company.com/nexus/content/repositories/releases</url> 
      <snapshots> 
       <enabled>true</enabled> 
       <updatePolicy>always</updatePolicy> 
       <checksumPolicy>fail</checksumPolicy> 
      </snapshots> 
      <releases> 
       <enabled>true</enabled> 
       <checksumPolicy>fail</checksumPolicy> 
      </releases> 
     </repository> 
    </repositories> 
    <pluginRepositories> 
     <pluginRepository> 
      <id>central</id> 
      <url>http://nexus.company.com/nexus/content/repositories/central</url> 
      <releases> 
       <enabled>true</enabled> 
       <checksumPolicy>fail</checksumPolicy> 
      </releases> 
      <snapshots> 
       <checksumPolicy>fail</checksumPolicy> 
      </snapshots> 
     </pluginRepository> 
    </pluginRepositories>    
</profile> 

問題與解決辦法是,如果Maven的不找到這些倉庫的東西它仍然下載它從repo.maven.apache.org。我會感謝任何幫助。謝謝!

回答

5

可以使用二者的組合:

創建遠程公共回購的代理存儲庫組(假設你叫公衆)。使用此鏡像的Maven,這是「中央」

對於其他存儲庫的唯一默認存儲庫,只需將其添加爲存儲庫/插件回購

settings.xml中看起來是這樣的:

<settings> 
    <mirrors> 
     <mirror> 
      <id>nexus</id> 
      <mirrorOf>central</mirrorOf> 
      <url>http://your/nexus/groups/public</url> 
     </mirror> 
    </mirrors> 

    <profiles> 
     <profile> 
      <id>nexus</id> 
      <repositories> 
       <repository> 
        <!-- for you to override settings of central --> 
        <id>central</id> 
        <url>http://a.fake.host</url> 
        <releases><enabled>true</enabled></releases> 
        <snapshots><enabled>true</enabled></snapshots> 
       </repository> 
       <repository> 
        <id>anotherRepo</id> 
        <url>http://your/nexus/groups/anotherRepo</url> 
        <releases><enabled>true</enabled></releases> 
        <snapshots><enabled>true</enabled></snapshots> 
       </repository> 

      </repositories> 
      <pluginRepositories> 
       <pluginRepository> 
        <!-- for you to override settings of central --> 
        <id>central</id> 
        <url>http://a.fake.host</url> 
        <releases><enabled>true</enabled></releases> 
        <snapshots><enabled>true</enabled></snapshots> 
       </pluginRepository> 

       <pluginRepository> 
        <id>anotherRepo</id> 
        <url>http://your/nexus/groups/anotherRepo</url> 
        <releases><enabled>true</enabled></releases> 
        <snapshots><enabled>true</enabled></snapshots> 
       </pluginRepository> 
      </pluginRepositories> 
     </profile> 
    </profiles> 

    <activeProfiles> 
     <activeProfile>nexus</activeProfile> 
    </activeProfiles> 
</settings> 
+0

標籤你需要說「*」,否則只有中央將被鏡像(看看這裏:http://www.sonatype.com/books/nexus-book/reference/maven-sect-single-group.html )。 – khmarbaise

+0

@khmarbaise這就是我想要做的:在nexus回購組中鏡像中心,並在其上添加額外的回購 –

+0

爲了解決這個問題,它應該在Nexus中配置,而不是在settings.xml中配置。 – khmarbaise