KTIJ-33763 [kotlin] Add possibility to specify productionOnTest flag when adding dependency to Module

GitOrigin-RevId: 0cbd97a98bfbbf8e22b9019e308b30d0f93c415e
This commit is contained in:
Roman Golyshev
2025-04-11 11:14:37 +02:00
committed by intellij-monorepo-bot
parent a1c5964f24
commit d05b7efaed
3 changed files with 9 additions and 2 deletions

View File

@@ -646,6 +646,7 @@ f:com.intellij.openapi.roots.ModuleRootModificationUtil
- s:addContentRoot(com.intellij.openapi.module.Module,java.lang.String):V
- s:addDependency(com.intellij.openapi.module.Module,com.intellij.openapi.module.Module):V
- s:addDependency(com.intellij.openapi.module.Module,com.intellij.openapi.module.Module,com.intellij.openapi.roots.DependencyScope,Z):V
- s:addDependency(com.intellij.openapi.module.Module,com.intellij.openapi.module.Module,com.intellij.openapi.roots.DependencyScope,Z,Z):V
- s:addDependency(com.intellij.openapi.module.Module,com.intellij.openapi.roots.libraries.Library):V
- s:addDependency(com.intellij.openapi.module.Module,com.intellij.openapi.roots.libraries.Library,com.intellij.openapi.roots.DependencyScope,Z):V
- s:addModuleLibrary(com.intellij.openapi.module.Module,java.lang.String):V

View File

@@ -143,10 +143,15 @@ public final class ModuleRootModificationUtil {
}
public static void addDependency(@NotNull Module from, @NotNull Module to, @NotNull DependencyScope scope, boolean exported) {
addDependency(from, to, scope, exported, false);
}
public static void addDependency(@NotNull Module from, @NotNull Module to, @NotNull DependencyScope scope, boolean exported, boolean productionOnTest) {
updateModel(from, model -> {
ModuleOrderEntry entry = model.addModuleOrderEntry(to);
entry.setScope(scope);
entry.setExported(exported);
entry.setProductionOnTestDependency(productionOnTest);
});
}

View File

@@ -169,8 +169,9 @@ abstract class AbstractMultiModuleTest : DaemonAnalyzerTestCase(),
fun Module.addDependency(
other: Module,
dependencyScope: DependencyScope = DependencyScope.COMPILE,
exported: Boolean = false
): Module = this.apply { ModuleRootModificationUtil.addDependency(this, other, dependencyScope, exported) }
exported: Boolean = false,
productionOnTest: Boolean = false,
): Module = this.apply { ModuleRootModificationUtil.addDependency(this, other, dependencyScope, exported, productionOnTest) }
fun Module.removeDependency(
other: Module,