1- import org.gradle.api.attributes.java.TargetJvmVersion
2- import org.gradle.api.plugins.internal.JavaConfigurationVariantMapping
3-
4- static def transferAttributes (HasAttributes src , HasAttributes dest ) {
5- def destAttrs = dest. attributes
6- src. attributes. keySet(). each {
7- destAttrs. attribute(it, src. attributes. getAttribute(it))
8- }
9- }
10-
11- def duplicateConfiguration (Configuration src , String name , Configuration parent ) {
12- configurations. create(name) {
13- canBeConsumed = true
14- canBeResolved = false
15- visible = true
16-
17- transferAttributes(src, delegate)
18- attributes. attribute(TargetJvmVersion . TARGET_JVM_VERSION_ATTRIBUTE , 11 )
19-
20- outgoing. variants. addAll(src. outgoing. variants)
21- outgoing. variants. configureEach {
22- it. attributes. attribute(TargetJvmVersion . TARGET_JVM_VERSION_ATTRIBUTE , 11 )
23- }
24- artifacts. addAll(src. artifacts)
25-
26- src. incoming. dependencies. each {
27- if (it. group != " com.diffplug.spotless" ) { // yikes
28- project. dependencies. add(name, it)
29- }
30- }
31- extendsFrom parent
32- }
33- }
34-
35- configurations {
36- java11Deps {
37- canBeConsumed = false
38- canBeResolved = true
39- }
40- }
411
422dependencies {
433 compileOnlyApi libs. jetbrainsAnnotations
444 api libs. mammoth
45- api libs. spotlessLegacy
46- java11Deps libs. spotless
5+ api libs. spotless
476 testImplementation project(" :indra-testlib" )
487 testImplementation libs. spotless
498}
509
51- configurations {
52- // must be after dep declaration because we eagerly read declared deps
53- duplicateConfiguration(apiElements, ' java11ApiElements' , java11Deps)
54- duplicateConfiguration(runtimeElements, ' java11RuntimeElements' , java11Deps)
55-
56- [testCompileClasspath, testRuntimeClasspath]. each {
57- it. attributes {
58- attribute(TargetJvmVersion . TARGET_JVM_VERSION_ATTRIBUTE , 11 )
59- }
60- }
61- }
62-
63- components. java {
64- // This is technically internal api but because it's our own buildscript we can just update as needed
65- // and it's easier than matching their logic
66- addVariantsFromConfiguration(configurations. java11ApiElements, new JavaConfigurationVariantMapping (' compile' , true ))
67- addVariantsFromConfiguration(configurations. java11RuntimeElements, new JavaConfigurationVariantMapping (' runtime' , true ))
68- }
69-
7010indraPluginPublishing {
7111 plugin(
7212 " indra.licenser.spotless" ,
@@ -76,16 +16,3 @@ indraPluginPublishing {
7616 [" indra" , " licenser" , " license-header" , " spotless" ]
7717 )
7818}
79-
80- tasks. named(' pluginUnderTestMetadata' , PluginUnderTestMetadata ). configure {
81- pluginClasspath. setFrom(sourceSets. main. output, configurations. java11Deps, configurations. runtimeClasspath)
82- }
83-
84- indra {
85- javaVersions {
86- // TODO(4): remove this since we'll target 11
87- def oldTestWith = testWith(). get()
88- testWith(). empty()
89- testWith(). addAll(oldTestWith. findAll { it != 8 })
90- }
91- }
0 commit comments