Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions gradle-plugin/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,50 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 8.13.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.13.0)" variant="all" version="8.13.0">

<issue
id="EagerGradleConfiguration"
message="Avoid using method get"
errorLine1=" val destinationProperty = (kaptProvider?.get() as? KaptTask)?.destinationDir"
errorLine2=" ~~~">
<location
file="src/main/kotlin/com/google/devtools/ksp/gradle/AndroidPluginIntegration.kt"
line="109"
column="62"/>
</issue>

<issue
id="EagerGradleConfiguration"
message="Avoid using method get"
errorLine1=" kotlinCompileProvider.get().libraries.filter {"
errorLine2=" ~~~">
<location
file="src/main/kotlin/com/google/devtools/ksp/gradle/KspAATask.kt"
line="226"
column="59"/>
</issue>

<issue
id="EagerGradleConfiguration"
message="Avoid using method get"
errorLine1=" cfg.konanHome.value((kotlinCompileProvider.get() as KotlinNativeCompile).konanHome)"
errorLine2=" ~~~">
<location
file="src/main/kotlin/com/google/devtools/ksp/gradle/KspAATask.kt"
line="347"
column="68"/>
</issue>

<issue
id="EagerGradleConfiguration"
message="Use register instead of create"
errorLine1=" private val configurationForAll = project.configurations.create(PREFIX).apply {"
errorLine2=" ~~~~~~">
<location
file="src/main/kotlin/com/google/devtools/ksp/gradle/KspConfigurations.kt"
line="28"
column="62"/>
</issue>

<issue
id="EagerGradleConfiguration"
message="Use register instead of maybeCreate"
Expand All @@ -56,17 +12,6 @@
column="39"/>
</issue>

<issue
id="EagerGradleConfiguration"
message="Use configureEach instead of whenObjectAdded"
errorLine1=" configurationForAll.dependencies.whenObjectAdded {"
errorLine2=" ~~~~~~~~~~~~~~~">
<location
file="src/main/kotlin/com/google/devtools/ksp/gradle/KspConfigurations.kt"
line="122"
column="50"/>
</issue>

<issue
id="EagerGradleConfiguration"
message="Use register instead of maybeCreate"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import org.jetbrains.kotlin.gradle.internal.KaptTask
import org.jetbrains.kotlin.gradle.plugin.KotlinBaseApiPlugin
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJvmAndroidCompilation
import org.jetbrains.kotlin.util.capitalizeDecapitalize.capitalizeAsciiOnly
import java.util.concurrent.Callable

/**
* This helper class handles communication with the android plugin.
Expand Down Expand Up @@ -104,10 +103,11 @@ object AndroidPluginIntegration {
val sources = androidVariant?.getSourceFolders(SourceKind.JAVA)

kspTaskProvider.configure { task ->
// this is workaround for KAPT generator that prevents circular dependency
val filteredSources = Callable {
val destinationProperty = (kaptProvider?.get() as? KaptTask)?.destinationDir
val dir = destinationProperty?.get()?.asFile
// Workaround for KAPT generator that prevents circular dependency, we can't call kaptProvider.map directly.
val filteredSources = project.provider {
@Suppress("EagerGradleConfiguration") // kaptProvider could be gotten in provider.
val kapt = kaptProvider?.get()
val dir = (kapt as? KaptTask)?.destinationDir?.get()?.asFile
sources?.filter { source ->
dir?.isParentOf(source.dir) != true &&
source.dir !in kspExtension.excludedSources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ import java.lang.reflect.InvocationTargetException
import java.net.URLClassLoader
import java.nio.file.Paths
import java.util.*
import java.util.concurrent.Callable
import javax.inject.Inject

@CacheableTask
Expand Down Expand Up @@ -221,15 +220,16 @@ abstract class KspAATask @Inject constructor(
val kaptGeneratedClassesDir = getKaptGeneratedClassesDir(project, sourceSetName)
val kspOutputDir = KspGradleSubplugin.getKspOutputDir(project, sourceSetName, target)
cfg.libraries.from(
project.files(
Callable {
kotlinCompileProvider.get().libraries.filter {
!kspOutputDir.get().asFile.isParentOf(it) &&
!kaptGeneratedClassesDir.isParentOf(it) &&
!(it.isDirectory && it.listFiles()?.isEmpty() == true)
}
// Workaround for preventing circular dependency, we can't call kotlinCompileProvider.map directly.
project.provider {
@Suppress("EagerGradleConfiguration") // kotlinCompile could be gotten in provider.
val kotlinCompile = kotlinCompileProvider.get()
kotlinCompile.libraries.filter {
!kspOutputDir.get().asFile.isParentOf(it) &&
!kaptGeneratedClassesDir.isParentOf(it) &&
!(it.isDirectory && it.listFiles()?.isEmpty() == true)
}
)
}
)
} else {
cfg.libraries.from(
Expand Down Expand Up @@ -344,7 +344,7 @@ abstract class KspAATask @Inject constructor(
if (kotlinCompilation is KotlinNativeCompilation) {
val konanTargetName = kotlinCompilation.target.konanTarget.name
cfg.konanTargetName.value(konanTargetName)
cfg.konanHome.value((kotlinCompileProvider.get() as KotlinNativeCompile).konanHome)
cfg.konanHome.value(kotlinCompileProvider.map { (it as KotlinNativeCompile).konanHome }.get())

val isKlibCrossCompilationEnabled: Provider<Boolean> = project.providers.gradleProperty(
"kotlin.native.enableKlibsCrossCompilation"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ class KspConfigurations(private val project: Project) {
?: true

// The "ksp" configuration, applied to every compilation.
private val configurationForAll = project.configurations.create(PREFIX).apply {
isCanBeConsumed = false
isCanBeResolved = false
isVisible = false
private val configurationForAll = project.configurations.register(PREFIX) {
it.isCanBeConsumed = false
it.isCanBeResolved = false
it.isVisible = false
}

private fun configurationNameOf(vararg parts: String): String {
Expand Down Expand Up @@ -118,17 +118,19 @@ class KspConfigurations(private val project: Project) {
is KotlinMultiplatformExtension -> {
kotlin.targets.configureEach { decorateKotlinTarget(it, isKotlinMultiplatform = true) }

var reported = false
configurationForAll.dependencies.whenObjectAdded {
if (!reported) {
reported = true
val msg = "The 'ksp' configuration is deprecated in Kotlin Multiplatform projects. " +
"Please use target-specific configurations like 'kspJvm' instead."

if (allowAllTargetConfiguration) {
project.logger.warn(msg)
} else {
throw InvalidUserCodeException(msg)
configurationForAll.configure { configuration ->
var reported = false
configuration.dependencies.configureEach {
if (!reported) {
reported = true
val msg = "The 'ksp' configuration is deprecated in Kotlin Multiplatform projects. " +
"Please use target-specific configurations like 'kspJvm' instead."

if (allowAllTargetConfiguration) {
project.logger.warn(msg)
} else {
throw InvalidUserCodeException(msg)
}
}
}
}
Expand Down