Skip to content

Commit 81bc682

Browse files
natiginfogithub-actions[bot]
authored andcommitted
[maps-android] separate KSP check to its own step inside verify-code (#4721)
Generated KSP files are already tracked in Git. Therefore, we don't need to generate them in every run since it adds extra time to CI runs as clean runs fails due to KSP issues. This PR adds separate task to check and update KSP files when needed. GitOrigin-RevId: 74769647867b4bf66a82d00632a129a42df305a6
1 parent 7340041 commit 81bc682

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
VERSION_NAME=11.14.0-SNAPSHOT-06-24--04-30.git-d373f44
2-
LAST_STABLE_VERSION=11.11.0
2+
LAST_STABLE_VERSION=11.13.1
33
# version name for the test app
44
TEST_APP_VERSION_NAME=0.1.0
55

sdk-base/build.gradle.kts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ android {
3030

3131
// moving generated KSP files from build folder to `src/<variant_name>/ksp`
3232
afterEvaluate {
33+
val shouldGenerateKsp = project.hasProperty("generate-ksp")
34+
3335
tasks.withType(KspTaskJvm::class.java).all {
36+
// Make KSP tasks optional - only run when explicitly requested
37+
enabled = shouldGenerateKsp
38+
3439
val generatedKspFilesFolder = destination
3540
var lastFolder = generatedKspFilesFolder.toPath().fileName.toString()
3641
// We handle "debug" and "release" build types as equal so remove them
@@ -45,7 +50,11 @@ android {
4550
val destinationPath = projectDir.resolve("src/$lastFolder/ksp")
4651
// dropping first 3 symbols which are `ksp`
4752
val variantName = name.drop(3)
53+
4854
val copyTask = tasks.register("moveKsp${variantName}Task", Sync::class.java) {
55+
// Only run if KSP generation is enabled
56+
enabled = shouldGenerateKsp
57+
4958
val sourcePath = "${generatedKspFilesFolder.absolutePath}${File.separator}kotlin"
5059
// make sure we always execute this task when KSP build folder is not empty
5160
outputs.upToDateWhen {
@@ -63,9 +72,20 @@ android {
6372
generatedKspFilesFolder.resolve("classes").mkdir()
6473
}
6574
}
66-
tasks.findByName("compile${variantName}")!!.dependsOn(copyTask)
67-
tasks.named("dokkaHtml") {
68-
dependsOn("moveKspReleaseKotlinTask", "kspReleaseKotlin")
75+
76+
// Always create the classes directory for metalava, regardless of KSP generation
77+
val createClassesDirTask = tasks.register("createKspClassesDir${variantName}") {
78+
doLast {
79+
generatedKspFilesFolder.resolve("classes").mkdirs()
80+
}
81+
}
82+
83+
if (shouldGenerateKsp) {
84+
// If KSP generation is enabled, add the copy task as a dependency to the compile task
85+
tasks.findByName("compile${variantName}")?.dependsOn(copyTask)
86+
} else {
87+
// If KSP generation is disabled, still create the classes directory for metalava
88+
tasks.findByName("compile${variantName}")?.dependsOn(createClassesDirTask)
6989
}
7090
}
7191
}

0 commit comments

Comments
 (0)