Build: Use attributes to resolve test dependencies in jps build mode
This commit is contained in:
@@ -365,6 +365,15 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configurations.maybeCreate("embeddedElements").apply {
|
||||||
|
extendsFrom(configurations["embedded"])
|
||||||
|
isCanBeConsumed = true
|
||||||
|
isCanBeResolved = false
|
||||||
|
attributes {
|
||||||
|
attribute(Usage.USAGE_ATTRIBUTE, objects.named("embedded-java-runtime"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
jvmTarget = defaultJvmTarget
|
jvmTarget = defaultJvmTarget
|
||||||
javaHome = defaultJavaHome
|
javaHome = defaultJavaHome
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,14 @@ val builtinsNative = fileFrom(rootDir, "core", "builtins", "native")
|
|||||||
val kotlinReflect = fileFrom(rootDir, "libraries/stdlib/src/kotlin/reflect")
|
val kotlinReflect = fileFrom(rootDir, "libraries/stdlib/src/kotlin/reflect")
|
||||||
val builtinsCherryPicked = fileFrom(buildDir, "src")
|
val builtinsCherryPicked = fileFrom(buildDir, "src")
|
||||||
|
|
||||||
|
val runtimeElements by configurations.creating {
|
||||||
|
isCanBeResolved = false
|
||||||
|
isCanBeConsumed = true
|
||||||
|
attributes {
|
||||||
|
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val prepareSources by tasks.registering(Sync::class) {
|
val prepareSources by tasks.registering(Sync::class) {
|
||||||
from(kotlinReflect) {
|
from(kotlinReflect) {
|
||||||
exclude("typeOf.kt")
|
exclude("typeOf.kt")
|
||||||
@@ -47,7 +55,7 @@ val assemble by tasks.getting {
|
|||||||
dependsOn(serialize)
|
dependsOn(serialize)
|
||||||
}
|
}
|
||||||
|
|
||||||
val builtinsJarArtifact = artifacts.add("default", builtinsJar)
|
val builtinsJarArtifact = artifacts.add(runtimeElements.name, builtinsJar)
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
|
|||||||
+9
-1
@@ -10,6 +10,14 @@ plugins {
|
|||||||
base
|
base
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val runtimeElements by configurations.creating {
|
||||||
|
isCanBeResolved = false
|
||||||
|
isCanBeConsumed = true
|
||||||
|
attributes {
|
||||||
|
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val JDK_18: String by rootProject.extra
|
val JDK_18: String by rootProject.extra
|
||||||
val toolsJarFile = toolsJarFile(jdkHome = File(JDK_18)) ?: error("Couldn't find tools.jar in $JDK_18")
|
val toolsJarFile = toolsJarFile(jdkHome = File(JDK_18)) ?: error("Couldn't find tools.jar in $JDK_18")
|
||||||
|
|
||||||
@@ -75,4 +83,4 @@ val jar = tasks.register<Jar>("jar") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
artifacts.add("default", jar)
|
artifacts.add(runtimeElements.name, jar)
|
||||||
|
|||||||
+16
-3
@@ -103,20 +103,33 @@ if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
|||||||
apply(mapOf("plugin" to "idea"))
|
apply(mapOf("plugin" to "idea"))
|
||||||
// Make Idea import embedded configuration as transitive dependency for some configurations
|
// Make Idea import embedded configuration as transitive dependency for some configurations
|
||||||
afterEvaluate {
|
afterEvaluate {
|
||||||
|
val jpsBuildTestDependencies = configurations.maybeCreate("jpsBuildTestDependencies").apply {
|
||||||
|
isCanBeConsumed = false
|
||||||
|
isCanBeResolved = true
|
||||||
|
attributes {
|
||||||
|
attribute(Usage.USAGE_ATTRIBUTE, objects.named("embedded-java-runtime"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
listOf(
|
listOf(
|
||||||
"testCompile",
|
"testCompile",
|
||||||
"testCompileOnly",
|
"testCompileOnly",
|
||||||
"testRuntime",
|
"testRuntime",
|
||||||
"testRuntimeOnly"
|
"testRuntimeOnly"
|
||||||
).forEach { configurationName ->
|
).forEach { configurationName ->
|
||||||
val dependencyProjects = configurations
|
val configuration = configurations.findByName(configurationName)
|
||||||
.findByName(configurationName)
|
|
||||||
|
configuration?.apply {
|
||||||
|
extendsFrom(jpsBuildTestDependencies)
|
||||||
|
}
|
||||||
|
|
||||||
|
val dependencyProjects = configuration
|
||||||
?.dependencies
|
?.dependencies
|
||||||
?.mapNotNull { (it as? ProjectDependency)?.dependencyProject }
|
?.mapNotNull { (it as? ProjectDependency)?.dependencyProject }
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
dependencyProjects?.forEach {dependencyProject ->
|
dependencyProjects?.forEach {dependencyProject ->
|
||||||
add(configurationName, project(dependencyProject.path, configuration = "embedded"))
|
add(jpsBuildTestDependencies.name, project(dependencyProject.path))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,13 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
val compile by configurations
|
val compile by configurations
|
||||||
val fatJarContents by configurations.creating
|
val fatJarContents by configurations.creating {
|
||||||
|
isCanBeResolved = true
|
||||||
|
isCanBeConsumed = false
|
||||||
|
attributes {
|
||||||
|
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
|
||||||
|
}
|
||||||
|
}
|
||||||
val fatJarContentsStripMetadata by configurations.creating
|
val fatJarContentsStripMetadata by configurations.creating
|
||||||
val fatJarContentsStripServices by configurations.creating
|
val fatJarContentsStripServices by configurations.creating
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,22 @@ plugins {
|
|||||||
base
|
base
|
||||||
}
|
}
|
||||||
|
|
||||||
val sources by configurations.creating
|
val sources by configurations.creating {
|
||||||
|
attributes {
|
||||||
|
isCanBeResolved = true
|
||||||
|
isCanBeConsumed = false
|
||||||
|
attributes {
|
||||||
|
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
|
||||||
|
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
|
||||||
|
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType.SOURCES))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations["embeddedElements"].isCanBeConsumed = false
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
sources(project(":kotlin-stdlib-common", configuration = "sources"))
|
sources(project(":kotlin-stdlib-common"))
|
||||||
}
|
}
|
||||||
|
|
||||||
val buildSources by tasks.registering(Jar::class) {
|
val buildSources by tasks.registering(Jar::class) {
|
||||||
|
|||||||
@@ -10,7 +10,13 @@ plugins {
|
|||||||
jvmTarget = "1.6"
|
jvmTarget = "1.6"
|
||||||
javaHome = rootProject.extra["JDK_16"] as String
|
javaHome = rootProject.extra["JDK_16"] as String
|
||||||
|
|
||||||
val builtins by configurations.creating
|
val builtins by configurations.creating {
|
||||||
|
isCanBeResolved = true
|
||||||
|
isCanBeConsumed = false
|
||||||
|
attributes {
|
||||||
|
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val runtime by configurations
|
val runtime by configurations
|
||||||
val runtimeJar by configurations.creating {
|
val runtimeJar by configurations.creating {
|
||||||
|
|||||||
@@ -41,7 +41,11 @@ sourceSets {
|
|||||||
configurations {
|
configurations {
|
||||||
commonSources
|
commonSources
|
||||||
longRunningTestCompile.extendsFrom(testCompile)
|
longRunningTestCompile.extendsFrom(testCompile)
|
||||||
builtins
|
builtins {
|
||||||
|
attributes {
|
||||||
|
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements, LibraryElements.JAR))
|
||||||
|
}
|
||||||
|
}
|
||||||
compileOnly.extendsFrom(builtins)
|
compileOnly.extendsFrom(builtins)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,13 @@ plugins {
|
|||||||
|
|
||||||
val JDK_18: String by rootProject.extra
|
val JDK_18: String by rootProject.extra
|
||||||
|
|
||||||
val fatJarContents by configurations.creating
|
val fatJarContents by configurations.creating {
|
||||||
|
isCanBeResolved = true
|
||||||
|
isCanBeConsumed = false
|
||||||
|
attributes {
|
||||||
|
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
|
||||||
|
}
|
||||||
|
}
|
||||||
val fatJarContentsStripMetadata by configurations.creating
|
val fatJarContentsStripMetadata by configurations.creating
|
||||||
val fatJarContentsStripServices by configurations.creating
|
val fatJarContentsStripServices by configurations.creating
|
||||||
val fatJarContentsStripVersions by configurations.creating
|
val fatJarContentsStripVersions by configurations.creating
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ val libraries by configurations.creating {
|
|||||||
|
|
||||||
val jpsPlugin by configurations.creating {
|
val jpsPlugin by configurations.creating {
|
||||||
attributes {
|
attributes {
|
||||||
|
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
|
||||||
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
|
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user