Skip to content

Commit 999316c

Browse files
committed
variant aware jvm attribute
1 parent 8d81e90 commit 999316c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

build.gradle.kts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE
2+
import org.gradle.api.attributes.java.TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE
13
import org.jetbrains.dokka.gradle.DokkaTask
24

35
plugins {
@@ -20,7 +22,7 @@ dependencies {
2022
implementation(kotlin("stdlib"))
2123
implementation(kotlin("stdlib-jdk8"))
2224

23-
attributesSchema.attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE).compatibilityRules.add(ModularJarCompatibilityRule::class)
25+
attributesSchema.attribute(LIBRARY_ELEMENTS_ATTRIBUTE).compatibilityRules.add(ModularJarCompatibilityRule::class)
2426
components { withModule<ModularKotlinRule>(kotlin("stdlib")) }
2527
components { withModule<ModularKotlinRule>(kotlin("stdlib-jdk8")) }
2628

@@ -80,9 +82,10 @@ artifacts {
8082

8183
// == Add access to the 'modular' variant of kotlin("stdlib"): Put this into a buildSrc plugin and reuse it in all your subprojects
8284
configurations.all {
85+
attributes.attribute(TARGET_JVM_VERSION_ATTRIBUTE, 11)
8386
val n = name.toLowerCase()
8487
if (n.endsWith("compileclasspath") || n.endsWith("runtimeclasspath"))
85-
attributes.attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named("modular-jar"))
88+
attributes.attribute(LIBRARY_ELEMENTS_ATTRIBUTE, objects.named("modular-jar"))
8689
if (n.endsWith("compile") || n.endsWith("runtime"))
8790
isCanBeConsumed = false
8891
}
@@ -104,7 +107,7 @@ abstract class ModularKotlinRule : ComponentMetadataRule {
104107
listOf("compile", "runtime").forEach { baseVariant ->
105108
ctx.details.addVariant("${baseVariant}Modular", baseVariant) {
106109
attributes {
107-
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, getObjects().named("modular-jar"))
110+
attribute(LIBRARY_ELEMENTS_ATTRIBUTE, getObjects().named("modular-jar"))
108111
}
109112
withFiles {
110113
removeAllFiles()

0 commit comments

Comments
 (0)