Skip to content

Commit 50bed18

Browse files
hfmehmedKSP Auto Pick
authored andcommitted
[AGP Built in kotlin] Pass kotlin sources from variant api as they are
no longer being passed to ksp task via allKotlinSourceSetsObservable (cherry picked from commit adeb459)
1 parent e19caf0 commit 50bed18

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/AndroidPluginIntegration.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,14 @@ object AndroidPluginIntegration {
8181
) {
8282
if (androidComponent != null && project.isAgpBuiltInKotlinUsed()) {
8383
if (project.canUseInternalKspApis()) {
84-
val sources =
84+
val javaSources =
8585
(androidComponent.sources.java as? FlatSourceDirectoriesForJavaImpl)?.allButKspAndKaptGenerators()
8686

87+
val kotlinSources = androidComponent.sources.kotlin?.static
88+
8789
kspTaskProvider.configure { task ->
88-
task.kspConfig.javaSourceRoots.from(sources)
90+
task.kspConfig.javaSourceRoots.from(javaSources)
91+
task.kspConfig.javaSourceRoots.from(kotlinSources)
8992
}
9093
} else {
9194
throw RuntimeException(

gradle-plugin/src/main/kotlin/com/google/devtools/ksp/gradle/utils/kgpUtils.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
88
import org.jetbrains.kotlin.gradle.utils.ObservableSet
99
import org.jetbrains.kotlin.tooling.core.KotlinToolingVersion
1010

11+
// NOTE: for AGP with built in kotlin enabled and android.disallowKotlinSourceSets=true, this returns empty set
1112
internal val KotlinCompilation<*>.allKotlinSourceSetsObservable
1213
get() = this.allKotlinSourceSets as ObservableSet<KotlinSourceSet>
1314

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ org.gradle.jvmargs=-Duser.country=US -Dkotlin.daemon.jvm.options=-Xmx4096m -Dfil
33
org.gradle.parallel=true
44

55
kotlinBaseVersion=2.3.0-RC
6-
agpBaseVersion=9.0.0-beta01
6+
agpBaseVersion=9.0.0-beta05
77
intellijVersion=241.19416.19
88
junitVersion=4.13.1
99
junit5Version=5.8.2

integration-tests/src/test/kotlin/com/google/devtools/ksp/test/AndroidBuiltInKotlinIT.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class AndroidBuiltInKotlinIT {
7575
fun testPlaygroundAndroidWithBuiltInKotlinAGP90AboveAlpha14() {
7676
val gradleRunner = GradleRunner.create().withProjectDir(project.root).withGradleVersion("9.1.0")
7777

78-
File(project.root, "gradle.properties").appendText("\nagpVersion=9.0.0-alpha14")
78+
File(project.root, "gradle.properties").appendText("\nagpVersion=9.0.0-beta05")
7979

8080
gradleRunner.withArguments(
8181
"clean", "build", "minifyReleaseWithR8", "--configuration-cache", "--info", "--stacktrace"
@@ -112,7 +112,7 @@ class AndroidBuiltInKotlinIT {
112112
fun testPlaygroundAndroidWithBuiltInKotlinProjectIsolationEnabled() {
113113
val gradleRunner = GradleRunner.create().withProjectDir(project.root).withGradleVersion("9.1.0")
114114

115-
File(project.root, "gradle.properties").appendText("\nagpVersion=9.0.0-alpha14")
115+
File(project.root, "gradle.properties").appendText("\nagpVersion=9.0.0-beta05")
116116
File(project.root, "gradle.properties").appendText("\nkotlinVersion=2.3.0-Beta2")
117117
File(project.root, "gradle.properties").appendText("\nksp.project.isolation.enabled=true")
118118

0 commit comments

Comments
 (0)