2015-04-01 114 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用于有每一个本地仓库的库使构建彼此独立的构建。

相关问题