Template
mirror of
https://github.com/MorpheApp/morphe-patches-template.git
synced 2026-12-01 00:19:34 +00:00
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().
This commit is contained in:
1 parent
e00dc144a0
commit
ca3ebed38b
2 files changed
+24
No files matched your search
@@ -1,3 +1,8 @@
|
||||
plugins {
|
||||
// Fails the build if patch code uses JDK APIs that do not exist on Android.
|
||||
alias(libs.plugins.animalsniffer)
|
||||
}
|
||||
|
||||
group = "app.template"
|
||||
|
||||
patches {
|
||||
@@ -20,6 +25,14 @@ val patchListGeneratorClasspath = configurations.create("patchListGeneratorClass
|
||||
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 {
|
||||
@@ -32,6 +45,11 @@ tasks {
|
||||
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")
|
||||
|
||||
Reference in new issue
Block a user