Maven的pom.xml文件详解------Environment Settings
轉載自??Maven的pom.xml文件詳解------Environment Settings
Issue Management
使用的缺陷跟蹤系統(Bugzilla,TestTrack,ClearQuest,等)信息,主要用于產生項目文檔。
<issueManagement><system>Bugzilla</system><url>http://127.0.0.1/bugzilla/</url> </issueManagement>Continuous Integration Management
持續構建系統配置。
<ciManagement><system>continuum</system><url>http://127.0.0.1:8080/continuum</url><notifiers><notifier><type>mail</type><sendOnError>true</sendOnError><sendOnFailure>true</sendOnFailure><sendOnSuccess>false</sendOnSuccess><sendOnWarning>false</sendOnWarning><configuration><address>continuum@127.0.0.1</address></configuration></notifier></notifiers> </ciManagement>notifiers:定義當出現構建狀態時需要通知的人,已經通知的方式。?
?
Mailing Lists
定義了該項目需要保持聯系的人員,主要是開發人員和用戶的郵件列表。
<mailingLists><mailingList><name>User List</name><subscribe>user-subscribe@127.0.0.1</subscribe><unsubscribe>user-unsubscribe@127.0.0.1</unsubscribe><post>user@127.0.0.1</post><archive>http://127.0.0.1/user/</archive><otherArchives><otherArchive>http://base.google.com/base/1/127.0.0.1</otherArchive></otherArchives></mailingList> </mailingLists>1)subscribe、unsubscribe:執行對應行為指定的郵件地址。如為了訂閱上面用戶的,一個用戶需要發送email到user-subscribe@127.0.0.1;?
2)archive:已歸檔的郵件列表郵件的url,如果有鏡像歸檔地址,則指定到otherArchives中;?
3)post:post到郵件列表的郵件地址。?
?
SCM
SCM:Software Configuration Management,也稱作Source Code/Control Management簡潔的成為version control。
這里是你存放版本管理信息到POM的地方
1)connection:要求對源代碼有讀的權限,可以更新;developerConnection:要求對源代碼有寫的權限,可以提交代碼;?
Maven有另一個項目Maven SCM,提供公共的API,供SCM的插件實現。目前所有的SCM的插件可以在http://maven.apache.org/scm/scms-overview.html上找到;?
2)tag:指定該項目所在的標簽。HEAD是默認;?
3)url:一個公共的可瀏覽的倉庫。?
?
Prerequisites
為了讓該POM正確的執行所需要的先決條件,這里是你定義先決條件的地方。如果不滿足這些先決條件,Maven將不會開始。目前只有maven的最小版本號一個先決條件。
<prerequisites><maven>2.0.6</maven> </prerequisites>?
Repositories
定義Maven的倉庫地址,在Super POM中已經定義了Maven的默認倉庫中心http://repo.maven.apache.org/maven2(見Super POM)。
<repositories><repository><releases><enabled>false</enabled><updatePolicy>always</updatePolicy><checksumPolicy>warn</checksumPolicy></releases><snapshots><enabled>true</enabled><updatePolicy>never</updatePolicy><checksumPolicy>fail</checksumPolicy></snapshots><id>codehausSnapshots</id><name>Codehaus Snapshots</name><url>http://snapshots.maven.codehaus.org/maven2</url><layout>default</layout></repository> </repositories> <pluginRepositories>... </pluginRepositories>1)releases、snapshots:針對組件的發布類型能干采取的策略(release或者snapshot);?
2)enabled:true/false,倉庫對于對應的類型是否激活;?
3)updatePolicy:指定Maven嘗試更新的頻率,Maven將比較本地POM的時間戳(存儲在倉庫的maven-metadata文件中)和遠端POM的時間戳,選擇為:always,daily(默認),interval:X(X為整數,單位分鐘)或者never;?
4)checksumPolicy:當Maven部署文件到倉庫時,它也部署了對應的校驗和文件。你可以選擇ignore、fail或者warn來響應當文件丟失或者不正確后的操作;?
5)layout:default/legacy,Maven 2和Maven 3都是用default layout。?
pluginRepositories的配置方式和repositories一致。?
?
Distribution Management
管理build生成的組件和資源文件和分發。
基本屬性
<distributionManagement>...<downloadUrl>http://mojo.codehaus.org/my-project</downloadUrl><status>deployed</status> </distributionManagement>downloadUrl:另一個POM配置用于獲取該POM的組件的倉庫的url;?
status:這個值不能手動配置,當該組件上傳到倉庫時,Maven將設置這個項目的狀態,它的有效值為:?
none:沒有特殊狀態,默認;?
converted:倉庫的管理人員從一個對Maven 2來說更早的版本轉換到這個POM;?
partner:這個組件有被同步到一個合作倉庫;?
deployed:最通用的狀態,這個組件從Maven2或者Maven2部署;?
verified:這個項目被查證了,應該被終止。
?
Repository
distributionManagement通過repository定義當組件部署時,項目可以從哪里(和怎么)獲取遠端倉庫。
<distributionManagement><repository><uniqueVersion>false</uniqueVersion><id>corp1</id><name>Corporate Repository</name><url>scp://repo/maven2</url><layout>default</layout></repository><snapshotRepository><uniqueVersion>true</uniqueVersion><id>propSnap</id><name>Propellors Snapshots</name><url>sftp://propellers.net/maven</url><layout>legacy</layout></snapshotRepository>... </distributionManagement>id:倉庫的唯一標識;?
name:人類可讀的名稱;?
uniqueVersion:true/false,表示部署到該倉庫的組件是否應該獲取一個唯一產生的版本號,并用這個版本號作為地址的一部分;?
url:指定用于傳送構建成的組件(包括POM文件和校驗和數據)到倉庫的網絡地址和傳輸協議,是Repository的核心;?
layout:default/legacy,同project下的repository 元素。?
?
Site Distribution
比起分發到倉庫,distributionManagement更多的運用是定義怎么部署項目的站點和文檔。
<distributionManagement>...<site><id>mojo.website</id><name>Mojo Website</name><url>scp://beaver.codehaus.org/home/projects/mojo/public_html/</url></site>... </distributionManagement>?
Relocation
<distributionManagement>...<relocation><groupId>org.apache</groupId><artifactId>my-project</artifactId><version>1.0</version><message>We have moved the Project under Apache</message></relocation>... </distributionManagement>項目在發展的過程中,可能被迫轉移到其它更適合的地方。relocation用于給項目的用戶指名該項目被重命名為什么(例如上面,項目被重命名到org.apache:my-project:1.0),除此之外,它還提供一個項目轉移的解釋。?
?
Profiles
POM 4.0的一個新特征是改變項目被構建的環境的settings的能力。
<profiles><profile><id>test</id><activation>...</activation><build>...</build><modules>...</modules><repositories>...</repositories><pluginRepositories>...</pluginRepositories><dependencies>...</dependencies><reporting>...</reporting><dependencyManagement>...</dependencyManagement><distributionManagement>...</distributionManagement></profile> </profiles>?
Activation
Activation是profile的關鍵。一個profile的威力來自于在當前的環境下修改基本POM的能力。
<profiles><profile><id>test</id><activation><activeByDefault>false</activeByDefault><jdk>1.5</jdk><os><name>Windows XP</name><family>Windows</family><arch>x86</arch><version>5.1.2600</version></os><property><name>sparrow-type</name><value>African</value></property><file><exists>${basedir}/file2.properties</exists><missing>${basedir}/file1.properties</missing></file></activation>...</profile> </profiles>jdk:如果jdk版本號匹配被給的前綴,則profile被激活,例如:1.5.0_06將匹配上面的配置; os:在哪些操作系統下profile被激活; property:profile將激活,如果Maven探測到一個對應的name=value對的property。 file:一個通過file的existence指定的文件名可以激活profile。
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的Maven的pom.xml文件详解------Environment Settings的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Maven的pom.xml文件详解---
- 下一篇: 香料面包制作方法大全 香料面包制作方法介