From 7129bcc2b1f192a51b1c1d69290be01d99ce9751 Mon Sep 17 00:00:00 2001 From: Yan Zhulanow Date: Mon, 4 Dec 2023 20:35:31 +0900 Subject: [PATCH] [Pill] Support production-on-test dependencies --- plugins/pill/pill-importer/src/JpsCompatiblePluginTasks.kt | 2 +- plugins/pill/pill-importer/src/ModelParser.kt | 2 +- plugins/pill/pill-importer/src/model/POrderRoot.kt | 5 ++--- plugins/pill/pill-importer/src/render.kt | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/pill/pill-importer/src/JpsCompatiblePluginTasks.kt b/plugins/pill/pill-importer/src/JpsCompatiblePluginTasks.kt index 91cf3016245..df33ed10463 100644 --- a/plugins/pill/pill-importer/src/JpsCompatiblePluginTasks.kt +++ b/plugins/pill/pill-importer/src/JpsCompatiblePluginTasks.kt @@ -335,7 +335,7 @@ class JpsCompatiblePluginTasks( for (path in paths) { val module = project.modules.find { it.path == path } if (module != null) { - result += PDependency.Module(module.name) + result += PDependency.Module(module) result += module.embeddedDependencies.flatMap { invoke(project, it) } continue } diff --git a/plugins/pill/pill-importer/src/ModelParser.kt b/plugins/pill/pill-importer/src/ModelParser.kt index fe67bf7eebf..8eaf2a82ec5 100644 --- a/plugins/pill/pill-importer/src/ModelParser.kt +++ b/plugins/pill/pill-importer/src/ModelParser.kt @@ -149,7 +149,7 @@ class ModelParser(private val modulePrefix: String, private val globalExcludedDi var orderRoots = parseDependencies(project, sourceSet) if (productionModule != null) { - val productionModuleDependency = PDependency.Module(productionModule.name) + val productionModuleDependency = PDependency.Module(productionModule) orderRoots = listOf(POrderRoot(productionModuleDependency, Scope.COMPILE, true)) + orderRoots } diff --git a/plugins/pill/pill-importer/src/model/POrderRoot.kt b/plugins/pill/pill-importer/src/model/POrderRoot.kt index a8cafae4195..d881e01544f 100644 --- a/plugins/pill/pill-importer/src/model/POrderRoot.kt +++ b/plugins/pill/pill-importer/src/model/POrderRoot.kt @@ -8,14 +8,13 @@ package org.jetbrains.kotlin.pill.model data class POrderRoot( val dependency: PDependency, val scope: Scope, - val isExported: Boolean = false, - val isProductionOnTestDependency: Boolean = false + val isExported: Boolean = false ) { enum class Scope { COMPILE, TEST, RUNTIME, PROVIDED } } sealed class PDependency { - data class Module(val name: String) : PDependency() + data class Module(val module: PModule) : PDependency() data class Library(val name: String) : PDependency() data class ModuleLibrary(val library: PLibrary) : PDependency() } \ No newline at end of file diff --git a/plugins/pill/pill-importer/src/render.kt b/plugins/pill/pill-importer/src/render.kt index 859d10e2b0c..bd69f34e836 100644 --- a/plugins/pill/pill-importer/src/render.kt +++ b/plugins/pill/pill-importer/src/render.kt @@ -146,7 +146,7 @@ private fun renderModule(project: PProject, module: PModule) = PFile( ) is PDependency.Module -> mutableListOf( "type" to "module", - "module-name" to dependency.name + "module-name" to dependency.module.name ) is PDependency.Library -> mutableListOf( "type" to "library", @@ -159,7 +159,7 @@ private fun renderModule(project: PProject, module: PModule) = PFile( args.add(1, "scope" to orderRoot.scope.toString()) } - if (dependency is PDependency.Module && orderRoot.isProductionOnTestDependency) { + if (!module.forTests && dependency is PDependency.Module && dependency.module.forTests) { args += ("production-on-test" to "") }