Skip to content

Commit 135a912

Browse files
authored
fix: explicitly set jvm target compatibility (#103)
Explicilty set the java source/target compatibility so that the outgoing gradle variant metadata isn't inferred from the JVM version gradle is running with. see: https://docs.gradle.org/current/userguide/variant_attributes.html#sub:jvm_default_attributes fixes: smithy-lang/smithy-kotlin#258
1 parent e14c101 commit 135a912

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

services/build.gradle.kts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
plugins {
77
kotlin("jvm")
8-
`maven`
8+
maven
99
`maven-publish`
1010
id("org.jetbrains.dokka")
1111
}
@@ -43,6 +43,18 @@ subprojects {
4343
}
4444
}
4545

46+
47+
// this is the default but it's better to be explicit (e.g. it may change in Kotlin 1.5)
48+
tasks.compileKotlin {
49+
kotlinOptions.jvmTarget = "1.6"
50+
}
51+
tasks.compileTestKotlin {
52+
kotlinOptions.jvmTarget = "1.6"
53+
}
54+
55+
// FIXME - we can remove this when we implement generated services as multiplatform.
56+
setOutgoingVariantMetadata()
57+
4658
val sourcesJar by tasks.creating(Jar::class) {
4759
group = "publishing"
4860
description = "Assembles Kotlin sources jar"
@@ -65,3 +77,13 @@ subprojects {
6577

6678
apply(from = rootProject.file("gradle/publish.gradle"))
6779
}
80+
81+
82+
// fixes outgoing variant metadata: https://github.com/awslabs/smithy-kotlin/issues/258
83+
fun Project.setOutgoingVariantMetadata() {
84+
tasks.withType<JavaCompile>() {
85+
val javaVersion = JavaVersion.VERSION_1_8.toString()
86+
sourceCompatibility = javaVersion
87+
targetCompatibility = javaVersion
88+
}
89+
}

0 commit comments

Comments
 (0)