Fix Kapt3 classes not consumed by kotlinCompile tasks from their friend
This commit is contained in:
committed by
Yan Zhulanow
parent
ea1068a822
commit
7da6ff78c1
+3
-1
@@ -285,7 +285,9 @@ class Kapt3KotlinGradleSubplugin : KotlinGradleSubplugin<KotlinCompile> {
|
||||
kaptTask.classesDir = classesOutputDir
|
||||
|
||||
javaSourceSet?.output?.apply {
|
||||
tryAddClassesDir { project.files(classesOutputDir).builtBy(kaptTask) }
|
||||
if (tryAddClassesDir { project.files(classesOutputDir).builtBy(kaptTask) }) {
|
||||
kotlinCompile.attachClassesDir { classesOutputDir }
|
||||
}
|
||||
}
|
||||
|
||||
kotlinCompile.source(sourcesOutputDir, kotlinSourcesOutputDir)
|
||||
|
||||
+16
-1
@@ -139,8 +139,23 @@ abstract class AbstractKotlinCompile<T : CommonCompilerArguments>() : AbstractKo
|
||||
protected val friendTask: AbstractKotlinCompile<T>?
|
||||
get() = friendTaskName?.let { project.tasks.findByName(it) } as? AbstractKotlinCompile<T>
|
||||
|
||||
/** Classes directories that are not produced by this task but should be consumed by
|
||||
* other tasks that have this one as a [friendTask]. */
|
||||
private val attachedClassesDirs: MutableList<Lazy<File?>> = mutableListOf()
|
||||
|
||||
/** Registers the directory provided by the [provider] as attached, meaning that the directory should
|
||||
* be consumed as a friend classes directory by other tasks that have this task as a [friendTask]. */
|
||||
fun attachClassesDir(provider: () -> File?) {
|
||||
attachedClassesDirs += lazy(provider)
|
||||
}
|
||||
|
||||
var friendPaths: Lazy<Array<String>?> = lazy {
|
||||
friendTask?.run { arrayOf((javaOutputDir ?: destinationDir).absolutePath) }
|
||||
friendTask?.let { friendTask ->
|
||||
mutableListOf<String>().apply {
|
||||
add((friendTask.javaOutputDir ?: friendTask.destinationDir).absolutePath)
|
||||
addAll(friendTask.attachedClassesDirs.mapNotNull { it.value?.absolutePath })
|
||||
}.toTypedArray()
|
||||
}
|
||||
}
|
||||
|
||||
override fun compile() {
|
||||
|
||||
Reference in New Issue
Block a user