Skip to content
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

Use the correct Kotlin source directory set on AGP 7 #279

Merged
merged 1 commit into from
Sep 15, 2022
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 @@ -3,15 +3,10 @@
package de.mannodermaus.gradle.plugins.junit5.internal.providers

import com.android.build.gradle.api.BaseVariant
import com.android.builder.model.SourceProvider
import de.mannodermaus.gradle.plugins.junit5.internal.extensions.agpLog
import de.mannodermaus.gradle.plugins.junit5.internal.extensions.unitTestVariant
import org.gradle.api.Project
import org.gradle.api.file.SourceDirectorySet
import org.gradle.api.internal.HasConvention
import org.gradle.api.logging.LogLevel.WARN
import org.jetbrains.kotlin.gradle.plugin.KOTLIN_DSL_NAME
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.File

Expand All @@ -35,7 +30,7 @@ internal class KotlinDirectoryProvider(

private fun sourceFoldersOf(variant: BaseVariant) =
variant.sourceSets
.flatMap { it.kotlin.srcDirs }
.flatMap { it.javaDirectories + it.kotlinDirectories }
.toSet()

private fun classFoldersOf(variant: BaseVariant): Set<File> {
Expand All @@ -59,13 +54,3 @@ internal class KotlinDirectoryProvider(

private val BaseVariant.kotlinTaskName
get() = "compile${this.name.capitalize()}Kotlin"

private val SourceProvider.kotlin: SourceDirectorySet
get() {
if (this !is HasConvention) {
throw IllegalArgumentException("Argument doesn't have Conventions: $this")
}

val kotlinConvention = this.convention.plugins[KOTLIN_DSL_NAME] as KotlinSourceSet
return kotlinConvention.kotlin
}