搭建 maven服务器(repository)方法中文翻译

 

用Artifactory管理内部Maven仓库

1. 介绍

  Maven是Java开发者中流行的构建工具,Maven的好处之一是可以帮助减少构建应用程序时所依赖的软件构件的副本,Maven建议的方法是将所有软件构件存储于一个叫做repository的远程仓库中。

  Maven会从ibiblio.org中的公用仓库中同步构件,这个公用仓库下载缓慢、 不稳定,并且不包含一些构件的最新版本,而且不能上传团队私有的构件。通过设置内部Maven仓库,团队可以更有好地利用Maven仓库的优势并且克服使 用ibiblio上的仓库时的缺点。

  本文着眼于Maven仓库工具应提供的一些功能,列出了选择Maven仓库工具的标准, 说明了使用Artifactory设置Maven仓库的相关步骤。在Linux和Windows中设置Maven仓库的过程是相同的,少数不同点在文中已 经用高亮显示,本文列出了与这个Maven仓库的使用有关的POM文件的范例,用截图来向用户阐述如何设置Maven仓库,Maven和 artifactory配置范例也有列出。

 

1.1 背景知识

  本文假定读者熟悉以下的概念和技术:

    Maven 2

    J2EE web 服务器部署过程(e.g. 在Tomcat中部署Web应用程序)

    XML

 

1.2 Maven仓库的目的 

  Maven仓库的目的是作为团队内所使用的所有软件构件的内部私有构件仓库,将 Maven构件(jar和pom)存储到一个专门的Maven仓库比将它们存储到版本控制系统中更有优势,这是因为:

    构件(jar)是二进制文件,不属于版本控制系统,版本控制系统在处理文本文件方面比较好

    保持较小的版本控制数据库

    Checkout、update和其他版本控制的操作可以更快

 

1.3 建立内部私有仓库的优势:

    减少可能的版本冲突

    减少首次构建时需要的手动干涉

    中央仓库包含所有依赖的软件构件,引用单一的中央仓库比引用多个独立的本地库要好 

    使用内部仓库做clean构建时会快些,因为Maven构件是从内部服务器而不是从因特网上的ibiblio服务器获取。

 

1.4 Maven构件库的类型

  本地仓库——位于开发者的机器,由开发者维护,它从位于‘~home/.m2’ 目录的‘settings.xml’文件中定义的Maven仓库上同步,如果在pom.xml或setting.xml文件中没有设置内部私有远程仓库, 那么开发者机器上的这个本地仓库就会从ibiblio.org 上的公用Maven仓库上同步。

  内部私有远程仓库——这是我们将要设置的仓库,我们将改变maven 的pom.xml或settings.xml文件来使用这个库。

  外部公用远程仓库——这是在ibiblio.org上的外部公用仓库,默认情况下,Maven从这个仓库上同步。

2.Maven仓库概览

 

2.1 没有Maven仓库下的开发环境

 

2.2 具有团队内部远程仓库的开发环境

 

 

 

3. 本教程Maven仓库的用例介绍

    在内部仓库中创建2个子库

      Ibiblio 缓存‘Ibiblio-cache’ ——用于存储从ibiblio.org中下载的构件,可以公开访问,它将从外部的ibiblio仓库中同步

      内部仓库internal-maven-repository——用于存储团队内部的构件,它不与任何外部仓库同步,是团队专有的构件库

      可以创建另一个子仓库,这是可选的,用于存储那些公用的但是在ibiblio上暂时没有的构件,例如一些构件的新最版本,这个仓库不与内部仓库同步。我们可以称它为第三方‘3rd-party’

    浏览远程库,最好是通过一个web浏览器

    在仓库中搜索构件

    从版本控制系统中下载代码,修改settings.xml指向内部仓库并且做一次没有任何手工干涉的clean构建

    向仓库中安装一个构件的新版本

    向仓库中大批导入构件

    从仓库中大批导出构件

    手动备份仓库,设置定时自动备份任务

 

4. Maven仓库工具的选择标准

  理想的Maven仓库工具应该:

?   开放源码并且免费

?   提供管理工具

?   提供仓库浏览器——最好是web浏览器而不是桌面应用程序

?   可以部署到标准web服务器中——例如Apache或Tomcat

?   创建、编辑、删除子库的能力

?   批量导入/导出的工具,用来向构件库或从构件库移动构件

