mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-10 08:31:29 +00:00
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
|
||||
javaHome = defaultJavaHome
|
||||
|
||||
|
||||
@@ -11,6 +11,14 @@ val builtinsNative = fileFrom(rootDir, "core", "builtins", "native")
|
||||
val kotlinReflect = fileFrom(rootDir, "libraries/stdlib/src/kotlin/reflect")
|
||||
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) {
|
||||
from(kotlinReflect) {
|
||||
exclude("typeOf.kt")
|
||||
@@ -47,7 +55,7 @@ val assemble by tasks.getting {
|
||||
dependsOn(serialize)
|
||||
}
|
||||
|
||||
val builtinsJarArtifact = artifacts.add("default", builtinsJar)
|
||||
val builtinsJarArtifact = artifacts.add(runtimeElements.name, builtinsJar)
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
|
||||
10
dependencies/tools-jar-api/build.gradle.kts
vendored
10
dependencies/tools-jar-api/build.gradle.kts
vendored
@@ -10,6 +10,14 @@ plugins {
|
||||
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 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)
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,13 @@ plugins {
|
||||
}
|
||||
|
||||
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 fatJarContentsStripServices by configurations.creating
|
||||
|
||||
|
||||
@@ -2,10 +2,22 @@ plugins {
|
||||
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 {
|
||||
sources(project(":kotlin-stdlib-common", configuration = "sources"))
|
||||
sources(project(":kotlin-stdlib-common"))
|
||||
}
|
||||
|
||||
val buildSources by tasks.registering(Jar::class) {
|
||||
|
||||
@@ -10,7 +10,13 @@ plugins {
|
||||
jvmTarget = "1.6"
|
||||
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 runtimeJar by configurations.creating {
|
||||
|
||||
@@ -41,7 +41,11 @@ sourceSets {
|
||||
configurations {
|
||||
commonSources
|
||||
longRunningTestCompile.extendsFrom(testCompile)
|
||||
builtins
|
||||
builtins {
|
||||
attributes {
|
||||
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements, LibraryElements.JAR))
|
||||
}
|
||||
}
|
||||
compileOnly.extendsFrom(builtins)
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,13 @@ plugins {
|
||||
|
||||
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 fatJarContentsStripServices by configurations.creating
|
||||
val fatJarContentsStripVersions by configurations.creating
|
||||
|
||||
@@ -145,6 +145,7 @@ val libraries by configurations.creating {
|
||||
|
||||
val jpsPlugin by configurations.creating {
|
||||
attributes {
|
||||
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
|
||||
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user