代码之家  ›  专栏  ›  技术社区  ›  Enno Shioji

如何使用mercurial和maven(和svn)嵌入修订信息

  •  5
  • Enno Shioji  · 技术社区  · 14 年前

    当我们使用SVN时,我们的项目有一个很好的方法(尽管我猜有更好的方法来实现),将修订信息嵌入到工件(jar等)中。

    现在我们已经迁移到了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>
    
    2 回复  |  直到 14 年前
        1
  •  4
  •   Pascal Thivent    14 年前

    这个 Maven Build Number Plugin 从1.0-β-4开始就支持Mercurial(请参见 MOJO-1432 buildnumber:hgchangeset 目标设置两个具有变更集ID和变更集日期的项目属性,可用于筛选以获得等效结果。

        2
  •  2
  •   Ry4an Brase    14 年前

    听起来Pascal有官方的Maven方法,但是如果你最终模仿了你的SVN黑客,那么Mercurial中最好的对应命令是:

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

    或者,如果你在使用标签,并且想变得花哨:

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

    看见 hg help templates 所有选项。