# HG changeset patch # User Da Risk # Date 1779148802 14400 # Node ID 4dd59e91dc997320f5af60a82550f825ce2a706f # Parent d21949038794d7f241b5e6d79469a81b392a2310 build: SourceLicenseChecker mark license task not compatible with gradle configuration cache diff -r d21949038794 -r 4dd59e91dc99 buildSrc/src/main/kotlin/SourceLicenseChecker.kt --- a/buildSrc/src/main/kotlin/SourceLicenseChecker.kt Sat May 16 17:48:50 2026 -0400 +++ b/buildSrc/src/main/kotlin/SourceLicenseChecker.kt Mon May 18 20:00:02 2026 -0400 @@ -39,6 +39,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper import org.jetbrains.kotlin.gradle.plugin.KotlinJsPluginWrapper import org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper +import java.io.File import java.util.Locale internal fun Project.configureSourceLicenseChecker() { @@ -47,6 +48,7 @@ configure { header = file("$rootDir/config/license/header.txt") mapping("java", "SLASHSTAR_STYLE") + mapping("json", "SLASHSTAR_STYLE") mapping("kt", "SLASHSTAR_STYLE") excludes(listOf("**/*.webp", "**/*.png")) @@ -54,7 +56,7 @@ // the LicensePlugin doesn't configure itself properly on DynamicFeaturePlugin // Copied the code to configure it - plugins.withType(DynamicFeaturePlugin::class.java) { + plugins.withType { configureAndroid() } // make the license tasks looks for kotlin files in an Android project @@ -63,12 +65,17 @@ } // make the license tasks for kotlin js project - plugins.withType(KotlinJsPluginWrapper::class.java) { + plugins.withType { configureKotlin() } - plugins.withType(KotlinMultiplatformPluginWrapper::class.java) { + plugins.withType { configureKotlin() + configureComposeResources() + } + + tasks.withType().configureEach { + notCompatibleWithConfigurationCache("License tasks calls getProject() at execution time") } } @@ -118,6 +125,49 @@ } } +private fun Project.configureComposeResources() { + val kotlin = the() + val taskInfix = "ComposeResources" + kotlin.sourceSets.configureEach { + val kotlinSource = this + val sourceSetTaskName = + "${LicenseBasePlugin.getLICENSE_TASK_BASE_NAME()}${taskInfix}${name.capitalize()}" + if (name.startsWith("generated")) { + logger.info("Skip sourceSet $name because it's generated code") + return@configureEach + } + val resourceDir = kotlinSource.resources.sourceDirectories.files.first() + val composeResourceDir = File(resourceDir, "../composeResources") + + val configureLicenseCheckTaskLambda: LicenseCheck.() -> Unit = { + source(composeResourceDir) + } + if (sourceSetTaskName in tasks.names) { + // tasks may have already been added by configuration for the Android plugin + logger.info("Tasks $sourceSetTaskName already exists. configure it") + tasks.named(sourceSetTaskName, LicenseCheck::class.java, configureLicenseCheckTaskLambda) + } else { + logger.info("Adding ${project.name}:$sourceSetTaskName task for sourceSet ${kotlinSource.name}") + tasks.register(sourceSetTaskName, LicenseCheck::class.java, configureLicenseCheckTaskLambda) + } + + val configureLicenseFormatTaskLambda: LicenseFormat.() -> Unit = { + source(composeResourceDir) + } + val sourceSetFormatTaskName = + "${LicenseBasePlugin.getFORMAT_TASK_BASE_NAME()}${taskInfix}${name.capitalize()}" + if (sourceSetFormatTaskName in tasks.names) { + // tasks may have already been added by configuration for the Android plugin + logger.info("Tasks $sourceSetFormatTaskName already exists. configure it") + tasks.named(sourceSetFormatTaskName, LicenseFormat::class.java, configureLicenseFormatTaskLambda) + } else { + logger.info("Adding ${project.name}:$sourceSetFormatTaskName task for sourceSet ${kotlinSource.name}") + tasks.register(sourceSetFormatTaskName, LicenseFormat::class.java, configureLicenseFormatTaskLambda) + } + } +} + + private fun Project.configureAndroid() { val android = the() diff -r d21949038794 -r 4dd59e91dc99 gradle/libs.versions.toml --- a/gradle/libs.versions.toml Sat May 16 17:48:50 2026 -0400 +++ b/gradle/libs.versions.toml Mon May 18 20:00:02 2026 -0400 @@ -1,5 +1,5 @@ [versions] -android-gradle-plugin = "9.1.0" +android-gradle-plugin = "9.2.1" annotation = "1.10.0" androidx-activity = "1.13.0" androidx-compose-bom = "2026.05.00"