Skip to content

Commit 13f84fd

Browse files
authored
Merge pull request #146 from KyoriPowered/feat/j11
feat(*): Require a minimum of Java 11 at runtime
2 parents 40d6991 + 06ebd75 commit 13f84fd

File tree

5 files changed

+20
-80
lines changed

5 files changed

+20
-80
lines changed

build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ subprojects {
5050
ci true
5151
}
5252
mitLicense()
53-
javaVersions().testWith(11, 17, 20)
53+
javaVersions {
54+
target 11
55+
minimumToolchain 17
56+
testWith(11, 17, 20)
57+
}
5458

5559
signWithKeyFromPrefixedProperties("kyori")
5660
configurePublications {

gradle/libs.versions.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ gradlePluginPublish = "1.2.1"
88
immutables = "2.9.3"
99
indra = "3.1.2"
1010
jetbrainsAnnotations = "24.0.1"
11-
jgit = "5.13.0.+" # stay on 5.x series, 6+ requires Java 11
11+
jgit = "6.6.0.+" # stay on 5.x series, 6+ requires Java 11
1212
junit = "5.10.0"
1313
kotlin = "1.9.10"
1414
mammoth = "1.3.1"
@@ -48,8 +48,7 @@ gradlePluginPublish = { module = "com.gradle.publish:plugin-publish-plugin", ver
4848
nexusPublishPlugin = { module = "io.github.gradle-nexus:publish-plugin", version = "1.3.0" }
4949

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

5453
# testlib
5554
mammoth-test = { module = "net.kyori:mammoth-test", version.ref = "mammoth" }

indra-common/src/main/java/net/kyori/indra/internal/IndraExtensionImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* This file is part of indra, licensed under the MIT License.
33
*
4-
* Copyright (c) 2020-2022 KyoriPowered
4+
* Copyright (c) 2020-2023 KyoriPowered
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -62,7 +62,7 @@
6262
public class IndraExtensionImpl implements IndraExtension {
6363

6464
private static final Logger LOGGER = Logging.getLogger(IndraExtensionImpl.class);
65-
private static final String DEFAULT_CHECKSTYLE_VERSION = "9.3";
65+
private static final String DEFAULT_CHECKSTYLE_VERSION = "10.12.3";
6666

6767
private final Property<ContinuousIntegration> ci;
6868
private final Property<Issues> issues;
Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,12 @@
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

422
dependencies {
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-
7010
indraPluginPublishing {
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-
}

settings.gradle

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@ dependencyResolutionManagement {
2121

2222
rootProject.name = "indra"
2323

24+
def requiredRuntime = 11
25+
if (JavaVersion.current() < JavaVersion.toVersion(requiredRuntime)) {
26+
throw new GradleException("""\
27+
You are running a Java version that is too old to build Indra.
28+
29+
Required: ${requiredRuntime}
30+
Current: ${JavaVersion.current()}
31+
""".stripIndent())
32+
}
33+
2434
[
2535
"indra-common",
2636
"indra-git",

0 commit comments

Comments
 (0)