I make a checkout of some branch or tag from subversion repository and then build the project with maven.
Now, I'd like to get store current revision number and URL to some file. How can I do that? That is, I'd like to get revision number and URL of whatever branch/tag I have made checkout of.
I know about buildnumber-maven-plugin but I think it doesn't do this. It fetches revision number of branch that is specified in pom.xml.
You could use the maven-antrun-plugin to execute svnversion.
<project>
[…]
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<configuration>
<tasks>
<exec executable="sh">
<arg value="-c"/>
<arg value="svnversion >version.txt" />
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
[…]
</project>
NB: I've used sh -c
to run svnversion, so I can redirect the output to a file. I don't think that you can get the output into a property for use by the maven build.
You can use the same approach to run svn info --url
.
As said already the Maven Build Number Plugin can be used to find the revision.
As for the URL: Maven Practice is to put it in the POM using the <scm>-tag. If you configure this right once and then use the appriopriate Maven plugins (maven-scm-plugin, maven-release-plugin) for branching, tagging, releasing, etc. you can be sure the <scm>-tag always contains the right url.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With