Giter Club home page Giter Club logo

ci-friendly-flatten-maven-plugin's Introduction

ci-friendly-flatten-maven-plugin

This is the ci-friendly-flatten-maven-plugin.

Apache License V.2 Build Status Maven Central

Why another flatten plugin?

Having a large (> 350 modules) reactor with multiple daily releases, we encountered two issues:

  1. Commit history littered with maven release plugin commits.
  2. Race between committers pushing to the main branch, and the release plugin pushing its own pom changes.

When we found out about ci friendly versions, we were ecstatic - finally we can avoid having versions in poms and achieve zero commits release process!

The only problem was that the flatten plugin coupled with the resolveCiFriendliesOnly option does not work. As adherers of the unix philosophy, we decided to create a plugin that truly, really, only replaces the revision, sha and changelist properties.

Quickstart

This plugin flattens a pom by replacing ${revision}, ${sha1}, ${changelist} to values you set by passing them as args. It then writes the resulting pom to a file named .ci-friendly-pom.xml and sets it as the new reactor. For example, installing version 2.0.0:

mvn -Drevision=2.0.0 clean install

Plugin setup

   <build>
        <plugins>
          <plugin>
            <groupId>com.outbrain.swinfra</groupId>
            <artifactId>ci-friendly-flatten-maven-plugin</artifactId>
            <!--<version>INSERT LATEST VERSION HERE</version>-->
            <executions>
              <execution>
                <goals>
                  <!-- Ensure proper cleanup. Will run on clean phase-->
                  <goal>clean</goal>
                  <!-- Enable ci-friendly version resolution. Will run on process-resources phase-->
                  <goal>flatten</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
   </build>

Plugin Goals

  • ci-friendly-flatten:flatten Replaces revision, sha1, changelist, writes the resolved pom file to .ci-friendly-pom.xml and sets it as the new reactor (Default maven phase binding: process-resources).
  • ci-friendly-flatten:clean Removes any files created by ci-friendly-flatten:flatten (Default maven phase binding: clean).
  • ci-friendly-flatten:version Fetches the latest git tag, increments it and writes it to revision.txt, relies on scm configuration.
  • ci-friendly-flatten:scmTag Tags the commit with the updated version and pushes the tag, relies on scm configuration.

Installing artifacts

  1. To avoid having to type -Drevision=<version> when installing locally, define a default revision property.

      <properties>
         <revision>5.0.0-SNAPSHOT</revision>
      </properties>
    

mvn clean install

Will install all artifacts with 5.0.0-SNAPSHOT version.

  1. Provide the version with revision arg

mvn clean install -Drevision=<VERSION>

Will install all artifacts with your provided VERSION

Deploying artifacts

Same as above, just use mvn clean deploy -Drevision=<VERSION>

How we configured it ?

  1. We added ci-friendly-flatten-maven-plugin to our pom.xml.

  2. TeamCity Configuration:

    • Added a project system param system.version.

    • The project build steps:

      • Step #0 New project should tag their project before step 1 (git tag)

        git tag -a "1.0.0" -m "my version '1.0.0'"

        git push origin "1.0.0"

      • Step #1 - (Maven step) Fetch the latest git tag, increment it and write the result to revision.txt. This is the version we are going to release.

        mvn ci-friendly-flatten:version

      • Step #2 - (Command line step) Set a system.version TeamCity parameter with our soon to be released version, in order to use it in the next steps

        #!/bin/bash -x
        VER_PATH="%teamcity.build.checkoutDir%/revision.txt"
        REV=`cat $VER_PATH`
        set +x
        echo "##teamcity[setParameter name='system.version' value='$REV']"
        
      • Step #3 - (Maven step) deploy

        mvn clean deploy -Drevision=%system.version%

      • Step #4 - (Maven step) Tag the current commit with the updated version and push the tag

        mvn ci-friendly-flatten:scmTag -Drevision=%system.version%

ci-friendly-flatten-maven-plugin's People

Contributors

ahadadi avatar amirhadadi avatar ayoukhananov avatar obar-zik avatar piotrwielgolaski-tomtom 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.