File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,23 @@ java {
5757 withSourcesJar()
5858}
5959
60+ tasks. register(' jvmVersionAttribute' ) {
61+ description = " Set the correct 'org.gradle.jvm.version' attribute"
62+ def jvmVersionAttribute = Attribute . of(' org.gradle.jvm.version' , Integer )
63+ configurations. each {
64+ if (it. canBeConsumed) {
65+ def categoryAttr = it. attributes. getAttribute(Category . CATEGORY_ATTRIBUTE )
66+ if (categoryAttr != null && categoryAttr. name == Category . LIBRARY ) {
67+ def usageAttr = it. attributes. getAttribute(Usage . USAGE_ATTRIBUTE )
68+ if (usageAttr != null && (usageAttr. name == Usage . JAVA_API
69+ || usageAttr. name == Usage . JAVA_RUNTIME )) {
70+ it. attributes. attribute(jvmVersionAttribute, 8 )
71+ }
72+ }
73+ }
74+ }
75+ }
76+
6077tasks. register(' compileLegacyJava' , JavaCompile ) {
6178 description = ' Compile to Java 8 bytecode, except module-info'
6279 dependsOn tasks. compileJava
You can’t perform that action at this time.
0 commit comments