?   访问控制工具和匿名只读访问

?   安装和使用简单

?   备份功能

?   问题追踪,论坛或其他独立的信息来源

?   活跃的社区/开发者,这样产品才能改进,bug才能修正

 

5. 不同Maven仓库工具的比较

  一些流行且免费的Maven仓库工具有:

    标准Maven代理codehaus—— http://maven-proxy.codehaus.org/

    Dead simple Maven Proxy (DSMP) - http://www.pdark.de/dsmp/

    Proximity - http://proximity.abstracthorizon.org/

    Artifactory - http://www.jfrog.org/sites/artifactory/latest/

 

  下面列出了一个比较:

 

 

  codehaus DSMP Proximity Artifactory
管理工具 基本
构件库浏览器 基本
部署到标准Web服务器 是(不可配置)  是  是(与Jetty绑定,支持Tomcat)
子库管理  是  是  是  是
批量导入/导出构件  是
安装使用简单  是 是(从代码构建)  是 是(AJAX界面)
备份功能  是(使用quartz和cron表达式)
问题追踪  JIRA,IRC    Wiki issues Tracker  Jira issues Tracker(良好的在线文档)

 

  研究过以上所有产品之后得出结论,Artifactory 拥有我们要的所有标准。Proximity看样子也有许多我们要的特性,我们将着眼于Artifactory 的使用。

  关于Artifactory 的其他方面:

      符合我们的需求

      Apache 2.0 许可

      运行于JDK 1.6和Tomcat 6。Artifactory以‘war’文件形式部署到Tomcat

      使用Derby数据库来存储构件,数据以一个已发布的知名的格式存储

      所有构件可以被批量导出到本地库然后导入到其他库,因而易于将构件从一个仓库工具移到另一个,它也使得Maven库的升级非常容易

      兼容Java Content Repository 标准(JSR-170)。

      使用Lucene作为搜索引擎,仓库可以被索引和重新索引

      Ajax界面

      易于定制界面

      使用JIRA作为问题追踪系统

 

6. 设置Maven仓库

 

6.1 软件需求

  Artifactory——从http://www.jfrog.org/sites/artifactory/latest/ 下载和安装,当前最新版本是1.2.1-rc1,Artifactory是一个可以被安装到Tomcat中去的Web应用程序

  JDK 1.6 – 更多信息请参阅http://www.jfrog.org/sites/artifactory/latest/install.html

  Tomcat 6

 

6.2 目录结构

  下载和解压artifactory。目录结构如下:

 

 

  这些目录是:

    backup —— 仓库的备份,可以使用cron表达式设置备份策略,quartz定时调度程序在指定的时间里运行备份任务,备份时间间隔在 ‘ARTIFACTORY_INSTALLATION_FOLDER>/etc/artifactory.config.xml’文件中指定

    bin ——内置jetty 服务器的运行批处理文件

    data —— 包含derby数据库文件,如果你想以一个空的构件库开始,可以删除这个目录中的所有内容,在全新的artifactory 安装中,这个目录是空的。

    etc —— artifactory 的配置文件,有‘artifactory.config.xml’ 、‘jetty.xml ‘和‘log4j.,properties’

    lib —— 包含所有依赖的jar文件

    logs —— 日志文件

    webapps —— 包含war文件,它可以被拷贝到Tomcat中安装。

 

6.2 在Tomcat 6中部署

  部署 ‘<ARTIFACTORY_INSTALLATION_FOLDER>/webapp’目录中的war文件到 ‘<TOMCAT_INSTALLATION_FOLDER>/webapps’目录中,在jdk1.6和Tomcat 6环境下不需要改变tomcat的配置,Tomcat 6会检测并部署它。

  当这个Web应用程序被部署的时候,需要这些信息:

    保存构件的数据库的位置

    artifactory 的xml配置文件的位置

    备份目录的位置

  可以在一个配置文件中指定所有3个信息,在Tomcat启动期间我们只需要指定 artifactory的安装目录,artifactory会计算出其余的信息。可选的方法是使用jdbc设置好derby数据库的连接并且在Web应用 程序中配置好artifactory (通过在Web应用程序中包含artifactory.config.xml文件)。不管怎样,这个方法是简单的。

  artifactory 安装目录的位置可以被设置为一个环境变量,在Linux中,用‘.bash’来输出artifactory 安装目录的位置的脚本是:

 

