From e0d4a8a73d6ffc10f079bc997c9bb559386e0f51 Mon Sep 17 00:00:00 2001 From: Ned Loynd Date: Thu, 8 Jun 2023 17:44:27 +1000 Subject: [PATCH 1/5] Misc. Gradle build script cleanup --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 1413417..826b950 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id "java" - id("com.github.johnrengelman.shadow") version "8.1.1" + id("com.github.johnrengelman.shadow") version "8.1.1" } group 'me.cortex' version '1.0-SNAPSHOT' @@ -20,13 +20,13 @@ test { useJUnitPlatform() } - tasks.shadowJar { archiveClassifier.set("") manifest { attributes "Main-Class": "me.cortex.jarscanner.Main" } } + tasks.build { dependsOn(shadowJar) if (project.hasProperty("overrideVersion")) { @@ -39,4 +39,4 @@ jar { manifest { attributes 'Main-Class': 'me.cortex.jarscanner.Main' } -} \ No newline at end of file +} From 565079295e443bfe80774248e76edc703beddbc8 Mon Sep 17 00:00:00 2001 From: Ned Loynd Date: Thu, 8 Jun 2023 17:48:45 +1000 Subject: [PATCH 2/5] Configure Gradle to create reproducible archives --- build.gradle | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build.gradle b/build.gradle index 826b950..8aa075c 100644 --- a/build.gradle +++ b/build.gradle @@ -11,6 +11,13 @@ repositories { mavenCentral() } +// Reproducible builds +// https://docs.gradle.org/current/userguide/working_with_files.html#sec:reproducible_archives +tasks.withType(AbstractArchiveTask).configureEach { + preserveFileTimestamps = false + reproducibleFileOrder = true +} + dependencies { implementation 'org.ow2.asm:asm:9.5' implementation 'org.ow2.asm:asm-tree:9.5' From 55332126c9648a3b2e677749eeea6e4c344ac61b Mon Sep 17 00:00:00 2001 From: Ned Loynd Date: Thu, 8 Jun 2023 18:06:37 +1000 Subject: [PATCH 3/5] Use Java toolchains --- build.gradle | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build.gradle b/build.gradle index 8aa075c..17190ad 100644 --- a/build.gradle +++ b/build.gradle @@ -4,9 +4,16 @@ plugins { } group 'me.cortex' version '1.0-SNAPSHOT' + sourceCompatibility = 1.8 targetCompatibility = 1.8 +java { + toolchain { + languageVersion = JavaLanguageVersion.of(8) + } +} + repositories { mavenCentral() } From b48ce655764277aa397206147b14338e347f4c3d Mon Sep 17 00:00:00 2001 From: Ned Loynd Date: Thu, 8 Jun 2023 18:15:10 +1000 Subject: [PATCH 4/5] Don't use hardcoded file name for release artifact --- .github/workflows/release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 780a2f0..4556d46 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,5 +45,4 @@ jobs: name: Neko Detector ${{ env.VERSION }} draft: true prerelease: false - files: | - jarscanner-${{ env.VERSION }}.jar + files: build/libs/* From 80b628e010a80eaac42d40eac93fd7d059541479 Mon Sep 17 00:00:00 2001 From: Ned Loynd Date: Thu, 8 Jun 2023 18:21:49 +1000 Subject: [PATCH 5/5] Disable the Gradle cache for release builds Helps with increasing build reproducibility --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4556d46..b34d7c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -31,7 +31,7 @@ jobs: uses: gradle/gradle-build-action@v2 with: gradle-version: wrapper - cache-read-only: ${{ github.ref != 'refs/heads/master' }} + cache-disabled: true # specify the build version, overrides whatever is in the build.gradle file arguments: build -PoverrideVersion=${{ env.VERSION }}