Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool

private val androidComponentCache = ConcurrentHashMap<String, Component>()

private var ksp1WarningShown = false

override fun apply(target: Project) {
val ksp = target.extensions.create("ksp", KspExtension::class.java)
ksp.useKsp2.convention(
Expand Down Expand Up @@ -252,12 +254,13 @@ class KspGradleSubplugin @Inject internal constructor(private val registry: Tool

val useKsp2 = project.extensions.getByType(KspExtension::class.java).useKsp2.get()

if (useKsp2.not()) {
if (useKsp2.not() && ksp1WarningShown.not()) {
project.logger.warn(
"We noticed you are using KSP1 which is deprecated and support for it will be removed soon - " +
"please migrate to KSP2 as soon as possible. KSP1 will no longer be compatible with" +
" Android Gradle Plugin 9.0.0 (and above) and Kotlin 2.3.0 (and above)"
)
ksp1WarningShown = true
}

// Check version and show warning by default.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class VersionCheckIT(val useKSP2: Boolean) {
@JvmField
val project: TemporaryTestProject = TemporaryTestProject("playground", useKSP2 = useKSP2)

fun String.containsOnce(substring: String, ignoreCase: Boolean = false): Boolean {
val firstIndex = this.indexOf(substring, ignoreCase = ignoreCase)
return firstIndex != -1 && firstIndex == this.lastIndexOf(substring, ignoreCase = ignoreCase)
}

@Test
fun testKsp1Usage() {
Assume.assumeFalse(useKSP2)
Expand All @@ -23,7 +28,7 @@ class VersionCheckIT(val useKSP2: Boolean) {
).run()

Assert.assertTrue(
result.output.contains(
result.output.containsOnce(
"We noticed you are using KSP1 which is deprecated and support for it will be removed " +
"soon - please migrate to KSP2 as soon as possible. KSP1 will no " +
"longer be compatible with Android Gradle Plugin 9.0.0 (and above) and Kotlin 2.3.0 (and above)"
Expand Down
Loading