2010-06-06 106 views
5

我們的項目有一個很好的黑客(雖然我猜有更好的方法來做到這一點),以將修訂信息嵌入到工件(jar等),當我們使用svn。如何嵌入版本信息使用mercurial和maven(和svn)

現在我們已經遷移到了mercurial,並且我們想要一個類似的東西,但是在我開始使用mercurial進行類似的攻擊之前,我想知道是否有更好的方法來做到這一點。

感謝您的回答!

<plugin> 
     <groupId>org.codehaus.mojo</groupId> 
     <artifactId>exec-maven-plugin</artifactId> 
     <executions> 
      <execution> 
        <phase>process-classes</phase> 
        <id>svninfo</id> 
        <goals> 
         <goal>exec</goal> 
        </goals> 
       <configuration> 
        <executable>svn</executable> 
        <arguments> 
        <argument>info</argument> 
        <argument>../</argument> 
        <argument>></argument> 
        <argument>target/some-project/META-INF/svninfo.txt</argument> 
        </arguments> 
       </configuration> 
      </execution> 
     </executions> 
    </plugin> 

回答

4

Maven Build Number Plugin具有自1.0-β-4水銀支持(見MOJO-1432)。目標buildnumber:hgchangeset設置了兩個項目屬性,其中包含可用於篩選以獲得等效結果的更改集標識和更改集日期。

2

聽起來像帕斯卡爾有官方的maven方式做到這一點,但如果這樣做最終會模仿你的svn黑客,在善變的最好的相應命令是:

hg log -r . --template '{node|short}\n' 

,或者如果你正在使用的標籤並想要看中:

hg log -r . --template '{latesttag}+{latestance}\n' 

請參閱hg help templates的所有選項。

+0

'hg parent'而不是'hg log -r .'怎麼樣? – Alex 2014-11-28 17:55:02

相關問題