diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cc86f6f..56c2acd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Check out repository - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 with: fetch-depth: 0 @@ -17,7 +17,7 @@ jobs: uses: gradle/actions/wrapper-validation@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0 - name: Set up JDK 21 - uses: actions/setup-java@dded0888837ed1f317902acf8a20df0ad188d165 # v5.0.0 + uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0 with: distribution: 'temurin' java-version: 21 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e528bad..e14ba79 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,10 +23,10 @@ jobs: echo "version=${version}" >> "${GITHUB_OUTPUT}" - name: Check out repository - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1 - name: Create release - uses: softprops/action-gh-release@6da8fa9354ddfdc4aeace5fc48d7f679b5214090 # v2.4.1 + uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0 with: tag_name: v${{ steps.get_version.outputs.version }} name: Version ${{ steps.get_version.outputs.version }} diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0818220..394be12 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,12 +1,15 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Andrew Gunnerson + * SPDX-FileCopyrightText: 2022-2026 Andrew Gunnerson * SPDX-License-Identifier: GPL-3.0-only */ +import com.android.build.api.artifact.SingleArtifact +import com.android.build.api.variant.VariantOutputConfiguration import org.eclipse.jgit.api.ArchiveCommand import org.eclipse.jgit.api.Git import org.eclipse.jgit.archive.TarFormat import org.eclipse.jgit.lib.ObjectId +import org.gradle.kotlin.dsl.support.uppercaseFirstChar import org.json.JSONObject plugins { @@ -21,24 +24,22 @@ java { buildscript { dependencies { - "classpath"(libs.jgit) - "classpath"(libs.jgit.archive) - "classpath"(libs.json) + classpath(libs.jgit) + classpath(libs.jgit.archive) + classpath(libs.json) } } typealias VersionTriple = Triple -fun MutableList.pop(): T = removeAt(size - 1) - fun describeVersion(git: Git): VersionTriple { // jgit doesn't provide a nice way to get strongly-typed objects from its `describe` command val describeStr = git.describe().setLong(true).call() return if (describeStr != null) { val pieces = describeStr.split('-').toMutableList() - val commit = git.repository.resolve(pieces.pop().substring(1)) - val count = pieces.pop().toInt() + val commit = git.repository.resolve(pieces.removeLast().substring(1)) + val count = pieces.removeLast().toInt() val tag = pieces.joinToString("-") Triple(tag, count, commit) @@ -123,13 +124,6 @@ android { versionCode = gitVersionCode versionName = gitVersionName } - sourceSets { - getByName("main") { - assets { - srcDir(archiveDir) - } - } - } buildTypes { getByName("debug") { signingConfig = null @@ -153,6 +147,14 @@ android { } } +androidComponents.onVariants { variant -> + variant.sources.assets!!.addGeneratedSourceDirectory(archive) { + project.objects.directoryProperty().apply { + set(archiveDir) + } + } +} + val archive = tasks.register("archive") { inputs.property("gitVersionTriple.third", gitVersionTriple.third) @@ -177,33 +179,40 @@ val archive = tasks.register("archive") { } } -android.applicationVariants.all { - val variant = this - val capitalized = variant.name.replaceFirstChar { it.uppercase() } +androidComponents.onVariants { variant -> + val capitalized = variant.name.uppercaseFirstChar() val variantDir = extraDir.map { it.dir(variant.name) } - - variant.preBuildProvider.configure { - dependsOn(archive) + val variantOutput = variant.outputs.first { + it.outputType == VariantOutputConfiguration.OutputType.SINGLE + } + val variantVersionCode = variantOutput.versionCode + val variantVersionName = variantOutput.versionName + val variantApkFiles = variant.artifacts.get(SingleArtifact.APK).map { + variant.artifacts.getBuiltArtifactsLoader().load(it)!!.elements.map { element -> + element.outputFile + } } + variant.lifecycleTasks.registerPreBuild(archive) + val moduleProp = tasks.register("moduleProp${capitalized}") { inputs.property("projectUrl", projectUrl) inputs.property("releaseMetadataBranch", releaseMetadataBranch) inputs.property("rootProject.name", rootProject.name) inputs.property("variant.applicationId", variant.applicationId) inputs.property("variant.name", variant.name) - inputs.property("variant.versionCode", variant.versionCode) - inputs.property("variant.versionName", variant.versionName) + inputs.property("variantVersionCode", variantVersionCode) + inputs.property("variantVersionName", variantVersionName) val outputFile = variantDir.map { it.file("module.prop") } outputs.file(outputFile) doLast { val props = LinkedHashMap() - props["id"] = variant.applicationId + props["id"] = variant.applicationId.get() props["name"] = rootProject.name - props["version"] = "v${variant.versionName}" - props["versionCode"] = variant.versionCode.toString() + props["version"] = "v${variantVersionName.get()}" + props["versionCode"] = variantVersionCode.get().toString() props["author"] = "chenxiaolong" props["description"] = "Change PackageManager installer fields on boot" @@ -220,9 +229,10 @@ android.applicationVariants.all { inputs.property("rootProject.name", rootProject.name) inputs.property("variant.applicationId", variant.applicationId) inputs.property("variant.name", variant.name) - inputs.property("variant.versionName", variant.versionName) + inputs.property("variantVersionName", variantVersionName) + inputs.files(variantApkFiles) - archiveFileName.set("${rootProject.name}-${variant.versionName}-${variant.name}.zip") + archiveFileName.set("${rootProject.name}-${variantVersionName.get()}-${variant.name}.zip") // Force instantiation of old value or else this will cause infinite recursion destinationDirectory.set(destinationDirectory.dir(variant.name).get()) @@ -230,10 +240,8 @@ android.applicationVariants.all { isPreserveFileTimestamps = false isReproducibleFileOrder = true - dependsOn.add(variant.assembleProvider) - from(moduleProp.map { it.outputs }) - from(variant.outputs.map { it.outputFile }) + from(variantApkFiles) val moduleDir = File(projectDir, "module") @@ -258,8 +266,8 @@ android.applicationVariants.all { inputs.property("projectUrl", projectUrl) inputs.property("rootProject.name", rootProject.name) inputs.property("variant.name", variant.name) - inputs.property("variant.versionCode", variant.versionCode) - inputs.property("variant.versionName", variant.versionName) + inputs.property("variantVersionCode", variantVersionCode) + inputs.property("variantVersionName", variantVersionName) val moduleDir = File(projectDir, "module") val updatesDir = File(moduleDir, "updates") @@ -274,9 +282,9 @@ android.applicationVariants.all { } val root = JSONObject() - root.put("version", variant.versionName) - root.put("versionCode", variant.versionCode) - root.put("zipUrl", "${projectUrl}/releases/download/${gitVersionTriple.first}/${rootProject.name}-${variant.versionName}-release.zip") + root.put("version", variantVersionName.get()) + root.put("versionCode", variantVersionCode.get()) + root.put("zipUrl", "${projectUrl}/releases/download/${gitVersionTriple.first}/${rootProject.name}-${variantVersionName.get()}-release.zip") root.put("changelog", "${projectUrl}/raw/${gitVersionTriple.first}/app/module/updates/${variant.name}/changelog.txt") jsonFile.writer().use { diff --git a/gradle.properties b/gradle.properties index f20a521..8be0b88 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,9 +11,3 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app"s APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn -android.useAndroidX=true -# Kotlin code style for this project: "official" or "obsolete": -kotlin.code.style=official diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4ee551b..525c68c 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,7 +1,7 @@ [versions] -android-gradle-plugin = "8.13.0" -jgit = "7.4.0.202509020913-r" -json = "20250517" +android-gradle-plugin = "9.0.0" +jgit = "7.5.0.202512021534-r" +json = "20251224" [libraries] # Build script diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index ddba4b0..06f19ea 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -10,263 +10,255 @@ - - + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - - - - - - - - - + + @@ -285,252 +277,252 @@ - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + @@ -978,12 +970,12 @@ - - - + + + - - + + @@ -994,24 +986,11 @@ - - - - - - - - - - - - - @@ -1058,28 +1037,20 @@ - - - + + + - - + + - - - + + + - - - - - - - - - - + + @@ -1502,11 +1473,6 @@ - - - - - @@ -1549,11 +1515,6 @@ - - - - - @@ -1564,27 +1525,32 @@ - - - - - + + + + + + + + + + - - - + + + - - + + @@ -1595,6 +1561,14 @@ + + + + + + + + @@ -1608,24 +1582,19 @@ - - - - - - - - + + + - - - + + + - - - + + + @@ -1633,6 +1602,11 @@ + + + + + @@ -1797,25 +1771,25 @@ - - - + + + - - + + - - - + + + - - - + + + - - + + @@ -1863,6 +1837,161 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1871,12 +2000,60 @@ - - - + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1895,12 +2072,20 @@ - - - + + + + + + + + + + + - - + + @@ -1919,9 +2104,9 @@ - - - + + + @@ -1932,12 +2117,12 @@ - - - + + + - - + + @@ -1948,12 +2133,44 @@ - - - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1979,6 +2196,11 @@ + + + + + @@ -2012,6 +2234,14 @@ + + + + + + + + @@ -2020,12 +2250,12 @@ - - - + + + - - + + @@ -2036,6 +2266,14 @@ + + + + + + + + @@ -2044,6 +2282,14 @@ + + + + + + + + @@ -2121,12 +2367,17 @@ - - - + + + - - + + + + + + + @@ -2134,9 +2385,9 @@ - - - + + + @@ -2162,12 +2413,12 @@ - - - + + + - - + + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 8bdaf60..61285a6 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 6a38a8c..44ae953 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionSha256Sum=a17ddd85a26b6a7f5ddb71ff8b05fc5104c0202c6e64782429790c933686c806 -distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip +distributionSha256Sum=0d585f69da091fc5b2beced877feab55a3064d43b8a1d46aeb07996b0915e0e0 +distributionUrl=https\://services.gradle.org/distributions/gradle-9.3.0-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME