Coder Social home page Coder Social logo

gradle-setversions-plugin's Introduction

Gradle Plugin Build

Gradle Set Versions Plugin

Simple plugin to modify gradle versions directly in build files or properties. No metadata file, no specific flow constraints.

Usage

You can add this plugin to your top-level or modules build script.

In a groovy 'build.gradle' build file :

plugins {
  id "com.github.ldenisey.setversions" version "$version"
}

In a kotlin 'build.gradle.kts' build file :

plugins {
  id("com.github.ldenisey.setversions") version "$version"
}

Tasks

getVersions

This task displays the current version of your project, optionally updated by suffix addition/removal and/or incrementation.

The new version is not applied, to do so use the task setVersions. As both tasks use the same logic internally you can use getVersions task for dry run execution.

When modifying current version, it is expected to have :

  • an optional prefix matching [A-Za-z0-9/_-]* regex
  • a base version made of at least 2 numbers separated by points ((\d+.)+\d+ regex)
  • an optional suffix matching [A-Za-z0-9/_-]* regex

Quick examples :

Project version Command Result
1.2.3-SNAPSHOT ./gradlew getVersions 1.2.3-SNAPSHOT
1.2.3-SNAPSHOT ./gradlew getVersions --suffix=false 1.2.3
1.2.3-SNAPSHOT ./gradlew getVersions --new-version=2.0.0 2.0.0
1.2.3-SNAPSHOT ./gradlew getVersions --suffix=rc 1.2.3-rc
1.2.3-SNAPSHOT ./gradlew getVersions --increment=1 --suffix=false 2.0.0
1.2.3-SNAPSHOT ./gradlew getVersions --increment=technical 1.2.4-SNAPSHOT
1.2.3-SNAPSHOT ./gradlew getVersions --increment=minor --suffix=false 1.3.0
1.2.3-SNAPSHOT ./gradlew getVersions --prefix=id/12 id/12-1.2.3-SNAPSHOT
v1.2 ./gradlew getVersions --increment=major v2.0
v1.2 ./gradlew getVersions --increment=2 --suffix=dev v1.3-dev
feature/42-1.2.3.4-alpha ./gradlew getVersions --increment=4 feature/42-1.2.3.5-alpha
feature/42-1.2.3.4-alpha ./gradlew getVersions --increment=-1 feature/42-1.2.3.5-alpha
feature/42-1.2.3.4-alpha ./gradlew getVersions --prefix=false 42-1.2.3.4-alpha

Plugin configuration

defaultSuffix

Default suffix value used by --suffix=true option. 'SNAPSHOT' by default, you can set it in your 'build.gradle', for example :

versions {
  defaultSuffix = 'dev'
}
skipSet

Boolean to disable version update on a specific module.

versions {
  skipSet = true
}

Task options

new-version

String option to define a new version from scratch, regardless of existing version value.

For example ./gradlew getVersions --new-version=1.2.3-SNAPSHOT returns 1.2.3-SNAPSHOT.

suffix

String option to add or replace a suffix. Can be set to any alphanumerical string, except true and false. The suffix is separated from base version with -.

--suffix=true will append the project's default suffix. --suffix=false will trim it.

increment

Use this option to increment base version digits. Specify the position of the version digit to increment, all digits on the right of the incremented digit will be set to 0.

Position can be set with :

  • a positive integer, 1 being first on the left
  • a negative integer, -1 being last digit on the right.
  • an alias :
    • major for first digit
    • minor for second digit
    • technical for third digit

For examples, if current version is 1.2.3-SNAPSHOT, executing ./gradlew getVersions --increment=1 will return 2.0.0-SNAPSHOT. It is equivalent to ./gradlew getVersions --increment=-3 and ./gradlew getVersions --increment=major

setVersions

This task updates the project/modules versions.

Its options to generate a new version are shared with getVersions task task, refer to it for options.

There are several ways to define versions in gradle. As of now, this task can update versions defined in project/modules build files, gradle.properties and in build scripts defined in buildSrc (see gradle sample).

gradle-setversions-plugin's People

Contributors

ldenisey avatar c3p0-maif 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.