Skip to content

Commit d29602e

Browse files
committed
fix: explicitly set jvm target compatibility
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 7927ad1 commit d29602e

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
}
1111

@@ -41,6 +41,18 @@ subprojects {
4141
}
4242
}
4343

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

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

0 commit comments

Comments
 (0)