Fix resourcesDir that cannot be imported due to not being a File

This commit is contained in:
Sergey Igushkin
2018-10-16 14:22:54 +03:00
parent e103bea211
commit c25cdb4264
2 changed files with 13 additions and 4 deletions
@@ -9,9 +9,11 @@ import org.gradle.api.Named
import org.gradle.api.attributes.HasAttributes
import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.FileCollection
import java.io.File
interface KotlinCompilationOutput {
var resourcesDir: Any
var resourcesDirProvider: Any
val resourcesDir: File
val classesDirs: ConfigurableFileCollection
val allOutputs: FileCollection
@@ -10,11 +10,12 @@ import org.gradle.api.file.ConfigurableFileCollection
import org.gradle.api.file.FileCollection
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationOutput
import org.jetbrains.kotlin.gradle.utils.isGradleVersionAtLeast
import java.io.File
import java.util.concurrent.Callable
class DefaultKotlinCompilationOutput(
project: Project,
override var resourcesDir: Any
private val project: Project,
override var resourcesDirProvider: Any
) : KotlinCompilationOutput, Callable<FileCollection> {
override val classesDirs: ConfigurableFileCollection = project.files()
@@ -24,6 +25,9 @@ class DefaultKotlinCompilationOutput(
from(Callable { resourcesDir })
}
override val resourcesDir: File
get() = project.file(resourcesDirProvider)
override fun call(): FileCollection = allOutputs
}
@@ -34,7 +38,10 @@ class KotlinWithJavaCompilationOutput(
private val javaSourceSetOutput
get() = compilation.javaSourceSet.output
override var resourcesDir: Any
override val resourcesDir: File
get() = javaSourceSetOutput.resourcesDir
override var resourcesDirProvider: Any
get() = javaSourceSetOutput.resourcesDir
set(value) { javaSourceSetOutput.setResourcesDir(value) }