Skip to content

Commit

Permalink
chore(deps): Bump default versions of eps to versions that require Ja…
Browse files Browse the repository at this point in the history
…va 11
  • Loading branch information
zml2008 committed Aug 28, 2023
1 parent baac487 commit a26b008
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 77 deletions.
5 changes: 2 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gradlePluginPublish = "1.2.1"
immutables = "2.9.3"
indra = "3.1.2"
jetbrainsAnnotations = "24.0.1"
jgit = "5.13.0.+" # stay on 5.x series, 6+ requires Java 11
jgit = "6.6.0.+" # stay on 5.x series, 6+ requires Java 11
junit = "5.10.0"
kotlin = "1.9.10"
mammoth = "1.3.1"
Expand Down Expand Up @@ -48,8 +48,7 @@ gradlePluginPublish = { module = "com.gradle.publish:plugin-publish-plugin", ver
nexusPublishPlugin = { module = "io.github.gradle-nexus:publish-plugin", version = "1.3.0" }

# spotless-licenser
spotlessLegacy = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "6.13.0" } # build against this, for J8 support
spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" } # published as a dep on a special J11+ variant
spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "spotless" }

# testlib
mammoth-test = { module = "net.kyori:mammoth-test", version.ref = "mammoth" }
Expand Down
75 changes: 1 addition & 74 deletions indra-licenser-spotless/build.gradle
Original file line number Diff line number Diff line change
@@ -1,72 +1,12 @@
import org.gradle.api.attributes.java.TargetJvmVersion
import org.gradle.api.plugins.internal.JavaConfigurationVariantMapping

static def transferAttributes(HasAttributes src, HasAttributes dest) {
def destAttrs = dest.attributes
src.attributes.keySet().each {
destAttrs.attribute(it, src.attributes.getAttribute(it))
}
}

def duplicateConfiguration(Configuration src, String name, Configuration parent) {
configurations.create(name) {
canBeConsumed = true
canBeResolved = false
visible = true

transferAttributes(src, delegate)
attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 11)

outgoing.variants.addAll(src.outgoing.variants)
outgoing.variants.configureEach {
it.attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 11)
}
artifacts.addAll(src.artifacts)

src.incoming.dependencies.each {
if (it.group != "com.diffplug.spotless") { // yikes
project.dependencies.add(name, it)
}
}
extendsFrom parent
}
}

configurations {
java11Deps {
canBeConsumed = false
canBeResolved = true
}
}

dependencies {
compileOnlyApi libs.jetbrainsAnnotations
api libs.mammoth
api libs.spotlessLegacy
java11Deps libs.spotless
api libs.spotless
testImplementation project(":indra-testlib")
testImplementation libs.spotless
}

configurations {
// must be after dep declaration because we eagerly read declared deps
duplicateConfiguration(apiElements, 'java11ApiElements', java11Deps)
duplicateConfiguration(runtimeElements, 'java11RuntimeElements', java11Deps)

[testCompileClasspath, testRuntimeClasspath].each {
it.attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 11)
}
}
}

components.java {
// This is technically internal api but because it's our own buildscript we can just update as needed
// and it's easier than matching their logic
addVariantsFromConfiguration(configurations.java11ApiElements, new JavaConfigurationVariantMapping('compile', true))
addVariantsFromConfiguration(configurations.java11RuntimeElements, new JavaConfigurationVariantMapping('runtime', true))
}

indraPluginPublishing {
plugin(
"indra.licenser.spotless",
Expand All @@ -76,16 +16,3 @@ indraPluginPublishing {
["indra", "licenser", "license-header", "spotless"]
)
}

tasks.named('pluginUnderTestMetadata', PluginUnderTestMetadata).configure {
pluginClasspath.setFrom(sourceSets.main.output, configurations.java11Deps, configurations.runtimeClasspath)
}

indra {
javaVersions {
// TODO(4): remove this since we'll target 11
def oldTestWith = testWith().get()
testWith().empty()
testWith().addAll(oldTestWith.findAll { it != 8})
}
}

0 comments on commit a26b008

Please sign in to comment.