亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

Maven插件之buildnumber-maven-plugin

系統(tǒng) 3908 0

某些情況下(這種情況一般很少見),使用maven構(gòu)建項目時,需要一個不重復(fù)的序列號,比如說,打包時,包名稱以當(dāng)前構(gòu)建時間結(jié)尾,或者每次生成的jar包中包含唯一的序列號,等等;

這個時候,就用到了buildnumber插件,官方網(wǎng)址:

http://mojo.codehaus.org/buildnumber-maven-plugin/index.html

該插件能按照指定的方案生成序列號;首先引入該插件

?

    <!-- 根據(jù)系統(tǒng)時間生成唯一序列號 -->

<plugin>

	<groupId>org.codehaus.mojo</groupId>

	<artifactId>buildnumber-maven-plugin</artifactId>

	<version>1.2</version>

</plugin>
  

常用以下兩個目標(biāo):

?

buildnumber:create (基于SCM版本生成)

buildnumber:create-timestamp (基于系統(tǒng)時間生成)
兩個目標(biāo)都默認(rèn)綁定在 initialize 生命周期;其中create-timestamp目標(biāo)是 1.0-beta-5 版本新增;

以下分別介紹:

buildnumber:create

其參數(shù)介紹如下:

?

Name Type Since Description
buildNumberPropertiesFileLocation File 1.0-beta-2 當(dāng)使用"format"參數(shù),并且"item"參數(shù)包含"buildNumber"值時,會創(chuàng)建屬性文件;此屬性定義文件生成位置;
默認(rèn)值: ? ${basedir}/buildNumber.properties
buildNumberPropertyName String 1.0-beta-1 自定義" buildNumber "屬性名;默認(rèn)值: buildNumber
doCheck boolean 1.0-beta-1 若設(shè)置為true,會檢查文件是否修改,若有修改,則構(gòu)建失敗;
?Note that this used to be inverted (skipCheck), but needed to be
changed to allow releases to work. This corresponds to 'svn status'.
默認(rèn)值 :? false .
doUpdate boolean 1.0-beta-1 若設(shè)置為true,版本號會更新為最新;否則會保持為本地值;
Note that this used to be inverted (skipUpdate),
but needed to be changed to allow releases to work.
This corresponds to 'svn update'.
默認(rèn)值 :? false .
format String 1.0-beta-1 使用java.text.MessageFormat類格式化信息;和"items"參數(shù)一起使用;設(shè)置該參數(shù)會讀取"items"參數(shù)
getRevisionOnlyOnce boolean 1.0-beta-3 若設(shè)置為true,在多模塊的項目中,只會從SCM獲取一次版本號; Default value is :? false .
items List 1.0-beta-1 和"format"參數(shù)一起使用;填充"format"參數(shù)的占位符;
有效值為:"scmVersion",?"timestamp", "buildNumber[digits]";
其中[digits]可選,用于選取指定的序列號;
locale String 1.0-beta-2 該屬性使用本地Locale信息格式化date和time.該屬性值由 Locale.toString() 方法得到;
默認(rèn)值 :由 Locale.getDefault() .toString() 方法得到;
password String 1.0-beta-1 連接SCM系統(tǒng)時的密碼;
providerImplementations Map 1.0-beta-3 SCM具體實(shí)現(xiàn)的替代方案;其值表示了SCM URL地址,比如"cvs","svn";
revisionOnScmFailure String 1.0-beta-2 當(dāng)執(zhí)行SCM某些操作失敗時,可使用此參數(shù)值作為替代方案;
scmBranchPropertyName String 1.0-beta-4 自定義" buildScmBranch "屬性名稱; Default value is :? scmBranch .
scmDirectory File 1.0-beta- Local directory to be used to issue SCM actions; Default value is :? ${basedir} .
shortRevisionLength int 1.1 版本號長度(僅用于git)
timestampFormat String 1.0-beta-2 Apply this java.text.MessageFormat to the timestamp only (as opposed to the? format ?parameter).
timestampPropertyName String 1.0-beta-1 自定義" timestamp "屬性名; Default value is :? timestamp .
useLastCommittedRevision boolean 1.0-beta-2 whether to retrieve the revision for the last commit, or the last revision of the repository.
Default value is :? false .
username String 1.0-beta-1 連接SCM的用戶名

