From d51066926bcd799fdc30fad011822ef0cbde69d9 Mon Sep 17 00:00:00 2001 From: LMBishop <13875753+LMBishop@users.noreply.github.com> Date: Wed, 13 Apr 2022 19:14:36 +0100 Subject: [ci skip] Add git hash to development versions --- .github/workflows/build.yml | 2 +- build.gradle | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7b996401..b92bc8a9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -32,7 +32,7 @@ jobs: - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle - run: ./gradlew allJar + run: ./gradlew - name: Upload Plugin uses: actions/upload-artifact@master with: diff --git a/build.gradle b/build.gradle index af44415c..a6052dad 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { id 'maven-publish' } -defaultTasks 'allJar' +defaultTasks 'allJarSnapshot' allprojects { apply plugin: 'java' @@ -15,6 +15,15 @@ allprojects { sourceCompatibility = 1.8 targetCompatibility = 1.8 } + +task versionGit() { + ext.gitCommitHash = 'git rev-parse --verify --short HEAD'.execute().text.trim() + project.version = "${version}-${gitCommitHash}" + subprojects.each { + it.version = "${version}-${gitCommitHash}" + } +} + task allJar( type: Jar, dependsOn: subprojects.tasks['build'] ) { subprojects.each { subproject -> from subproject.configurations.archives.allArtifacts.files.collect { @@ -24,6 +33,10 @@ task allJar( type: Jar, dependsOn: subprojects.tasks['build'] ) { archiveBaseName = 'Quests' } +task allJarSnapshot( dependsOn: [ 'versionGit', 'allJar' ] ) { + allJar.mustRunAfter( 'versionGit' ) +} + artifacts { archives allJar } -- cgit v1.2.3-70-g09d2