Java代码

 

  1. export JAVA_OPTS = -D<SPAN class=hilite1>artifactory</SPAN>.home=/home/amangat/<SPAN class=hilite1>artifactory</SPAN>-1.2.1-rc1  

export JAVA_OPTS = -Dartifactory.home=/home/amangat/artifactory-1.2.1-rc1

 

  在Windows中,可以添加到Tomcat启动选项中:

 

 

6.3 设置Maven仓库

  建议的方法是在我们的Maven仓库中创建3个库(或子库),它们是:

    内部私有仓库private-internal-repository:这个仓库包含仅在团队内使用的构件,它们由开发者手动上传,这个仓库不与ibiblio 中的远程仓库同步,因为这个仓库(或子仓库)中的构件是团队私有的。

    第三方库3rd-party:这个仓库包含公有的但不在ibiblio服务器上的构件,例如,最新版本的尚不在ibiblio的组件或jdbc驱动。这个仓库不与ibiblio 同步,因为ibiblio 没有这些jar。

    Ibiblio 缓存Ibiblio-cache:这个仓库与ibiblio 仓库同步,它是ibiblio 上的构件的缓存。

 

  设置这三个仓库,需要修改<ARTIFACTORY_INSTALLATION_FOLDER>/etc/artifactory.config.xml’中的配置:

 

