Toilal Toilal - 1 year ago 137
Java Question

Update versions contained in README on maven release

I'm maintaining an opensource project on github that contains
file with install instructions containing the current version of the project

When releasing a new version to maven central, is it possible to automatically update this version number contained in

Releases are performed with
, versions in pom.xml are well updated, but I can't find anything in the docs to update this external file properly.

file currently at
. It lies outside of maven sources/resources, but it's managed on git. on
mvn release:prepare
, it should be updated to
, and maven should then commit/push the change before tagging the new release. Then, on
mvn release:perform
it should go to the next development version

(Link to the project)

Answer Source

You can use the maven-resources-plugin for this like mentioned in the comments.

I didn't try it but the configuration should look something like this:


And in your where you want the version you put the placeholder ${project.version}.

The two features which where combined here are copy-resources and filtering.

We tell the plugin to copy resources from the directory ${project.basedir}, which maven resolves to the root directory, again to the root directory but only include files matching

The filtering option replaces all placeholders with variables which can be defined as system properties, project properties, filter resources defined in the pom.xml or on command line. In this case we use the project property version.

Though the comments are right mentioning eventually inconsistency in case the release went wrong. You could overcome this by explicitly calling mvn resources:resources after your mvn release:perform was successful. I hope this helps.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download