小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

使用maven2 進行團隊配置

 figol 2007-01-08
    對于團隊來說,建立統(tǒng)一的開發(fā)環(huán)境是必須的,而maven能很好幫助建立統(tǒng)一的環(huán)境。下面就介紹如何更有效的進行統(tǒng)一的配置。
準備工作:
   下載必須的軟件:
maven2: http://maven./download.html 最主要的
maven-proxy:用來代理repository,使用代理來訪問多個遠程庫
            http://maven-proxy./
continuum:一個不錯的持續(xù)整合工具,用于自動build。支持ant,maven
http://maven./continuum/
svn:版本控制工具

創(chuàng)建一致的開發(fā)環(huán)境
   在共享的開發(fā)環(huán)境中,更好的建議是保持maven的兩個不同的配置文件分別管理,包括共享和用戶自定義設(shè)置。共同的配置包括在安裝目錄中,而單獨的開發(fā)設(shè)置保存在用戶本地目錄。
    全局的配置文件settings.xml
xml 代碼
  1.    <servers>  
  2.        //公司內(nèi)部庫,所有的release版本,serverid對應(yīng)于repository id,用于在deploy時,訪問使用,主要保存用戶名和密碼  
  3. <server>  
  4. <id>internal</id>  
  5. <username>${website.username}</username>  
  6. <password>${website.pwd}</password>  
  7. <filePermissions>664</filePermissions>  
  8. <directoryPermissions>775</directoryPermissions>  
  9. </server>  
  10. //目前的開發(fā)庫,用于snapshot庫  
  11. <server>  
  12. <id>snapshot</id>  
  13. <username>${website.username}</username>  
  14. <password>${website.pwd}</password>  
  15. <filePermissions>664</filePermissions>  
  16. <directoryPermissions>775</directoryPermissions>  
  17. </server>  
  18. </servers>  
  19.   
  20. <profiles>  
  21. <!--定義核心庫 maven 鏡像,由maven-proxy實現(xiàn)-->  
  22. <profile>  
  23. <id>central-repo</id>  
  24. <repositories>  
  25. <repository>  
  26. <id>central</id>  
  27. <name>Internal Repository</name>  
  28. <url>http://192.168.0.2:9999/repository</url>  
  29. </repository>  
  30. </repositories>  
  31. <pluginRepositories>  
  32. <pluginRepository>  
  33. <id>central</id>  
  34. <name>Internal Repository</name>  
  35. <url>http://192.168.0.2:9999/repository</url>  
  36. </pluginRepository>  
  37. </pluginRepositories>  
  38. </profile>  
  39.   
  40. <!--定義內(nèi)部庫,包括公司的所有release版本-->  
  41. <profile>  
  42. <id>internal-repo</id>  
  43. <repositories>  
  44. <repository>  
  45. <id>internal</id>  
  46. <name>Internal Repository</name>  
  47. <url>http://192.168.0.2:8080/repo-local</url>  
  48. <releases>  
  49. <enabled>true</enabled>  
  50. <updatePolicy>never</updatePolicy>  
  51. <checksumPolicy>warn</checksumPolicy>  
  52. </releases>  
  53. </repository>  
  54. </repositories>  
  55. <pluginRepositories>  
  56. <pluginRepository>  
  57. <id>internal</id>  
  58. <name>Internal Plugin Repository</name>  
  59. <url>http://192.168.0.2:8080/repo-local</url>  
  60. <releases>  
  61. <enabled>true</enabled>  
  62. <updatePolicy>never</updatePolicy>  
  63. <checksumPolicy>warn</checksumPolicy>  
  64. </releases>  
  65. </pluginRepository>  
  66. </pluginRepositories>  
  67. </profile>  
  68. <!--定義內(nèi)部開發(fā)庫 ,也可以合并snapshot和release-->  
  69. <profile>  
  70. <id>snapshot-repo</id>  
  71. <repositories>  
  72. <repository>  
  73. <id>snapshot</id>  
  74. <name>Internal Repository</name>  
  75. <url>http://192.168.0.2:8080/repo-snapshot</url>  
  76. <snapshots>  
  77. <enabled>true</enabled>  
  78. <updatePolicy>interval:60</updatePolicy>  
  79. <checksumPolicy>warn</checksumPolicy>  
  80. </snapshots>  
  81. </repository>  
  82. </repositories>  
  83. <pluginRepositories>  
  84. <pluginRepository>  
  85. <id>snapshot</id>  
  86. <name>Internal Plugin Repository</name>  
  87. <url>http://192.168.0.2:8080/repo-snapshot</url>  
  88. <snapshots>  
  89. <enabled>true</enabled>  
  90. <updatePolicy>interval:60</updatePolicy>  
  91. <checksumPolicy>warn</checksumPolicy>  
  92. </snapshots>  
  93. </pluginRepository>  
  94. </pluginRepositories>  
  95. </profile>  
  96. </profiles>  
  97. <!-- 激活相應(yīng)得配置-->  
  98. <activeProfiles>  
  99. <activeProfile>central-repo</activeProfile>  
  100. <activeProfile>internal-repo</activeProfile>  
  101. <activeProfile>snapshot-repo</activeProfile>  
  102. </activeProfiles>  
  103. <!-- 插件默認groupId -->  
  104. <pluginGroups>  
  105. <pluginGroup>com.mycompany.plugins</pluginGroup>  
  106. </pluginGroups>  

