Build: Use attributes to resolve test dependencies in jps build mode

This commit is contained in:
Vyacheslav Gerasimov
2020-06-26 19:08:34 +03:00
parent a32f901ab9
commit 77a8cf4e66
10 changed files with 84 additions and 11 deletions
+16 -3
View File
@@ -103,20 +103,33 @@ if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
apply(mapOf("plugin" to "idea"))
// Make Idea import embedded configuration as transitive dependency for some configurations
afterEvaluate {
val jpsBuildTestDependencies = configurations.maybeCreate("jpsBuildTestDependencies").apply {
isCanBeConsumed = false
isCanBeResolved = true
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named("embedded-java-runtime"))
}
}
listOf(
"testCompile",
"testCompileOnly",
"testRuntime",
"testRuntimeOnly"
).forEach { configurationName ->
val dependencyProjects = configurations
.findByName(configurationName)
val configuration = configurations.findByName(configurationName)
configuration?.apply {
extendsFrom(jpsBuildTestDependencies)
}
val dependencyProjects = configuration
?.dependencies
?.mapNotNull { (it as? ProjectDependency)?.dependencyProject }
dependencies {
dependencyProjects?.forEach {dependencyProject ->
add(configurationName, project(dependencyProject.path, configuration = "embedded"))
add(jpsBuildTestDependencies.name, project(dependencyProject.path))
}
}
}