?

?

buildnumber:create-timestamp

其有兩個可選參數(shù)

?

Name Type Since Description
timestampFormat String 1.0-beta-5 使用ava.text.SimpleDateFormat類格式化序列號;默認(rèn)格式不友好,推薦自定義該參數(shù);
timestampPropertyName String 1.0-beta-5 自定義屬性名;默認(rèn)屬性名稱是:? timestamp .

個人認(rèn)為,使用 create-timestamp 目標(biāo)就足夠了。

?

有關(guān)"format"和"items"參數(shù)的使用,例子如下:

?

    <plugin>

	<groupId>org.codehaus.mojo</groupId>

	<artifactId>buildnumber-maven-plugin</artifactId>

	<version>1.2</version>

	<configuration>

		<format>At {1,time} on {1,date}, there was {2} on planet {0,number,integer}.</format>

		<items>

			<item implementation="java.lang.Integer">7</item>

			<item>timestamp</item>

			<item>a disturbance in the Force</item>

		</items>

	</configuration>

	<executions>

		<execution>

			<phase>validate</phase>

			<goals>

				<goal>create</goal>

			</goals>

		</execution>

	</executions>

</plugin>
  

其他常用配置有

?

?

    <configuration>

	<format>{0,number}.{1,number}.{2,number}</format>

	<items>

		<item>buildNumber0</item>

		<item>buildNumber1</item>

		<item>buildNumber2</item>

	</items>

</configuration>
  

?


    <configuration>

	<format>{0,date,yyyy-MM-dd HH:mm:ss}</format>

	<items>

		<item>timestamp</item>

	</items>

</configuration>
  


產(chǎn)生的? ${buildNumber} 值分別如下:

      
        At
      
      
        12
      
      
        :
      
      
        30
      
      
         PM on 
      
      
        Jul
      
      
        3
      
      
        ,
      
      
        2053
      
      
        ,
      
      
         there was a disturbance 
      
      
        in
      
      
         the 
      
      
        Force
      
      
         on planet 
      
      
        7.
      
    
      
        2.0
      
      
        .
      
      
        3
      
    
      
        2005
      
      
        -
      
      
        10
      
      
        -
      
      
        06
      
      
        2
      
      
        :
      
      
        22
      
      
        :
      
      
        55
      
    

其他詳細(xì)信息,請參考官網(wǎng)

http://mojo.codehaus.org/buildnumber-maven-plugin/usage.html


PS:一個有用的實(shí)踐,自定義屬性,將生成的序列號賦值其中,便于其他插件等地方使用;

?

    <properties>

	<buildtimestamp>${timestamp}</buildtimestamp>

</properties>


  


?


?

Maven插件之buildnumber-maven-plugin


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 亚洲第一综合色 | 女bbbxxx毛片视频 | 天天插夜夜操 | 欧美黄视频在线观看 | 九九视频在线观看6 | 亚洲欧美国产日产综合不卡 | 亚洲精品成人中文网 | 日日碰狠狠添天天爽对白 | 国产福利在线 | 亚洲欧洲中文字幕 | 久久www免费人成精品香蕉 | 免费观看一级特黄欧美大片 | 男人的天堂黄 | 一级大黄视频 | 欧美成人二区 | 亚洲精品一区二区三区婷婷 | 国产激情一区二区三区四区 | 性欧美一级毛片在线播放 | 五月综合激情久久婷婷 | 色爱综合网欧美 | 国产精品99re | 亚洲精品国产一区二区 | 久草视频免费看 | 一级啪啪片 | 欧洲免费在线视频 | 一极毛片 | 国产一区二区三区免费看 | 亚洲成人高清在线观看 | 久久99久久精品国产99热 | 欧美性猛交xxxx免费看久久 | 99在线免费 | 波多野结衣久久高清免费 | 四虎影视成人永久在线观看 | 国产欧美精品一区二区色综合 | 国产亚洲精品欧美一区 | 九九精品免视频国产成人 | 天天夜夜骑 | 免费看a毛片 | 高清国产美女在线观看 | 国产日韩视频 | 伊人色综合久久天天伊 |