包括了以下的共享因素:
服務(wù)器設(shè)置典型是共同的,只有用戶名需要在用戶環(huán)境中設(shè)置。使用一致的定義來配置共同的設(shè)置
profile定義了共同的因素,內(nèi)部開發(fā)庫,包括指定的組織或者部門發(fā)布的產(chǎn)品。這些庫獨立于核心開發(fā)庫。
激活的profiles列表,用于激活相應(yīng)的profile
plugin 組只有當你的組織中有自己定義的插件,用于命令行運行在pom中定義。

對于單獨的用戶來說,設(shè)置如下:
xml 代碼
  1. <settings>  
  2. <profiles>  
  3. <profile>  
  4. <id>property-overrides</id>  
  5. <properties>  
  6. <website.username>myuser</website.username>  
  7. <website.pwd>test</website.username>  
  8. </properties>  
  9. </profile>  
  10. </profiles>  
  11. </settings>  

創(chuàng)建共享開發(fā)庫
    大多數(shù)組織將會創(chuàng)建自己的內(nèi)部開發(fā)庫,用于配置,而中心開發(fā)庫用于連接maven
    設(shè)置內(nèi)部開發(fā)庫是簡單的,使用http協(xié)議,可以使用存在的http 服務(wù)器?;蛘邉?chuàng)建新的服務(wù),使用apache,或者jetty
    假設(shè)服務(wù)器地址192.168.0.2 ,端口8080
    http://192.168.0.2:8080/repo-local
    設(shè)置另外一個開發(fā)庫,用于設(shè)置項目的snapshot庫http://192.168.0.2:8080/repo-snapshot
    中心鏡像庫,使用maven-proxy創(chuàng)建,當然也可以創(chuàng)建自己的鏡像。用于下載本地庫中沒有的artifact
maven-proxy 設(shè)置
    從網(wǎng)上直接下載maven-proxy-standalone-0.2-app.jar和 proxy.properties
    在命令行中,直接運行java -jar maven-proxy-standalone-0.2-app.jar  proxy.properties
主要的配置:
設(shè)置repo.list 中增加相應(yīng)的庫就可以,如下定義:
repo.list=repo1.,...
#maven 的中心庫
repo.repo1..url=http://repo1./maven2
repo.repo1..description=
repo.repo1..proxy=one
repo.repo1..hardfail=false
repo.repo1..cache.period=360000
repo.repo1..cache.failures=true
以后所有的遠程庫,都通過此方式增加。順便說一下,不要忘了注釋原來的example,那是沒有辦法訪問的。

其他配置如
端口號 port=9999
保存的位置 repo.local.store=target/repo
serverName=http://localhost:9999

創(chuàng)建標準的組織pom
定義共同的內(nèi)容,包括公司的結(jié)構(gòu),如組織,部門以及團隊。
察看一下maven 的自身,可以作為很好的參考。
如scm
 
xml 代碼
  1. <project>  
  2. <modelVersion>4.0.0</modelVersion>  
  3. <parent>  
  4. <groupId>org.apache.maven</groupId>  
  5. <artifactId>maven-parent</artifactId>  
  6. <version>1</version>  
  7. </parent>  
  8. <groupId>org.apache.maven.scm</groupId>  
  9. <artifactId>maven-scm</artifactId>  
  10. <url>http://maven./maven-scm/</url>  
  11. ...  
  12. <modules>  
  13. <module>maven-scm-api</module>  
  14. <module>maven-scm-providers</module>  
  15. ...  
  16. </modules>  
  17. </project>      
 

在maven父項目中可以看到如下定義:
 
xml 代碼
  1. <project>  
  2. <modelVersion>4.0.0</modelVersion>  
  3. <parent>  
  4. <groupId>org.apache</groupId>  
  5. <artifactId>apache</artifactId>  
  6. <version>1</version>  
  7. </parent>  
  8. <groupId>org.apache.maven</groupId>  
  9. <artifactId>maven-parent</artifactId>  
  10. <version>5</version>  
  11. <url>http://maven./</url>  
  12. ...  
  13. <mailingLists>  
  14. <mailingList>  
  15. <name>Maven Announcements List</name>  
  16. <post>announce@maven.</post>  
  17. ...  
  18. </mailingList>  
  19. </mailingLists>  
  20. <developers>  
  21. <developer>  
  22. ...  
  23. </developer>  
  24. </developers>  
  25. </project>       

