/mvn-fluid-cd

Maven extension to ease continuous delivery of microservices

Primary LanguageJavaApache License 2.0Apache-2.0

~ Surfing the continuous delivery pipe ~

Having fun continuously delivering microservices built by Maven

mvn-fluid-cd

Maven extension(s) to facilitate continuous delivery of microservices

Build Status

Problem statement (Anno 2014)

Problem statement

Continuously delivering microservices built by Maven is tough and painful.

Programming in the CI/CD tool is hard to scale.

  • Technology radar January 2015 Preview - Thoughtworks

    A common pre-requisite for doing continuous integration has been to have a single command that could be executed on a clone of your repository on a brand new machine to get a working environment which can build, test and package your application. This focuses the attention on automation, makes it easy for new users to get started, reduces chances of snowflake build environments and results in reliable build results that can be recreated on demand either in the CI environment or locally. However, we often see teams ignoring this and resorting to programming in their CI/CD tool, which not only results in build failures that are hard to debug, they also lose out on the upstream benefits of having the single point of entry to configuring and building their projects. In this version of the radar, we would like to strongly advise against this practice which sacrifices many of the benefits of CI in the interest of expediency.

As Is (Anno 2014)

Bringing back the joy

Bringing back the joy ~

  • Requirements gathering

    • Dave Dev says:
      • Let me use my snapshots and for the rest stay out of my way ...
    • Oliver Ops says:
      • Freeze! And no adding a revision number in a manifest file is not good enough ...
    • Jerry Jenkins
      • I'll do it for you but Keep It Simple Stupid ...
    • ...
  • Scope

  • Solution

    ![Solution](/mvn-ext-freeze/src/doc/Continuous delivery with Maven.png?raw=true)

    • Bundle of Maven extensions

      • General design rules for Maven extensions
        • Maximal cohesion, minimal coupling
        • Less is more
          • Minimize the transitive jar dependencies of the extension
          • Minimize the inter extension dependencies
        • Follow or extrapolate existing Maven conventions/principles
        • Piggyback existing Maven functionality
        • Not viral
          • Local preprocessing of poms
          • Pom's stored in a Maven repository are processed poms and do not enforce installation of the extension when depending on these
        • Graceful degradation when extension is not installed
        • Does not break the Maven support in the IDE
    • Algorithm

      • Activate freezing when a revision is provided (-Drevision=xyz)
      • Start parsing pom.xml file and stream it to frozen.pom.xml
      • Extract the properties (groupId, artifactId, version) of the pom's project artifact
      • Replace the snapshot ending of the pom's project artifact version with the given revision number (1.2-SNAPSHOT -> 1.2-xyz)
      • For each snapshot dependency version encountered while parsing the pom
        • Lookup the latest frozen version of the artifact in Maven's local repository
        • Replace the version of the dependency whith the latest frozen version
      • Let the Maven build use the frozen poms instead of the regular poms for all subsequent steps (especially install and deploy)
    • See it in action

      Sample

      • Clone the mvn-fluid-it github project
      • 'cd mvn-ext-s-modules'
      • Run 'mvn clean install' (First run will build the Maven extensions and will copy these to the $M2_HOME/lib/ext folder)
      • Run 'mvn clean install' again (The magic (= the freezing of the snapshots :-)) will now happen because the extensions were installed in the previous step.)
      • Have a look at the integration tests in 'mvn-ext-freeze/src/it'
      • (To uninstall the extensions just remove the four jars from the $M2_HOME/lib/ext)
    • Links