Skip to content

Commit bfc2f27

Browse files
committed
Improve stability subfolder names
1 parent e5291cd commit bfc2f27

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

stability-gradle/src/main/kotlin/com/skydoves/compose/stability/gradle/StabilityAnalyzerGradlePlugin.kt

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ public class StabilityAnalyzerGradlePlugin : KotlinCompilerPluginSupportPlugin {
7575

7676
// Per-task output directory to avoid shared output conflicts with other plugins (Issue #153)
7777
target.tasks.withType(KotlinCompile::class.java).configureEach {
78-
val stabilityDir = target.layout.buildDirectory.dir("stability/$name")
78+
val stabilityDir = target.layout.buildDirectory.dir(
79+
getKotlinTaskStabilityFolderName(name),
80+
)
7981
outputs.dir(stabilityDir).optional(true)
8082
}
8183

@@ -174,7 +176,7 @@ public class StabilityAnalyzerGradlePlugin : KotlinCompilerPluginSupportPlugin {
174176
projectName.set(target.name)
175177
stabilityInputFiles.setFrom(
176178
target.layout.buildDirectory.file(
177-
"stability/compile${variantNameUpperCase}Kotlin/stability-info.json",
179+
"stability/$variantNameLowerCase/stability-info.json",
178180
),
179181
)
180182
outputDir.set(extension.stabilityValidation.outputDir)
@@ -193,7 +195,7 @@ public class StabilityAnalyzerGradlePlugin : KotlinCompilerPluginSupportPlugin {
193195
projectName.set(target.name)
194196
stabilityInputFiles.from(
195197
target.layout.buildDirectory.file(
196-
"stability/compile${variantNameUpperCase}Kotlin/stability-info.json",
198+
"stability/$variantNameLowerCase/stability-info.json",
197199
),
198200
)
199201
stabilityReferenceFiles.from(extension.stabilityValidation.outputDir)
@@ -284,7 +286,7 @@ public class StabilityAnalyzerGradlePlugin : KotlinCompilerPluginSupportPlugin {
284286
// Per-compilation output directory to avoid shared output conflicts (Issue #153)
285287
val compileTaskName = kotlinCompilation.compileTaskProvider.name
286288
val stabilityDir = project.layout.buildDirectory
287-
.dir("stability/$compileTaskName").get().asFile
289+
.dir(getKotlinTaskStabilityFolderName(compileTaskName)).get().asFile
288290
stabilityDir.mkdirs()
289291
val dependenciesFile = java.io.File(stabilityDir, "project-dependencies.txt")
290292
dependenciesFile.writeText(projectDependencies.joinToString("\n"))
@@ -518,3 +520,23 @@ public class StabilityAnalyzerGradlePlugin : KotlinCompilerPluginSupportPlugin {
518520
private fun getLintProject(project: Project): Project? =
519521
project.rootProject.findProject(":stability-lint")
520522
}
523+
524+
private fun getKotlinTaskStabilityFolderName(taskName: String): String {
525+
// Clean up the task name a bit to make folder name a bit clearer
526+
// compileKotlin => (blank)
527+
// compileDebugKotlin => debug
528+
// compileDebugAndroidTestKotlin => debugAndroidTest
529+
// compileDebugUnitTestKotlinAndroid => debugUnitTestAndroid
530+
// compileJvmCommonKotlinMetadata => jvmCommonMetadata
531+
532+
val subfolder = taskName
533+
.removePrefix("compile")
534+
.replace("Kotlin", "")
535+
.replaceFirstChar { it.lowercase() }
536+
537+
return if (subfolder.isBlank()) {
538+
"stability"
539+
} else {
540+
"stability/$subfolder"
541+
}
542+
}

0 commit comments

Comments
 (0)