Git Product home page Git Product logo

maven-git-autover's Introduction

Introduction

There are cases when it is advantageous that the version is calculated instead of specified in the pom. This is a Maven plugin that can automatically calculate a version based on Git tags. It should be registered as a Maven extension .mvn/extensions.xml file.

Git tag types

In git there are two types of tags: lightweight and annotated. Annotated tags are usually used to mark releases (they have a comment/description) and lightweight tags in other cases.

Configuration

How the plugin calculates the version is configurable. The version will be calculated only for artifacts that have the version 0.0.0-SNAPSHOT. A configuration has the following parameters:

  • versionTagRegex: This is used to determine what tags should be considered version tags
  • includeGroupIds: Only artifacts in this group ids will be processed. When no such group is specified artifacts from all groups ids will be processed
  • autoverBranchConfigs: The branch configurations
    • nameRegex: This is used to determine the branches that should use this configuration
    • stopOn: the stop on setting to be used by branches that match the above pattern possible values
      • ON_FIRST: It will use the first annotation that it will find (regardles of the type)
      • ON_FIRST_ANN: It will use the first annotated branch that it will find
      • ON_FIRST_LIGHT: It will use the first light branch that it will find The branch name is checked against the configured branches in the order from the configuration file and it stops on the first that matches.

How the version is calculated

The version is calculated based on the configuration. The plugin will look to the git history and "walk back" from current commit until it finds the first tag of the type configured for the branch and if the tag found is:

  • an annotated tag: it will calculate the next version as the next minor version and add SNAPSHOT (For ex: when it finds tag 2.0.1, it will calculate the version as 2.0.2-SNAPSHOT)
  • a lightweight tag: the version will be equal to the lightweight tag (For ex: when it finds tag 2.1.0-SNAPSHOT, it will calculate the version as 2.1.0-SNAPSHOT)

Default configuration

The plugin has the following default configuration.

  • versionTagRegex - [0-9]+\.[0-9]+\.([0-9]+)(-SNAPSHOT)?
  • includeGroupIds - empty (all groups will be considered)
  • autoverBranchConfigs
    • master - ON_FIRST_LIGHT
    • release/.* - ON_FIRST_ANN
    • feature/([A-Z0-9]+-[0-9]+)-.* - ON_FIRST_LIGHT
    • bugfix/([A-Z0-9]+-[0-9]+)-.* - ON_FIRST_ANN
    • (PR-\d+) - ON_FIRST (for jenkins)
    • .* - ON_FIRST

Use non default configuration

If the default configuration is not OK for a certain maven module, a different configuration can be specified. This custom configuration file should have the name git.autover.conf.xml and be placed in the .mvn folder of the module.

How to disable it

The plugin execution can be disabled using -Dautover.disable=true. This way the version specified in the pom file will be used. Also one could disable only the pom changes using -Dautover.disable.pom.change=true.

maven-git-autover's People

Contributors

edipal avatar

Watchers

 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.