From c34c1be21f50b4f720a7cd81e0dfe5ef6330caab Mon Sep 17 00:00:00 2001 From: Lucaskyy Date: Thu, 16 Jun 2022 12:47:49 +0200 Subject: [PATCH] feat: generate dex files using gradle task --- .github/workflows/release.yml | 11 +---------- build.gradle.kts | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6e43d98ca..42c0a35f2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,18 +35,9 @@ jobs: - name: Build with Gradle env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: ./gradlew build + run: ./gradlew build clean - name: Install Android build-tools run: sdkmanager "build-tools;32.0.0" - - name: Generate Patches DEX - run: | - mkdir -p bin - fn=$(find build/libs -maxdepth 1 | grep -P "[\d]+\.jar") - out=bin/$(basename "$fn" | sed 's/jar/dex/g') - $ANDROID_HOME/build-tools/32.0.0/d8 $fn - mv *.dex $out - - name: Clean build - run: ./gradlew clean - name: Setup semantic-release run: npm install -g semantic-release @semantic-release/git @semantic-release/changelog gradle-semantic-release-plugin -D - name: Release diff --git a/build.gradle.kts b/build.gradle.kts index b11b9647f..697290f61 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,12 +22,25 @@ dependencies { } tasks { + register("generateDex") { + description = "Generate dex files from build" + dependsOn(build) + + val androidHome = System.getenv("ANDROID_HOME") ?: throw GradleException("ANDROID_HOME not found") + val d8 = "${androidHome}/build-tools/32.0.0/d8" + val input = build.get().outputs.files.singleFile.absolutePath + val output = input.replace(".jar", ".dex") + + workingDir = File("${buildDir}/libs") + commandLine = listOf(d8, input) + commandLine = listOf("mv", "*.dex", output) + } // Dummy task to fix the Gradle semantic-release plugin. // Remove this if you forked it to support building only. // Tracking issue: https://github.com/KengoTODA/gradle-semantic-release-plugin/issues/435 register("publish") { group = "publish" description = "Dummy task" - dependsOn(build) + dependsOn(named("generateDex")) } } \ No newline at end of file