作者:kylin 出处:http://www.cnblogs.com/kylindai/archive/2007/05/05/736454.html Maven2 & Continuum 持续整合 (1) 经过几天努力,终于将 Maven2 & Continuum 持续整合环境搭建成功,记录在这里。
本文搭建的环境目标如下:
整个环境包括服务器环境和开发人员环境: 服务器:Redhat AS4 Update4 开发环境:WindowsXP
服务器上安装 maven, maven-proxy, subversion, continuumn 开发环境上安装 eclipse, maven-eclipse-plugin, svn-eclipse-plugins
先说 maven 的环境吧: 服务器端的安装 安装 maven 需要先装好 JDK,我安装的是 JDK 1.6,安装好后设置好 JAVA_HOME 和 CLASSPATH 环境变量。
下载 maven2 & maven-proxy (1) maven 下载 下载地址:[url=http://maven.apache.org/download.htmlhttp://maven.apache.org/download.html[/url]] 下载最新的 release 版本 maven-2.0.6 (2) maven-proxy 下载 下载地址:[url=http://maven-proxy.codehaus.org/http://maven-proxy.codehaus.org/[/url]] 下载最新的 release 版本 maven-proxy 0.2
安装 maven & maven-proxy (1) mavne 安装
在 profile 里配置环境变量 MAVEN_HOEM=/usr/local/maven PATH=$PATH:MAVEN_HOME/bin export MAVEN_HOME PATH
测试 maven 安装是否成功
显示 Maven version: 2.0.6 表示安装成功。
创建 /var/maven/repository 目录,用于保存本地的库文件和插件文件
修改全局 maven setting.xml 修改 MAVEN_HOME/conf/seeting.xml
将 localRepository 的路径指向 /var/maven [size=13px] <!-- localRepository | The path to the local repository maven will use to store artifacts. | | Default: ~/.m2/repository --> [color=#ff00][b]/var/maven/repository[/b]
修改 mirrors,添加镜像服务器 maven-proxy 假设镜像服务器 maven-proxy IP 192.168.1.10,域名 maven-proxy.gehouse.cn (如何配置域名,参考我的另一篇文章 [color=#1a8bc8] RedHat AS4 Update4 DNS (bind 9) 配置 [url=http://www.cnblogs.com/kylindai/archive/2007/04/16/716052.htmlhttp://www.cnblogs.com/kylindai/archive/2007/04/16/716052.html[/url]) [size=13px] <!-- mirror | Specifies a repository mirror site to use instead of a given repository. The repository that | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. | --> [color=#ff00][b] maven-proxy.gehouse.cn[/b] [color=#ff00][b]*[/b] [color=#ff00][b] maven-proxy on gehouse.cn[/b] [color=#ff00][b]http://maven-proxy.gehouse.cn:9999/repository/b][
(2) maven-proxy 的安装 (在 maven-proxy.gehouse.cn 的机器上安装)
得到 maven-proxy-standalone-0.2-app.jar
创建镜像服务器缓存 maven 库文件和 maven 插件的目录 # cd /usr/local/maven-proxy
编辑 maven-proxy.properties 配置文件
[size=13px]################ GLOBAL SETTINGS
repo.local.store=[color=#ff00][b]./target/repo[/b]
#The port to listen on - not used if loaded as a webapp port=[b] 9999 [/b] #This is the base area that all files are loaded from. While it is possible to leave this blank, this behaviour #is deprecated and will be disabled in version 2.0. There are too many namespace conflicts caused by not using #a prefix. #The repository will be shown at http://localhost:9999/repository/ #for the .war loaded into a webapp server, the default prefix is "repository" (edit the web.xml to change)
prefix=repository
#This is the simple date format used to display the last modified date while browsing the repository. lastModifiedDateFormat=yyyy/MM/dd HH:mm:ss
################ SNAPSHOT HANDLING #If you want the proxy to look for newer snapshots, set to true snapshot.update=true
################ M2 METADATA HANDLING #If you want the proxy to prevent looking for newer metadata, set to false (default is true) #metadata.update=false
################ M2 POM HANDLING #If you want the proxy to look for newer POMs, set to true (default is false) pom.update=true
################ PROMOTION HANDLING
#Promotion describes the process by which new artifacts are loaded to global maven-proxy repository. It
# #If promotion handling is enabled, then the proxy will not download remote artifacts without permission
# #Permission to download is granted via the Promotion menu which will be enabled
# #If promotion is false, artifacts are sourced from any repository as per normal. # #Promotion and snapshots: If promotion is enabled, snapshots are not downloadable. The concept of using
## promotion=false
################ WEB INTERFACE
serverName=[b]http://maven-proxy.gehouse.cn:9999/b][
#If true, the repository can be browsed browsable=true
#If true, the repository can be searched searchable=true
#Not currently implemented. Will allow webdav access to the repository at some point. webdav=true
#Stylesheet - if configured, will override the default stylesheet shipped with maven-proxy - absolute URLs only #eg. /maven-proxy/style.css, http://www.example.com/style.css stylesheet=/maven-proxy/style.css
#bgColor / bgColorHighlight are replaced in the built in stylesheet to produce a simple color scheme. #If a stylesheet is set, these are not used. bgColor=#14B bgColorHighlight=#94B
#rowColor / rowColorHighlight are replaced in the built in stylesheet to produce a simple color scheme. #If a stylesheet is set, these are not used. rowColor=#CCF rowColorHighlight=#DDF
################ PROXIES #This is just a hack, it should auto discover them [b]#[/b] proxy.list=one,tow,three
#Unauthenticated proxy proxy.one.host=proxy1.example.org proxy.one.port=3128
#Authenticated proxy proxy.two.host=proxy2.example.org proxy.two.port=80 proxy.two.username=username2 proxy.two.password=password2
#Authenticated proxy proxy.three.host=proxy3.example.net proxy.three.port=3129 proxy.three.username=username3 proxy.three.password=password3
################# REPOSITORIES #This is not just a hack, it specifies the order repositories should be checked #Note that the proxy adds a "/" which is why the urls aren't suffixed with a "/" [b]#[/b] repo.list=local-repo,www-ibiblio-org,dist-codehaus-org,private-example-com repo.list=[b] local-repo,repo1-maven-org,www-ibiblio-org,dist-codehaus-org[/b]
#local-store
repo.local-repo.url=file:///./target/repo-local repo.local-repo.description=Super Secret Custom Repository #If copy is true, jars are copied from the store to the proxy-repo. Only configurable for file:/// repos repo.local-repo.copy=false #If hardfail is true, any unexpected errors from the repository will cause #the client download to fail (typically with a 500 error) repo.local-repo.hardfail=true #Don't cache a file repository repo.local-repo.cache.period=0
[b]#repo1.maven.org repo.repo1-maven-org.url=http://repo1.maven.org/maven2 repo.repo1-maven-org.description=repo1.maven.org #repo.repo1-maven-org.proxy=one repo.repo1-maven-org.hardfail=false repo.repo1-maven-org.cache.period=360000 repo.repo1-maven-org.cache.failures=true [/b] #www.ibiblio.org repo.www-ibiblio-org.url=http://www.ibiblio.org/maven repo.www-ibiblio-org.description=www.ibiblio.org [b]#[/b] repo.www-ibiblio-org.proxy=one repo.www-ibiblio-org.hardfail=true #Cache this repository for 1 hour repo.www-ibiblio-org.cache.period=3600 repo.www-ibiblio-org.cache.failures=true
#dist.codehaus.org repo.dist-codehaus-org.url=http://dist.codehaus.org [b]#[/b] repo.dist-codehaus-org.proxy=two repo.dist-codehaus-org.hardfail=false repo.dist-codehaus-org.cache.period=3600 repo.dist-codehaus-org.cache.failures=true
#private.example.com repo.private-example-com.url=http://private.example.com/internal repo.private-example-com.description=Commercial In Confidence Repository repo.private-example-com.username=username1 repo.private-example-com.password=password1 repo.private-example-com.proxy=three repo.private-example-com.cache.period=3600
注意阅读这个配置文件,里面定义了 maven-proxy 服务器的端口,缓存库文件的路径,被镜像的服务器的列表等。
编辑启动 maven-proxy 的脚本 startup.sh
[size=13px] java - jar maven - proxy - standalone - 0.2 - app.jar maven - proxy.properties >/ dev / [color=#00ff] null &
启动 maven-proxy.sh
在开发环境里的浏览器地址栏输入 [url=http://maven-proxy.gehouse.cn:9999/repositoryhttp://maven-proxy.gehouse.cn:9999/repository[/url]] 可以看到这个 maven-proxy 的页面,说明安装成功。