SVN Latest Revision Maven Plugin
The SVN Latest Revision Plugin is used to retrieve the project latest SVN revision information from the project .svn
folder and store it in Maven properties.
Similar products
Usage
The SVN Latest Revision Plugin has only one goal svn-latest-revision:run
executed in Maven INITIALIZE stage.
The plugin implementation is extremely simple, plugin code is less 100 lines.
The goal opens SVN SQLite database file in .svn project directory and queries it for the latest revision.
NOTE: the SVN latest revision reflects the latest checked-in however the project build may have not committed changes.
After this plugin goal execution the latest revision and its timestamp are stored in the Maven properties:
svn.latest.revision
svn.latest.timestamp - not defined if not available (e.g. deletion outside of the project)
The SVN Latest Revision Plugin declaration in a POM-file:
<plugin>
<groupId>com.jdotsoft</groupId>
<artifactId>svn-latest-revision-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<timestampFormat>dd-MMM-yyyy HH:mm</timestampFormat>
</configuration>
</plugin>
|
The configuration timestampFormat is optional, the default value is dd-MMM-yyyy HH:mm
Example plugin console output:
[INFO] --- svn-latest-revision-maven-plugin:1.2:run (default) @ MyProject ---
[INFO] Opening SQLite SVN database file C:\projects\MyProject\.svn\wc.db
[INFO] Connected to DB. Latest revision:
[INFO] 1929 18-Dec-2021 20:09 | MyProject/src/main/java/com/jdotsoft/demo/Abc.java
[INFO] 1929 18-Dec-2021 20:09 | MyProject/src/main/java/com/jdotsoft/demo/Xyz.java
|
Maven properties defined by this plugin execution could be used, for example, in a MANIFEST.MF file:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
. . .
<configuration>
<archive>
<manifestEntries>
<Build-Time>${local.build.timestamp}</Build-Time>
<SVN-latest-revision>${svn.latest.revision} ${svn.latest.timestamp}</SVN-latest-revision>
</manifestEntries>
</archive>
</configuration>
</plugin>
|
Other features
Maven has a build-in property maven.build.timestamp which could be formatted with specified in a POM-file pattern:
<properties>
<maven.build.timestamp.format>dd-MMM-yyyy HH:mm</maven.build.timestamp.format>
</properties>
|
Maven uses UTC timezone for build timestamp property maven.build.timestamp
while SVN latest revision timestamp is in a local timezone.
The time zone discrepancy could lead to a confusion if both timestamps are displayed to a user.
The SVN Latest Revision Plugin creates Maven property local.build.timestamp similar to
maven.build.timestamp reusing the Maven timestamp format maven.build.timestamp.format .
The property local.build.timestamp could be used as a maven.build.timestamp replacement
to make both timestamps in local time zone (see example above).
Troubleshooting
The plugin is not execited.
This was observed if plugin was declared inside build/pluginManagement/plugins tags.
Solution: move plugin declaration inside build/plugins tags.
Declaring this plugin in Eclipse projects might result in Eclipse specific error:
Plugin execution not covered by lifecycle configuration:
com.jdotsoft:svn-latest-revision-maven-plugin:1.2:run
(execution: default, phase: initialize)
Eclipse provides an option to resolve this issue, follow steps:
1. Select the line with this error in a console
2. Right click it and select Quick Fix
3. Select Mark goal descriptor as ignored in pom.xml in the popup
Eclipse generates the section in a POM-file to fix this issue.
Download
The project SvnLatestRevisionMavenPlugin
is available to download from GitHub.
License
Java classes in this Maven plugin are licensed under Apache license.
|