Xml代码

 

  1. <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  2.         xmlns="http://<SPAN class=hilite1>artifactory</SPAN>.jfrog.org/xsd/1.0.0"  
  3.         xsi:schemaLocation="http://<SPAN class=hilite1>artifactory</SPAN>.jfrog.org/xsd/1.0.0   
  4.         http://www.jfrog.org/xsd/<SPAN class=hilite1>artifactory</SPAN>-v1_0_0.xsd">  
  5.     <!-- Backup every 12 hours -->  
  6.     <!--<backupCronExp>0 0 /12 * * ?</backupCronExp>-->  
  7.     <localRepositories>  
  8.       <localRepository>  
  9.           <key>private-internal-repository</key>  
  10.           <description>Private internal repository</description>  
  11.           <handleReleases>true</handleReleases>  
  12.           <handleSnapshots>true</handleSnapshots>  
  13.       </localRepository>  
  14.       <localRepository>  
  15.           <key>3rd-party</key>  
  16.           <description>3rd party jars added manually</description>  
  17.           <handleReleases>true</handleReleases>  
  18.           <handleSnapshots>false</handleSnapshots>  
  19.       </localRepository>  
  20.     </localRepositories>  
  21.     <remoteRepositories>  
  22.       <remoteRepository>  
  23.           <key>ibiblio</key>  
  24.           <handleReleases>true</handleReleases>  
  25.           <handleSnapshots>false</handleSnapshots>  
  26.           <excludesPattern>org/<SPAN class=hilite1>artifactory</SPAN>/**,org/jfrog/**</excludesPattern>  
  27.           <url>http://repo1.maven.org/maven2</url>  
  28.       </remoteRepository>  
  29.     </remoteRepositories>  
  30. </config>  

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://artifactory.jfrog.org/xsd/1.0.0" xsi:schemaLocation="http://artifactory.jfrog.org/xsd/1.0.0 http://www.jfrog.org/xsd/artifactory-v1_0_0.xsd"> <!-- Backup every 12 hours --> <!--<backupCronExp>0 0 /12 * * ?</backupCronExp>--> <localRepositories> <localRepository> <key>private-internal-repository</key> <description>Private internal repository</description> <handleReleases>true</handleReleases> <handleSnapshots>true</handleSnapshots> </localRepository> <localRepository> <key>3rd-party</key> <description>3rd party jars added manually</description> <handleReleases>true</handleReleases> <handleSnapshots>false</handleSnapshots> </localRepository> </localRepositories> <remoteRepositories> <remoteRepository> <key>ibiblio</key> <handleReleases>true</handleReleases> <handleSnapshots>false</handleSnapshots> <excludesPattern>org/artifactory/**,org/jfrog/**</excludesPattern> <url>http://repo1.maven.org/maven2</url> </remoteRepository> </remoteRepositories></config>

 

 

  启动Tomcat并且输入 http://localhost:8080/artifactor

  下面是artifactory的首页面:

 

 

  以用户名admin和密码password登录,点击浏览仓库的链接,你可以查看仓库的内容。

 

 

7.配置Maven以使用新的仓库

 

7.1 配置Maven的settings.xml 文件

  Maven使用位于‘~/.m2/settings.xml’目录的 settings.xml文件来获取Maven仓库 ,如果没有在该文件中指定仓库,Maven默认使用ibiblio.org上的仓库, settings.xml文件必须被修改以使用新的仓库:

 

Xml代码

 

  1. <profiles>  
  2.       <profile>  
  3.             <id>dev</id>  
  4.             <properties>  
  5.                   <tomcat5x.home>C:/InstalledPrograms/apache-tomcat-5.5.20</tomcat5x.home>  
  6.             </properties>  
  7.             <repositories>  
  8.                   <repository>  
  9.                         <id>central</id>  
  10.                         <url>http://localhost:8080/<SPAN class=hilite1>artifactory</SPAN>/repo</url>  
  11.                         <snapshots>  
  12.                               <enabled>false</enabled>  
  13.                         </snapshots>  
  14.                   </repository>  
  15.                   <repository>  
  16.                         <id>snapshots</id>  
  17.                         <url>http://localhost:8080/<SPAN class=hilite1>artifactory</SPAN>/repo</url>  
  18.                         <releases>  
  19.                               <enabled>false</enabled>  
  20.                         </releases>  
  21.                   </repository>  
  22.             </repositories>  
  23.             <pluginRepositories>  
  24.                   <pluginRepository>  
  25.                         <id>central</id>  
  26.                         <url>http://localhost:8080/<SPAN class=hilite1>artifactory</SPAN>/repo</url>  
  27.                         <snapshots>  
  28.                               <enabled>false</enabled>  
  29.                         </snapshots>  
  30.                   </pluginRepository>  
  31.                   <pluginRepository>  
  32.                         <id>snapshots</id>  
  33.                         <url>http://localhost:8080/<SPAN class=hilite1>artifactory</SPAN>/repo</url>  
  34.                         <releases>  
  35.                               <enabled>false</enabled>  
  36.                         </releases>  
  37.                   </pluginRepository>  
  38.             </pluginRepositories>  
  39.       </profile>  
  40. </profiles>  

<profiles> <profile> <id>dev</id> <properties> <tomcat5x.home>C:/InstalledPrograms/apache-tomcat-5.5.20</tomcat5x.home> </properties> <repositories> <repository> <id>central</id> <url>http://localhost:8080/artifactory/repo</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>snapshots</id> <url>http://localhost:8080/artifactory/repo</url> <releases> <enabled>false</enabled> </releases> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://localhost:8080/artifactory/repo</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> <pluginRepository> <id>snapshots</id> <url>http://localhost:8080/artifactory/repo</url> <releases> <enabled>false</enabled> </releases> </pluginRepository> </pluginRepositories> </profile></profiles>

 

 

7.2 使用pom.xml配置Maven

  也可以在项目的pom.xml文件中设置仓库,下面是pom.xml范例文件:

 

Xml代码

 

  1. <project xmlns="http://maven.apache.org/POM/4.0.0"  
  2. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0   
  4. <A href="http://maven.apache.org/maven-v4_0_0.xsd" target=_blank>http://maven.apache.org/maven-v4_0_0.xsd</A>">  
  5. <modelVersion>4.0.0</modelVersion>  
  6. <groupId>test</groupId>  
  7. <artifactId>test</artifactId>  
  8. <packaging>jar</packaging>  
  9. <version>1.0-SNAPSHOT</version>  
  10. <name>test</name>  
  11. <url>http://maven.apache.org</url>  
  12.        <repositories>  
  13.                       <repository>  
  14.                               <id>central</id>  
  15.                       <url>http://localhost:8080/<SPAN class=hilite1>artifactory</SPAN>/repo</url>  
  16.                       <snapshots>  
  17.                               <enabled>false</enabled>  
  18.                       </snapshots>  
  19.               </repository>  
  20.               <repository>  
  21.                       <id>snapshots</id>  
  22.                       <url>http://localhost:8080/<SPAN class=hilite1>artifactory</SPAN>/repo</url>  
  23.                       <releases>  
  24.                               <enabled>false</enabled>  
  25.                       </releases>  
  26.               </repository>  
  27.       </repositories>  
  28.       <pluginRepositories>  
  29.               <pluginRepository>  
  30.                       <id>central</id>  
  31.                       <url>http://localhost:8080/<SPAN class=hilite1>artifactory</SPAN>/repo</url>  
  32.                       <snapshots>  
  33.                               <enabled>false</enabled>  
  34.                       </snapshots>  
  35.               </pluginRepository>  
  36.               <pluginRepository>  
  37.                       <id>snapshots</id>  
  38.                       <url>http://localhost:8080/<SPAN class=hilite1>artifactory</SPAN>/repo</url>  
  39.                       <releases>  
  40.                               <enabled>false</enabled>  
  41.                       </releases>  
  42.               </pluginRepository>  
  43.       </pluginRepositories>  
  44. <dependencies>  
  45.    <dependency>  
  46.      <groupId>junit</groupId>  
  47.      <artifactId>junit</artifactId>  
  48.      <version>3.8.1</version>  
  49.      <scope>test</scope>  
  50.    </dependency>  
  51. </dependencies>  
  52. </project>  

<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.0http://maven.apache.org/maven-v4_0_0.xsd "><modelVersion>4.0.0</modelVersion><groupId>test</groupId><artifactId>test</artifactId><packaging>jar</packaging><version>1.0-SNAPSHOT</version><name>test</name><url>http://maven.apache.org</url> <repositories> <repository> <id>central</id> <url>http://localhost:8080/artifactory/repo</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> <repository> <id>snapshots</id> <url>http://localhost:8080/artifactory/repo</url> <releases> <enabled>false</enabled> </releases> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>central</id> <url>http://localhost:8080/artifactory/repo</url> <snapshots> <enabled>false</enabled> </snapshots> </pluginRepository> <pluginRepository> <id>snapshots</id> <url>http://localhost:8080/artifactory/repo</url> <releases> <enabled>false</enabled> </releases> </pluginRepository> </pluginRepositories><dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency></dependencies></project>

 

 

7.3 使用Maven构件仓库构建项目

  在构建Maven项目的时候,所有的构件库都会从新的仓库下载,控件台会显示下载的过程:

 

  用浏览器登录到新的构件仓库,你会发现artifactory 已经下载并缓存了ibiblio上的构件。

 

 

7.4 安装构件到构件仓库

  可以通过Web界面或Maven命令行安装构件,通过Web界面来安装更简单更快,并且不需要修改任何配置。通过命令行安装需要修改settings.xml配置文件,可以在其他脚本中使用。

 

7.4.1 通过Web界面安装构件

 

  安装步骤如下:

  1. 上传要部署的构件(‘jar’ 文件 或 ‘pom’ 文件)

 

  2. 如果你上传的是jar文件,Artifactory会为它创建pom文件 。上传的时候你可以指定上传到哪个仓库。

 

 

  3. 上传完后,上传的构件与artifactory 自动创建的pom文件一起在仓库中出现。

 

 

7.4.1 能过Maven命令行安装构件

  当用‘mvn clean install’ 命令的时候,Maven仅仅打包和安装构件到本地仓库,要把它安装到APH内部仓库中,我们必须在settings.xml中添加一条额外的配置:

 

Java代码

 

  1. <settings>   
  2.       <servers>   
  3.             <server>   
  4.                   <id>organisation-internal</id>   
  5.                   <username>admin</username>   
  6.                   <password>password</password>   
  7.             </server>   
  8.       </servers>   
  9. </settings>  

<settings> <servers> <server> <id>organisation-internal</id> <username>admin</username> <password>password</password> </server> </servers></settings>

 

 

  安装构件到内部Maven仓库的命令是:

 

Java代码

 

  1. mvn deploy:deploy-file -DrepositoryId=organisation-internal -Durl=http://localhost:8080/<SPAN class=hilite1>artifactory</SPAN>/private-internal-repository   
  2. -DgroupId=test -DartifactId=test -Dversion=1.1 -Dpackaging=jar -Dfile=target/test-1.1.jar  

mvn deploy:deploy-file -DrepositoryId=organisation-internal -Durl=http://localhost:8080/artifactory/private-internal-repository-DgroupId=test -DartifactId=test -Dversion=1.1 -Dpackaging=jar -Dfile=target/test-1.1.jar

 

 

  repositoryId必须与settings.xml中定义的服务器ID相匹配,url必须包含构件将要被安装到的仓库的名称。

 

  新的构件会在仓库中出现,并且artifactory 会自动为我们创建pom文件。

 

8. Artifactory 的其他特性

 

8.1 备份构件仓库

  备份策略在 <ARTIFACTORY_INSTALLATION_FOLDER>/etc/artifactory.config.xml中指定,使用 cron表达式来指定定时备份任务,配置备份任务的元素在下面的代码清单中用高亮显示出来了

 

Xml代码

 

  1. <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  2.         xmlns="http://<SPAN class=hilite1>artifactory</SPAN>.jfrog.org/xsd/1.0.0"  
  3.         xsi:schemaLocation="http://<SPAN class=hilite1>artifactory</SPAN>.jfrog.org/xsd/1.0.0   
  4.         http://www.jfrog.org/xsd/<SPAN class=hilite1>artifactory</SPAN>-v1_0_0.xsd">  
  5.     <!-- Backup every 12 hours -->  
  6.     <backupCronExp>0 0 /12 * * ?</backupCronExp>  
  7.     <localRepositories>  
  8.       <localRepository>  
  9.           <key>private-internal-repository</key>  
  10.           <description>Private internal repository</description>  
  11.           <handleReleases>true</handleReleases>  
  12.           <handleSnapshots>true</handleSnapshots>  
  13.       </localRepository>  
  14.       <localRepository>  
  15.           <key>3rd-party</key>  
  16.           <description>3rd party jars added manually</description>  
  17.           <handleReleases>true</handleReleases>  
  18.           <handleSnapshots>false</handleSnapshots>  
  19.       </localRepository>  
  20.     </localRepositories>  
  21.     <remoteRepositories>  
  22.       <remoteRepository>  
  23.           <key>ibiblio</key>  
  24.           <handleReleases>true</handleReleases>  
  25.           <handleSnapshots>false</handleSnapshots>  
  26.           <excludesPattern>org/<SPAN class=hilite1>artifactory</SPAN>/**,org/jfrog/**</excludesPattern>  
  27.           <url>http://repo1.maven.org/maven2</url>  
  28.       </remoteRepository>  
  29.     </remoteRepositories>  
  30. </config>  

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://artifactory.jfrog.org/xsd/1.0.0" xsi:schemaLocation="http://artifactory.jfrog.org/xsd/1.0.0 http://www.jfrog.org/xsd/artifactory-v1_0_0.xsd"> <!-- Backup every 12 hours --> <backupCronExp>0 0 /12 * * ?</backupCronExp> <localRepositories> <localRepository> <key>private-internal-repository</key> <description>Private internal repository</description> <handleReleases>true</handleReleases> <handleSnapshots>true</handleSnapshots> </localRepository> <localRepository> <key>3rd-party</key> <description>3rd party jars added manually</description> <handleReleases>true</handleReleases> <handleSnapshots>false</handleSnapshots> </localRepository> </localRepositories> <remoteRepositories> <remoteRepository> <key>ibiblio</key> <handleReleases>true</handleReleases> <handleSnapshots>false</handleSnapshots> <excludesPattern>org/artifactory/**,org/jfrog/**</excludesPattern> <url>http://repo1.maven.org/maven2</url> </remoteRepository> </remoteRepositories></config>

 

 

  备份文件存储在 ‘<ARTIFACTORY_INSTALLATION_FOLDER>/backups’目录,备份文件的格式与开发者机器上的本地仓库一致,这使得要移植仓库内容到其他Maven仓库工具中时非常容易。

 

8.2 其他特性

  通过Web界面删除构件

  通过Web界面搜索构件

  批量导入/导出仓库中的所有构件

  如果不要求使用Tomcat,可以使用内置的jetty服务器

 

9. 结论

  内部私有Maven仓库加快构建的过程并且使clean构建更简单,它还帮助避免不同构件版本的冲突。

  在这4款通用的Maven构件仓库工具中,看样子Artifactory 是比较好的产品。

  Artifactory使得设置Maven仓库变得简单;它提供了一个好的Maven仓 库工具应该实现的所有功能;团队不会被锁定在这个工具上,因为可以容易地移植仓库内容到其他仓库工具上;对于不知道Maven仓库如何工作的人来 说,Web界面使得他们能很容易地使用仓库。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章