Skip to content

[gradle-plugin] Simplify task wiring #6562

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025
Merged
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 @@ -70,29 +70,15 @@ private fun Project.getTestVariants(): NamedDomainObjectContainer<BaseVariant> {
return container
}


fun connectToAndroidSourceSet(
project: Project,
sourceSetName: String,
outputDir: Provider<Directory>,
taskProvider: TaskProvider<out Task>,
) {
val kotlinSourceSet = project.kotlinProjectExtension?.sourceSets?.getByName(sourceSetName)?.kotlin
if (kotlinSourceSet != null) {
kotlinSourceSet.srcDir(outputDir)
}

project.getMainVariants().configureEach {
if (it.sourceSets.any { it.name == sourceSetName }) {
if (kotlinSourceSet == null) {
it.registerJavaGeneratingTask(taskProvider, outputDir.get().asFile)
} else {
// The kotlinSourceSet carries task dependencies, calling srcDir() above is enough
// to setup task dependencies
// addJavaSourceFoldersToModel is still required for AS to see the sources
// See https://github.com/apollographql/apollo-kotlin/issues/3351
it.addJavaSourceFoldersToModel(outputDir.get().asFile)
}
it.registerJavaGeneratingTask(taskProvider, outputDir.get().asFile)
}
}
}
Expand Down
Loading