maven 父pom包括了共享的元素,如聲明郵件列表,開發(fā)者。并且大多數(shù)項目繼承apache組織:
 
xml 代碼
  1. <project>  
  2. <modelVersion>4.0.0</modelVersion>  
  3. <groupId>org.apache</groupId>  
  4. <artifactId>apache</artifactId>  
  5. <version>1</version>  
  6. <organization>  
  7. <name>Apache Software Foundation</name>  
  8. <url>http://www./</url>  
  9. </organization>  
  10. <url>http://www./</url>  
  11. ...  
  12. <repositories>  
  13. <repository>  
  14. <id>apache.snapshots</id>  
  15. <name>Apache Snapshot Repository</name>  
  16. <url>http://svn./maven-snapshot-repository</url>  
  17. <releases>  
  18. <enabled>false</enabled>  
  19. </releases>  
  20. </repository>  
  21. </repositories>  
  22. ...  
  23. <distributionManagement>  
  24. <repository>  
  25. ...  
  26. </repository>  
  27. <snapshotRepository>  
  28. ...  
  29. </snapshotRepository>  
  30. </distributionManagement>  
  31. </project>       

對于項目自身來說,父pom很少更新。所以,最后的方式保存父pom文件在單獨的版本控制區(qū)域,它們能夠check out,更改和配置
使用Continuum持久整合
    持續(xù)整合自動build你的項目,通過一定的時間,包括所有的沖突在早期察覺,而不是發(fā)布的時候。另外持續(xù)整合也是一種很好的開發(fā)方式,使團隊成員能產(chǎn)生細微的,交互的變動,能更有效的支持平行開發(fā)進程。
    可以使用maven的continuum作為持久整合的服務(wù)。
    安裝continuum,比較簡,使用以下的命令:
    C:\mvnbook\continuum-1.0.3> bin\win32\run
    可以通過http://localhost:8082/continuum來驗證
    為了支持continuum 發(fā)送e-mail提醒,你需要相應(yīng)的smtp服務(wù)用于發(fā)送信息。默認使用localhost:25,如果你沒有設(shè)置,編輯上面的文件改變smtp-host設(shè)置。
    下一步,設(shè)置svn目錄:
    svn co file://localhost/C:/mvnbook/svn/proficio/trunk proficio
    編輯pom.xml用于正確相應(yīng)得e-mail地址。
 
xml 代碼
  1. ...  
  2. <ciManagement>  
  3. <system>continuum</system>  
  4. <url>http://localhost:8080/continuum  
  5. <notifiers>  
  6. <notifier>  
  7. <type>mail</type>  
  8. <configuration>  
  9. <address>youremail@yourdomain.com</address>  
  10. </configuration>  
  11. </notifier>  
  12. </notifiers>  
  13. </ciManagement>  
  14. ...  
  15. <scm>  
  16. <connection>  
  17. scm:svn:file://localhost/c:/mvnbook/svn/proficio/trunk  
  18. </connection>  
  19. <developerConnection>  
  20. scm:svn:file://localhost/c:/mvnbook/svn/proficio/trunk  
  21. </developerConnection>  
  22. </scm>  
  23. ...  
  24. <distributionManagement>  
  25. <site>  
  26. <id>website</id>  
  27. <url>  
  28. file://localhost/c:/mvnbook/repository/sites/proficio  
  29. /reference/${project.version}  
  30. </url>  
  31. </site>  
  32. </distributionManagement>      
 

提交相應(yīng)的pom,然后執(zhí)行mvn install
如果你返回http://localhost:8082/continuum,你會看到相應(yīng)的項目列表。
一旦你登錄后,你可以選擇mavan 2.0項目用于增加相應(yīng)的項目。你可以增加你的url或者提交你的本地內(nèi)容。
你可以使用本地pom url,如下file://localhost/c:mvnbook/proficio/pom.xml
在提交了此url后,continuum將會返回相應(yīng)的成功信息。
以下的原則用于更好的幫助持續(xù)整合:
早提交,經(jīng)常提交:當用戶經(jīng)常提交時,持續(xù)整合是最有效的。這并不意味著,提交不正確的代碼。
經(jīng)常運行build:用于最快檢測失敗
盡快修正失?。寒斒“l(fā)生時,應(yīng)該馬上修正失敗
建議一個有效的版本
運行clean build
運行復(fù)雜的綜合測試
build所有的項目結(jié)構(gòu)分支
持續(xù)運行項目的拷貝

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多