Skip to content

Commit f82a0b4

Browse files
committed
Remove KSP1 related logic from gradle plugin
1 parent 29ce41f commit f82a0b4

File tree

6 files changed

+32
-901
lines changed

6 files changed

+32
-901
lines changed

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

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ object AndroidPluginIntegration {
7373
private fun tryUpdateKspWithAndroidSourceSets(
7474
project: Project,
7575
kotlinCompilation: KotlinJvmAndroidCompilation,
76-
kspTaskProvider: TaskProvider<*>,
76+
kspTaskProvider: TaskProvider<KspAATask>,
7777
androidComponent: Component?
7878
) {
7979
val kaptProvider: TaskProvider<Task>? =
@@ -96,17 +96,8 @@ object AndroidPluginIntegration {
9696
val dir = destinationProperty?.get()?.asFile
9797
sources.filter { dir?.isParentOf(it.dir) != true }
9898
}
99-
when (task) {
100-
is KspTaskJvm -> {
101-
task.source(filteredSources)
102-
}
10399

104-
is KspAATask -> {
105-
task.kspConfig.javaSourceRoots.from(filteredSources)
106-
}
107-
108-
else -> Unit
109-
}
100+
task.kspConfig.javaSourceRoots.from(filteredSources)
110101
}
111102
}
112103

@@ -124,27 +115,26 @@ object AndroidPluginIntegration {
124115
private fun registerGeneratedSources(
125116
project: Project,
126117
kotlinCompilation: KotlinJvmAndroidCompilation,
127-
kspTaskProvider: TaskProvider<*>,
118+
kspTaskProvider: TaskProvider<KspAATask>,
128119
javaOutputDir: Provider<Directory>,
129120
kotlinOutputDir: Provider<Directory>,
130121
classOutputDir: Provider<Directory>,
131122
resourcesOutputDir: Provider<Directory>,
132123
androidComponent: Component?,
133-
useKsp2: Boolean,
134124
) {
135-
if (androidComponent != null && useKsp2 && project.canUseAddGeneratedSourceDirectoriesApi()) {
125+
if (androidComponent != null && project.canUseAddGeneratedSourceDirectoriesApi()) {
136126
androidComponent.sources.java?.addGeneratedSourceDirectory(
137127
taskProvider = kspTaskProvider,
138-
wiredWith = { task -> (task as KspAATask).kspConfig.javaOutputDir }
128+
wiredWith = { task -> task.kspConfig.javaOutputDir }
139129
)
140130

141131
androidComponent.sources.java?.addGeneratedSourceDirectory(
142132
taskProvider = kspTaskProvider,
143-
wiredWith = { task -> (task as KspAATask).kspConfig.kotlinOutputDir }
133+
wiredWith = { task -> task.kspConfig.kotlinOutputDir }
144134
)
145135
androidComponent.sources.resources?.addGeneratedSourceDirectory(
146136
taskProvider = kspTaskProvider,
147-
wiredWith = { task -> (task as KspAATask).kspConfig.resourceOutputDir }
137+
wiredWith = { task -> task.kspConfig.resourceOutputDir }
148138
)
149139

150140
// this is a bit of a hack because merge*GeneratedProguardFiles in AGP looks in the CLASSES artifacts
@@ -188,13 +178,12 @@ object AndroidPluginIntegration {
188178
fun syncSourceSets(
189179
project: Project,
190180
kotlinCompilation: KotlinJvmAndroidCompilation,
191-
kspTaskProvider: TaskProvider<*>,
181+
kspTaskProvider: TaskProvider<KspAATask>,
192182
javaOutputDir: Provider<Directory>,
193183
kotlinOutputDir: Provider<Directory>,
194184
classOutputDir: Provider<Directory>,
195185
resourcesOutputDir: Provider<Directory>,
196186
androidComponent: Component?,
197-
useKsp2: Boolean,
198187
) {
199188
// Order is important here as we update task with AGP generated sources and
200189
// then update AGP with source that KSP will generate.
@@ -210,7 +199,6 @@ object AndroidPluginIntegration {
210199
classOutputDir,
211200
resourcesOutputDir,
212201
androidComponent,
213-
useKsp2
214202
)
215203
}
216204

0 commit comments

Comments
 (0)