/simple-semantic-version

This is a plugin that facilitates semantic versioning (for gradle)

Primary LanguageJavaMIT LicenseMIT

simple-semantic-version

GitHub Build Verification Gradle Package

This is a gradle plugin that helps you easily do semantic versioning of java projects using gradle.

Reason for production

In the team I work with, we do not use Docker and instead deploy the .jar files directly. Because of this, we encountered situations where it became confusing to know which version a specific .jar file was during deployment, especially when the file itself didn't contain version information.

To address this, I decided to create a versioning library for .jar files that would be beneficial for all team members.


Usage

Setting build.gradle

from Local File

buildscript {
    dependencies {
        classpath files('libs/gradle-semantic-versioning-manager-plugin-0.1.0.jar')
    }
}

plugins {
  // ~~~
}

apply plugin: 'io.github.mainmethod0126.simple-semantic-version'

from Gradle Plugin Portal

https://plugins.gradle.org/plugin/io.github.mainmethod0126.simple-semantic-version

Using legacy plugin application:

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "io.github.mainmethod0126:app:0.1.0"
  }
}

apply plugin: "io.github.mainmethod0126.simple-semantic-version"

Using the plugins DSL:

Currently, the "Using the plugins DSL" method is not available. We will try to solve the problem as soon as possible.

Example

Version Increment

Major

gradlew build -Pmajor=++

Minor

gradlew build -Pminor=++

Patch

gradlew build -Ppatch=++

Prerelease(pr)

PrereleaseVersion Since version is in text format, incremental method is not supported.

BuildMetadata(bm)

BuildMetadataVersion Since version is in text format, incremental method is not supported.

Version Change

Major

gradlew build -Pmajor=1

Minor

gradlew build -Pminor=2

Patch

gradlew build -Ppatch=3

Prerelease(pr)

gradlew build -Ppr=beta

BuildMetadata(bm)

gradlew build -Pbm=test

Java Version

gradlew build -Pjavav=17

Compositive

gradlew build -Pmajor=1 -Pminor=2 -Ppatch=3 -Ppr=beta -Pbm=test -Pjavav=17

Properties

ssv {
  buildDate = "2023-10-21";
  isDateInBuildArtifactDirPath = true;
  applicationVersion = "0.0.0";
}
Property name Description Default
ssv.buildDate This is the build date. today
ssv.isDateInBuildArtifactDirPath Indicates whether buildDate should be included in BuildArtifactDirPath. If true, a directory is created with the name buildDate. If false, no directory is created. false
ssv.applicationVersion This is the application version. The content of the version.json file if the version.json file exists. If the version.json file does not exist, the default value is "0.0.0".

Build Artifacts Sample

gradlew build -Pmajor=1 -Pminor=2 -Ppatch=3 -Ppr=beta -Pbm=test -Pjavav=17
<application root>/dist/<YYYY-MM-DD>/<java version>/<version>/app-<major.minor.patch>-<prereleaseVersion>-<buildMetadata>.jar

gradle-build-sample gradle-build-sample2

Directory : dist

A folder called "dist" is automatically created in the application root path, and Build Artifacts are located under the "dist" folder. (If it already exists, the creation process is skipped)

Directory : YYYY-MM-DD

The year, month, and day information of the build is created as a directory. (ex: 2023-02-07)

Directory : java version

During gradle build, the java version entered through -Pjavav is created as a directory. (When the javav option is omitted, the build java version is used by default)

Directory : version

The directory is created with the final version information generated during Gradle build. (ex : app-1.2.3-beta-test)