Skip to content

Commit 1f76e1f

Browse files
committed
Manually declare the fatjar as requiring Java 17
For some reason, the ShadowJar plugin doesn't automatically use the same JVM version attribute from the Jar task. This can lead to consumers accidentally resolving the fat-jar instead of the main jar if their language version is incorrectly set or behaving weirdly. Working around this by manually specifying J17 in the shadowRuntimeElements configuration.
1 parent b9855d5 commit 1f76e1f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import org.gradle.api.attributes.java.TargetJvmVersion
12
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
23

34
plugins {
@@ -23,6 +24,12 @@ java {
2324
}
2425

2526
configurations {
27+
named('shadowRuntimeElements') {
28+
attributes {
29+
attribute TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17
30+
}
31+
}
32+
2633
resolvable('shadowOnly') {
2734
description = 'Implementation dependencies that are not declared as required dependencies.'
2835
}

0 commit comments

Comments
 (0)