Adding SVN revision number in manifest

2,112 views
Skip to first unread message

neopium

unread,
Sep 26, 2012, 10:12:42 AM9/26/12
to maven-svn-revisi...@googlegroups.com
Hi,

I am trying to use maven-svn-revision-number-plugin to add the revision number in the manuifest of my projects.

What I have done is adding in the super pom.xml file the following lines in the <plugins> tag of my super pom:

<!-- Gets the SVN revision number -->
<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>
            </plugin>
<!-- Add the SVN revision number in the manifest (works on Hudson only) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.1</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Implementation-Build>${prefix.revision}</Implementation-Build>
</manifestEntries>
</archive>
</configuration>
</plugin>
 
However, what I obtain in the manifest is

Implementation-Build: ${prefix.revision}

What did I do wrong? 

Oleg Estekhin

unread,
Sep 26, 2012, 1:02:00 PM9/26/12
to maven-svn-revisi...@googlegroups.com
Hi
 
by default the “prefix” is equal to artifactId of the module where the plugin is used. For example, the artifactId is “yourCoolModule”, the plugin will create properties like ${yourCoolModule.revision}.
 
You could configure the actual prefix value with the following plugin configuration
===
<configuration>
                    <entries>
                        <entry>
                            <prefix>yourDesiredPrefixHere</prefix>
                        </entry>
                    </entries>
                </configuration>
===
which will create properties like ${yourDesiredPrefixHere.revision}.

neopium

unread,
Sep 27, 2012, 3:34:09 AM9/27/12
to maven-svn-revisi...@googlegroups.com
Thanks for your answer. I tried that in the Super POM:

<!-- Gets the SVN revision number -->
<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>
</entry>
</entries>
</configuration>

</plugin>
<!-- Add the SVN revision number in the manifest (works on Hudson only) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.1</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Implementation-Build>${svn.revision}</Implementation-Build>
</manifestEntries>
</archive>
</configuration>
</plugin>

Still getting uninterpreted tag in manifest:

 Implementation-Build: ${svn.revision}

Is it because I configure the Super POM and not its children?
What I expect is to modify the Super POM and see all modules inheriting getting their SVN revision nulber without having to modify them all manually (that's supposed to be the point of inheritance after all)

Kind regards,

Ben 

neopium

unread,
Sep 27, 2012, 5:45:41 AM9/27/12
to maven-svn-revisi...@googlegroups.com
I found the cause of my problem (not the solution however).

In parallel to maven-svn-revision-number-plugin, I also use maven-bundle-plugin. The packagin as defined in the POM is thus not <packaging>jar</packaging> but <packaging>bundle</packaging>.

I have no idea how to solve the problem...

Moreover, When I load the project in Eclipse with m2eclipse plugin, it complains about the
<execution>
<goals>
<goal>revision</goal>
</goals>
</execution>

It says:

Plugin execution not covered by lifecycle configuration: com.google.code.maven-svn-revision-number-plugin:svn-revision-number-maven-plugin:1.13:revision (execution: default, phase: initialize) pom.xml
 

neopium

unread,
Sep 27, 2012, 5:47:02 AM9/27/12
to maven-svn-revisi...@googlegroups.com
One precision: maven-bundle-plugin creates OSGi-compliant JARs. It's not optionnal :-)

Oleg Estekhin

unread,
Sep 28, 2012, 12:49:26 PM9/28/12
to maven-svn-revisi...@googlegroups.com
I am not sure how m-jar-p and m-bundle-p work with each other, it is possible that m-bundle-p does not use manifest configuration from the m-jar-p. Just to be sure that the s-r-n plugin works, you can configure it be more verbose (<configuration><verbose>true</></>) and check the build log, where you should see exactly what properties are set.
 
As for the problem with m2eclipse – this is known bug, you can find all sorts of information about it in here http://stackoverflow.com/questions/6352208/how-to-solve-plugin-execution-not-covered-by-lifecycle-configuration-for-sprin . The easiest way to fix this bug is simply to move to another IDE which “just works” with maven, like IntelliJ Idea =)

neopium

unread,
Oct 3, 2012, 8:06:15 AM10/3/12
to maven-svn-revisi...@googlegroups.com
Hi, and thanks for your answer.

Here is the output with verbose set to true:

[INFO] inspecting directory /home/ben/dev/IME/Keridwen/modules/org-keridwen-core-data-model
[INFO]   prefix = svn
[INFO]   depth = infinity
[INFO]   report unversioned = true
[INFO]   report ignored = false
[INFO]   report out-of-date = false
[INFO] calculating properties
[INFO]   wc format = V16
(plenty of "[INFO]               824    776     -1  /local/path/to/files ()")
[INFO] setting properties
[INFO]   svn.repository = http://my.repository
[INFO]   svn.path = trunk/modules/mymodule
[INFO]   svn.revision = 824
[INFO]   svn.mixedRevisions = false
[INFO]   svn.committedRevision = 820
[INFO]   svn.committedDate = 2012-09-13 09:49:31 +0100 (Thu, 13 Sep 2012)
[INFO]   svn.status = M?
[INFO]   svn.specialStatus = Mu

 
 Indeed I have no idea if m-bundle-p uses m-jar-p to build the jar...

Oleg Estekhin

unread,
Oct 3, 2012, 12:10:36 PM10/3/12
to maven-svn-revisi...@googlegroups.com
Check that s-r-n-plugin actually runs before jar- and bundle- plugins. If it is configured only in the aggregator pom, then it will run after all sub-modules finished building.
 
From: neopium
Sent: Wednesday, October 03, 2012 4:06 PM
Subject: Re: Adding SVN revision number in manifest

neopium

unread,
Oct 5, 2012, 7:58:25 AM10/5/12
to maven-svn-revisi...@googlegroups.com
Hi,

I found the problem: I cannot use both maven-jar-plugin and maven-bundle-plugin to edit the MANIFEST. What should be done is to use either one of them and then it works

Reply all
Reply to author
Forward
0 new messages