From 4d92adcacfd951d7489833b57fb8fdd7726b5ab8 Mon Sep 17 00:00:00 2001 From: zml Date: Mon, 28 Aug 2023 16:40:00 -0700 Subject: [PATCH 1/4] feat(*): Require a minimum of Java 11 at runtime Closes GH-115 --- build.gradle | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 8b7b021d..551d7fee 100644 --- a/build.gradle +++ b/build.gradle @@ -50,7 +50,11 @@ subprojects { ci true } mitLicense() - javaVersions().testWith(11, 17, 20) + javaVersions { + target 11 + minimumToolchain 17 + testWith(11, 17, 20) + } signWithKeyFromPrefixedProperties("kyori") configurePublications { From baac487226ae5b31f2bb25578cc4f5ba2cfae23b Mon Sep 17 00:00:00 2001 From: zml Date: Mon, 28 Aug 2023 16:43:00 -0700 Subject: [PATCH 2/4] chore: provide a friendlier error message when running on Java versions that are too old --- settings.gradle | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/settings.gradle b/settings.gradle index 90bf4808..f7ea6727 100644 --- a/settings.gradle +++ b/settings.gradle @@ -21,6 +21,16 @@ dependencyResolutionManagement { rootProject.name = "indra" +def requiredRuntime = 11 +if (JavaVersion.current() < JavaVersion.toVersion(requiredRuntime)) { + throw new GradleException("""\ + You are running a Java version that is too old to build Indra. + + Required: ${requiredRuntime} + Current: ${JavaVersion.current()} + """.stripIndent()) +} + [ "indra-common", "indra-git", From a26b00898c600178f4fa31223fe3a867cb8f2bc8 Mon Sep 17 00:00:00 2001 From: zml Date: Mon, 28 Aug 2023 16:46:32 -0700 Subject: [PATCH 3/4] chore(deps): Bump default versions of eps to versions that require Java 11 --- gradle/libs.versions.toml | 5 +- indra-licenser-spotless/build.gradle | 75 +--------------------------- 2 files changed, 3 insertions(+), 77 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 22ab270d..68a1c156 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -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" @@ -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" } diff --git a/indra-licenser-spotless/build.gradle b/indra-licenser-spotless/build.gradle index a99b518d..ac946dc5 100644 --- a/indra-licenser-spotless/build.gradle +++ b/indra-licenser-spotless/build.gradle @@ -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", @@ -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}) - } -} From 06ebd75a8fe49bf9b51537901d259c07b1dece81 Mon Sep 17 00:00:00 2001 From: zml Date: Mon, 28 Aug 2023 16:58:28 -0700 Subject: [PATCH 4/4] chore(common): Update the default checkstyle version as well --- .../java/net/kyori/indra/internal/IndraExtensionImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra-common/src/main/java/net/kyori/indra/internal/IndraExtensionImpl.java b/indra-common/src/main/java/net/kyori/indra/internal/IndraExtensionImpl.java index ed416023..91cc812e 100644 --- a/indra-common/src/main/java/net/kyori/indra/internal/IndraExtensionImpl.java +++ b/indra-common/src/main/java/net/kyori/indra/internal/IndraExtensionImpl.java @@ -1,7 +1,7 @@ /* * This file is part of indra, licensed under the MIT License. * - * Copyright (c) 2020-2022 KyoriPowered + * Copyright (c) 2020-2023 KyoriPowered * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -62,7 +62,7 @@ public class IndraExtensionImpl implements IndraExtension { private static final Logger LOGGER = Logging.getLogger(IndraExtensionImpl.class); - private static final String DEFAULT_CHECKSTYLE_VERSION = "9.3"; + private static final String DEFAULT_CHECKSTYLE_VERSION = "10.12.3"; private final Property ci; private final Property issues;