Files
morphe-patches-template/patches/build.gradle.kts
T
LisoUseInAIKyrios ca3ebed38b chore: Fail the build if patches use APIs not available on Android
Patches run inside Manager on Android, so check the compiled patch
classes against the Android API 26 signature with Animal Sniffer.
This catches desktop-only JDK classes such as AWT and newer JDK
methods such as InputStream.readAllBytes() or List.of().
2026-11-21 09:05:10 +00:00

58 lines
1.6 KiB
Kotlin

plugins {
// Fails the build if patch code uses JDK APIs that do not exist on Android.
alias(libs.plugins.animalsniffer)
}
group = "app.template"
patches {
// TODO: Update this section with your project details.
about {
name = "UserXYZ Patches"
description = "Patches for apps I like"
source = "[email protected]:UserXYZ/morphe-patches.git"
author = "Awesome dev"
contact = "na"
website = "na"
license = "GPLv3"
}
}
// Separate configuration so gson is available at runtime for the
// generatePatchesList task but never bundled into the APK.
val patchListGeneratorClasspath = configurations.create("patchListGeneratorClasspath")
dependencies {
compileOnly(libs.gson)
patchListGeneratorClasspath(libs.gson)
// Android API level 26 is the minimum API the patches are compiled for (see buildAndroid).
signature(libs.android.api.signature) { artifact { type = "signature" } }
}
animalsniffer {
// Only the main source set ships in the patches file.
sourceSets = listOf(project.sourceSets["main"])
}
tasks {
register<JavaExec>("generatePatchesList") {
description = "Build patch with patch list"
dependsOn(build)
classpath = sourceSets["main"].runtimeClasspath + patchListGeneratorClasspath
mainClass.set("util.PatchListGeneratorKt")
}
// The check task already runs it, but buildAndroid does not depend on check.
named("buildAndroid") {
dependsOn("animalsnifferMain")
}
// Used by gradle-semantic-release-plugin.
publish {
dependsOn("generatePatchesList")
}
}