[Gradle, JS] Fix test on DCE working with usual js files

This commit is contained in:
Ilya Goncharov
2019-10-18 14:14:42 +03:00
parent 83527a6d0e
commit f66e6337fe
2 changed files with 7 additions and 1 deletions
@@ -190,6 +190,8 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
it.dependsOn(kotlinTask)
it.kotlinFilesOnly = true
it.classpath = project.configurations.getByName(compilation.compileDependencyConfigurationName)
it.destinationDir = it.dceOptions.outputDirectory?.let { File(it) }
?: compilation.npmProject.dir.resolve(DCE_DIR)
@@ -50,6 +50,10 @@ open class KotlinJsDce : AbstractKotlinCompileTool<K2JSDceArguments>(), KotlinJs
private val dceOptionsImpl = KotlinJsDceOptionsImpl()
// DCE can be broken in case of non-kotlin js files or modules
@Internal
var kotlinFilesOnly: Boolean = false
@get:Internal
override val dceOptions: KotlinJsDceOptions
get() = dceOptionsImpl
@@ -68,7 +72,7 @@ open class KotlinJsDce : AbstractKotlinCompileTool<K2JSDceArguments>(), KotlinJs
@TaskAction
fun performDce() {
val inputFiles = (listOf(source) + classpath
.filter { isDceCandidate(it) }
.filter { !kotlinFilesOnly || isDceCandidate(it) }
.map { project.fileTree(it) })
.reduce(FileTree::plus)
.files.map { it.path }