Pill: Understand dependencies with the 'apiElements' configuration name as module dependencies

This commit is contained in:
Yan Zhulanow
2018-10-02 19:44:50 +03:00
parent 813e4c966a
commit 6d73aa29e0
3 changed files with 11 additions and 6 deletions
@@ -173,7 +173,7 @@ fun generateKotlinPluginArtifactFile(rootProject: Project): PFile {
for (dependencyInfo in listOf(configuration).collectDependencies()) { for (dependencyInfo in listOf(configuration).collectDependencies()) {
val dependency = (dependencyInfo as? DependencyInfo.ResolvedDependencyInfo)?.dependency ?: continue val dependency = (dependencyInfo as? DependencyInfo.ResolvedDependencyInfo)?.dependency ?: continue
if (dependency.configuration == "runtimeElements") { if (dependency.isModuleDependency) {
archiveForJar.add(ModuleOutput(dependency.moduleName + ".src")) archiveForJar.add(ModuleOutput(dependency.moduleName + ".src"))
} else if (dependency.configuration == "tests-jar" || dependency.configuration == "jpsTest") { } else if (dependency.configuration == "tests-jar" || dependency.configuration == "jpsTest") {
error("Test configurations are not allowed here") error("Test configurations are not allowed here")
+4 -1
View File
@@ -413,7 +413,7 @@ private fun ParserContext.parseDependencies(project: Project, forTests: Boolean)
} }
} }
mainRoots += if (dependency.configuration == "runtimeElements" && scope != Scope.TEST) { mainRoots += if (dependency.isModuleDependency && scope != Scope.TEST) {
POrderRoot(PDependency.Module(dependency.moduleName + ".src"), scope) POrderRoot(PDependency.Module(dependency.moduleName + ".src"), scope)
} else if (dependency.configuration == "tests-jar" || dependency.configuration == "jpsTest") { } else if (dependency.configuration == "tests-jar" || dependency.configuration == "jpsTest") {
POrderRoot( POrderRoot(
@@ -489,6 +489,9 @@ sealed class DependencyInfo(val scope: Scope) {
class CustomDependencyInfo(scope: Scope, val files: List<File>) : DependencyInfo(scope) class CustomDependencyInfo(scope: Scope, val files: List<File>) : DependencyInfo(scope)
} }
val ResolvedDependency.isModuleDependency
get() = configuration in JpsCompatiblePlugin.MODULE_CONFIGURATIONS
fun List<CollectedConfiguration>.collectDependencies(): List<DependencyInfo> { fun List<CollectedConfiguration>.collectDependencies(): List<DependencyInfo> {
val dependencies = mutableListOf<DependencyInfo>() val dependencies = mutableListOf<DependencyInfo>()
+6 -4
View File
@@ -20,6 +20,8 @@ class PillConfigurablePlugin : Plugin<Project> {
class JpsCompatiblePlugin : Plugin<Project> { class JpsCompatiblePlugin : Plugin<Project> {
companion object { companion object {
val MODULE_CONFIGURATIONS = arrayOf("apiElements", "runtimeElements")
private fun mapper(module: String, vararg configurations: String): DependencyMapper { private fun mapper(module: String, vararg configurations: String): DependencyMapper {
return DependencyMapper("org.jetbrains.kotlin", module, *configurations) { MappedDependency(PDependency.Library(module)) } return DependencyMapper("org.jetbrains.kotlin", module, *configurations) { MappedDependency(PDependency.Library(module)) }
} }
@@ -27,10 +29,10 @@ class JpsCompatiblePlugin : Plugin<Project> {
private fun getDependencyMappers(projectLibraries: List<PLibrary>): List<DependencyMapper> { private fun getDependencyMappers(projectLibraries: List<PLibrary>): List<DependencyMapper> {
val mappersForKotlinLibrariesExeptStdlib = projectLibraries val mappersForKotlinLibrariesExeptStdlib = projectLibraries
.filter { it.name != "kotlin-stdlib" } .filter { it.name != "kotlin-stdlib" }
.mapTo(mutableListOf()) { mapper(it.name, "default", "distJar", "runtimeElements") } .mapTo(mutableListOf()) { mapper(it.name, "default", "distJar", *MODULE_CONFIGURATIONS) }
return mappersForKotlinLibrariesExeptStdlib + listOf( return mappersForKotlinLibrariesExeptStdlib + listOf(
DependencyMapper("org.jetbrains.kotlin", "kotlin-stdlib", "distJar", "runtimeElements") { DependencyMapper("org.jetbrains.kotlin", "kotlin-stdlib", "distJar", *MODULE_CONFIGURATIONS) {
MappedDependency( MappedDependency(
PDependency.Library("kotlin-stdlib"), PDependency.Library("kotlin-stdlib"),
listOf(PDependency.Library("annotations-13.0")) listOf(PDependency.Library("annotations-13.0"))
@@ -42,13 +44,13 @@ class JpsCompatiblePlugin : Plugin<Project> {
listOf(PDependency.Library("annotations-13.0")) listOf(PDependency.Library("annotations-13.0"))
) )
}, },
DependencyMapper("org.jetbrains.kotlin", "kotlin-reflect-api", "runtimeElements") { DependencyMapper("org.jetbrains.kotlin", "kotlin-reflect-api", *MODULE_CONFIGURATIONS) {
MappedDependency(PDependency.Library("kotlin-reflect")) MappedDependency(PDependency.Library("kotlin-reflect"))
}, },
DependencyMapper("org.jetbrains.kotlin", "kotlin-compiler-embeddable", "runtimeJar") { null }, DependencyMapper("org.jetbrains.kotlin", "kotlin-compiler-embeddable", "runtimeJar") { null },
DependencyMapper("org.jetbrains.kotlin", "kotlin-stdlib-js", "distJar") { null }, DependencyMapper("org.jetbrains.kotlin", "kotlin-stdlib-js", "distJar") { null },
DependencyMapper("org.jetbrains.kotlin", "kotlin-compiler", "runtimeJar") { null }, DependencyMapper("org.jetbrains.kotlin", "kotlin-compiler", "runtimeJar") { null },
DependencyMapper("org.jetbrains.kotlin", "compiler", "runtimeElements") { null }, DependencyMapper("org.jetbrains.kotlin", "compiler", *MODULE_CONFIGURATIONS) { null },
DependencyMapper("kotlin.build.custom.deps", "android", "default") { dep -> DependencyMapper("kotlin.build.custom.deps", "android", "default") { dep ->
val (sdkCommon, otherJars) = dep.moduleArtifacts.map { it.file }.partition { it.name == "sdk-common.jar" } val (sdkCommon, otherJars) = dep.moduleArtifacts.map { it.file }.partition { it.name == "sdk-common.jar" }
val mainLibrary = PDependency.ModuleLibrary(PLibrary(dep.moduleName, otherJars)) val mainLibrary = PDependency.ModuleLibrary(PLibrary(dep.moduleName, otherJars))