Giter Club home page Giter Club logo

promote-maven-plugin's Introduction

Maven Central License

Promote Maven plugin

This is a Maven plugin that allows for promoting the artifacts of the previous snapshot build to a release. This allows you to speed up the release process, by avoiding running the same compile-test-package phases again, when you already have a good build.

This plugin circumvents some of the precautions and conventions of Maven, and hopefully that is exactly what you aimed to when you found this plugin.

Usage

Add this to your pom.xml:

  <build>
    <plugins>
      <plugin>
        <groupId>se.jiderhamn</groupId>
        <artifactId>promote-maven-plugin</artifactId>
        <version>2.0.0</version>
        <!-- Automatically execute promote:make-promotable after each snapshot build -->
        <executions>
          <execution>
            <goals>
              <goal>make-promotable</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

Build your snapshot as usual, say

mvn clean package

Now, in case you want to promote the snapshot into a release you would run

mvn promote:prepare release:prepare

In case you prefer, you could instead add the following to the <configuration> of the maven-release-plugin

<preparationGoals>promote:artifacts deploy:deploy</preparationGoals>

and then to release run

mvn release:prepare

Note that release:perform should not be invoked. For that reason, you may also want to add release:clean.

Migration from 1.x to 2.0

2.0.0 is a minor change compared to 1.1.0, but since the change to <preparationGoals> could break existing configurations, the major version is bumped. If you have added <preparationGoals> to your pom.xml you need to update according to the Usage section above.

Jenkins

You will likely want to use this plugin together with Continuous Integration, so that the latest code is always built, and as soon as you are ready to release you'll just promote the last build.

For Jenkins, it is recommended to combine this Maven plugin with the Promoted Builds Jenkins plugin.

Configure a normal Maven Jenkins project, and set Build / Goals and options as usual, say clean install. (This assumes you've configured promote:make-promotable to be executed automatically as of above.)

Jenkins Build

Create a manually triggered promotion (Promote builds when... + Only when manually approved) and select a Name and an Icon. (Unfortunately, the Name cannot currently contain any variables, which would have allowed hoovering the icon/badge to see the released version. Please vote for JENKINS-31725!)

Use Add Parameter to add 2 String Parameter s, one named releaseVersion and another named developmentVersion (as per the release:prepare goal of the Maven Release Plugin).

Approval Parameters

Add action: Invoke top-level Maven targets and set Goals to release:clean promote:prepare release:prepare.

Promote Action

Now it will be possible to manually promote the latest -SNAPSHOT build, allowing you to set the version of the release and the SNAPSHOT version of the next development iteration, just like you would with a normal Maven release.

Promote Approve

Goals

These are the Maven goals defined by this plugin

  • promote:make-promotable Identifies the artifacts of the build, and writes them to promotable-artifacts.properties in the project directory. This should be invoked at the end of any snapshot build that are candidates for promotion.
  • promote:prepare Configures the preparationGoals to perform the release by invoking promote:artifacts + deploy:deploy
  • promote:artifacts Read the artifact list written by promote:make-promotable during the snapshot build and register them as being the artifacts produced by the current build.
  • promote:no-op Does nothing (no operation); used as dummy goal to avoid default goals.

Caveat

You should be aware that in case you have a multi module Maven project with "nested" packaging, i.e. one of your modules produces a WAR (<packaging>war</packaging>) that contains JARs produced by other modules in the same project, then the name of those .jars inside the promoted .war will be the -SNAPSHOT that was promoted.

Example: You have a Maven multi module project that creates foo-[VERSION].jar which is included in bar-[VERSION].war. When promote the SNAPSHOT build 1.2.3-SNAPSHOT to a 1.2.3 release, then bar-1.2.3.war will contain foo-1.2.3-SNAPSHOT.jar.

If this is a problem, then this plugin is not for you.

Even though it would have been theoretically possible for the plugin to rename the JAR inside the WAR that would defeat the purpose of the plugin. Unless we promote the exact same (binary) artifacts, it is per definition not a promotion but some kind of new build, and then you may as well use the ordinary Maven Release Plugin.

promote-maven-plugin's People

Contributors

achaphiv avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.