Control module version with Maven

Asked

Viewed 1,242 times

7

I have a multi-module Java project with Maven.

Currently, I control the version of each module manually, editing the element <version> pom.xml for each module that undergoes updates.

I believe this is not the correct/indicated method. There is something automated for this?

  • You use versions -SNAPSHOTs? Or your problem is when you close the version (release)?

  • Do not use -SNAPSHOT, doubt is only for when it closes even.

1 answer

6

If all your projects are controlled in the same pom create a property:

<project ...>
    <properties>
        <my.project.version>1.0</my.project.version>
    </properties>
</project>

And then use wherever you want like:

<version>${my.project.version}</version>

Another way to make this automated version lock is by using the Maven release plugin (http://maven.apache.org/maven-release/maven-release-plugin/).

In that case when shooting mvn release:prepare Maven will simulate a version lock for you. With this he changes the artifact version (everyone with SNAPSHOT, he will ask if you want to tag) and commit to SVN.

After the prepare be successfully completed you perform the command mvn release:perform commit the changes.

This plugin can integrate with SVN and also with Jira.

If any error has happened it is possible to use mvn:rollback to undo the changes.

More details look at the links Abaixos: http://www.tutorialspoint.com/maven/maven_deployment_automation.htm https://weblogs.java.net/blog/johnsmart/archive/2008/08/using_the_maven.html

  • If I inherit the version I will have a new version of each module in any and all changes. It does not seem very good to do that. I thought there was a way to automate module versioning.

  • I updated the response to include automation. [=

  • Thanks @uaiHebert. I will study this plugin... However, I have here Jenkins (I installed the time for testing) and I was thinking... It would no longer be logical for Jenkins to be responsible for carrying out the versioning process and preparing the files for deploy (.War)?

  • I don’t see much logic in Jenkins doing this, after all it looks at how it is defined: https://wiki.jenkins-ci.org/display/JENKINS/Meet+Jenkins Building/testing software Projects Continuously + Monitoring executions of externally-run Jobs . [=

  • Yeah, I think it was kind of my own trip... I thought of Jenkins doing the tests and generating a new build with the enhanced version...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.