How to add SVN revision number to MANIFEST file?

2019-08-31 12:27发布

问题:

I am trying to add svn revision number to MANIFEST file. I have this in my root pom.xml:

<plugin>
  <groupId>com.google.code.maven-svn-revision-number-plugin</groupId>
  <artifactId>svn-revision-number-maven-plugin</artifactId>
  <version>1.13</version>
  <executions>
    <execution>
      <goals>
        <goal>revision</goal>
      </goals>
    </execution>
  </executions>
  <configuration>
    <entries>
      <entry>
        <prefix>svn</prefix> <!-- create the ${svn.revision} -->
      </entry>
    </entries>
  </configuration>
     <dependencies>
    <dependency>
      <groupId>org.tmatesoft.svnkit</groupId>
      <artifactId>svnkit</artifactId>
      <version>1.7.4-v1</version>
    </dependency>
    <dependency>
      <groupId>org.tmatesoft.sqljet</groupId>
      <artifactId>sqljet</artifactId>
      <version>1.1.9</version>
    </dependency>
  </dependencies>
</plugin> 

And I'm trying to add svn revision in my ear pom.xml:

<archive>
    <manifestEntries>
    <Specification-Title>${project.name}</Specification-Title>
    <Specification-Version>${svn.revision}</Specification-Version>
    <Implementation-Version>${build.number}</Implementation-Version>
    </manifestEntries>
</archive>

I'm not getting any version in MANIFEST file. Any ideas of what I'm doing wrong?

Manifest-Version: 1.0
Implementation-Version: 273
Built-By: adelina.dimachi
Build-Jdk: 1.6.0_45
Specification-Title: MyProjectName
Created-By: Apache Maven 3.2.1
**Specification-Version:** 
Archiver-Version: Plexus Archiver

回答1:

I don't know the maven-svn-revision-number-plugin but I've successfully used the maven-jar-plugin for this in the past:

https://maven.apache.org/plugin-developers/cookbook/add-svn-revision-to-manifest.html