diff --git a/plugins/pill/pill-importer/src/JpsCompatiblePluginTasks.kt b/plugins/pill/pill-importer/src/JpsCompatiblePluginTasks.kt index 5741005b35b..91cf3016245 100644 --- a/plugins/pill/pill-importer/src/JpsCompatiblePluginTasks.kt +++ b/plugins/pill/pill-importer/src/JpsCompatiblePluginTasks.kt @@ -70,6 +70,8 @@ class JpsCompatiblePluginTasks( Regex("kotlin_test_wasm_js_[\\d_]+_SNAPSHOT\\.xml"), Regex("kotlin_dom_api_compat_[\\d_]+_SNAPSHOT\\.xml") ) + + private val EXCLUDED_DIRECTORY_PATHS = listOf("out") } private lateinit var projectDir: File @@ -92,7 +94,8 @@ class JpsCompatiblePluginTasks( rootProject.logger.lifecycle("Pill: Setting up project...") val modulePrefix = System.getProperty("pill.module.prefix", "") - val modelParser = ModelParser(modulePrefix) + val globalExcludedDirectories = EXCLUDED_DIRECTORY_PATHS.map { File(rootProject.projectDir, it) } + val modelParser = ModelParser(modulePrefix, globalExcludedDirectories) val dependencyPatcher = DependencyPatcher(rootProject) val dependencyMappers = listOf(dependencyPatcher, ::attachPlatformSources, ::attachAsmSources) diff --git a/plugins/pill/pill-importer/src/ModelParser.kt b/plugins/pill/pill-importer/src/ModelParser.kt index 5e93dccba5a..743746851de 100644 --- a/plugins/pill/pill-importer/src/ModelParser.kt +++ b/plugins/pill/pill-importer/src/ModelParser.kt @@ -32,7 +32,7 @@ import java.util.* typealias OutputDir = String typealias GradleProjectPath = String -class ModelParser(private val modulePrefix: String) { +class ModelParser(private val modulePrefix: String, private val globalExcludedDirectories: List) { fun parse(project: Project): PProject { if (project != project.rootProject) { error("$project is not a root project") @@ -182,7 +182,7 @@ class ModelParser(private val modulePrefix: String) { forTests = false, rootDirectory = project.projectDir, moduleFile = mainModuleFileRelativePath, - contentRoots = listOf(PContentRoot(project.projectDir, listOf(), getExcludedDirs(project, excludedProjects))), + contentRoots = listOf(PContentRoot(project.projectDir, listOf(), computeAllExcludedDirectories(project, excludedProjects))), orderRoots = emptyList(), javaLanguageVersion = null, kotlinOptions = null, @@ -199,14 +199,13 @@ class ModelParser(private val modulePrefix: String) { return javaToolchainService.launcherFor(javaPluginExtension.toolchain).orNull?.metadata?.languageVersion?.asInt() } - private fun getExcludedDirs(project: Project, excludedProjects: List): List { - fun getJavaExcludedDirs() = project.plugins.findPlugin(IdeaPlugin::class.java) - ?.model?.module?.excludeDirs?.toList() ?: emptyList() + private fun computeAllExcludedDirectories(project: Project, excludedProjects: List): List { + val javaExcludedDirectories = project.plugins.findPlugin(IdeaPlugin::class.java) + ?.model?.module?.excludeDirs?.toList().orEmpty() - fun getPillExcludedDirs() = project.findPillExtensionMirror()?.excludedDirs ?: emptyList() + val excludedProjectDirectories = if (project == project.rootProject) excludedProjects.map { it.buildDir } else emptyList() - return getPillExcludedDirs() + getJavaExcludedDirs() + project.buildDir + - (if (project == project.rootProject) excludedProjects.map { it.buildDir } else emptyList()) + return globalExcludedDirectories + javaExcludedDirectories + project.buildDir + excludedProjectDirectories } private fun parseSourceSets(project: Project): List { diff --git a/plugins/pill/pill-importer/src/PillExtensionMirror.kt b/plugins/pill/pill-importer/src/PillExtensionMirror.kt deleted file mode 100644 index 436c73bab8e..00000000000 --- a/plugins/pill/pill-importer/src/PillExtensionMirror.kt +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. - * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. - */ - -package org.jetbrains.kotlin.pill - -import java.io.File -import org.gradle.api.Project - -open class PillExtensionMirror(val excludedDirs: List) - -fun Project.findPillExtensionMirror(): PillExtensionMirror? { - val ext = extensions.findByName("pill") ?: return null - - @Suppress("UNCHECKED_CAST") - val serialized = ext::class.java.getMethod("serialize").invoke(ext) as Map - - @Suppress("UNCHECKED_CAST") - val excludedDirs = serialized["excludedDirs"] as List - - return PillExtensionMirror(excludedDirs) -} \ No newline at end of file