Skip to content

Commit 7878c1d

Browse files
authored
Cleanup Gradle buildscripts and fix deprecations (#73)
1 parent 3aac87f commit 7878c1d

File tree

8 files changed

+109
-123
lines changed

8 files changed

+109
-123
lines changed

build.gradle

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
import net.minecraftforge.gradleutils.PomUtils
21
import net.ltgt.gradle.errorprone.ErrorProneOptions
32
import net.ltgt.gradle.nullaway.NullAwayOptions
43

54
plugins {
65
id 'java-library'
76
id 'maven-publish'
8-
id 'org.gradlex.extra-java-module-info' version '1.11'
9-
id 'net.minecraftforge.gradleutils' version '2.4.13'
10-
id 'net.minecraftforge.licenser' version '1.1.1'
7+
alias libs.plugins.modules
8+
alias libs.plugins.gradleutils
9+
alias libs.plugins.licenser
1110

1211
// Enforce jSpecify annotations at compile-time
13-
id 'net.ltgt.errorprone' version '4.1.0'
14-
id 'net.ltgt.nullaway' version '2.2.0'
12+
alias libs.plugins.errorprone
13+
alias libs.plugins.nullaway
1514
}
1615

16+
final projectDisplayName = 'EventBus'
17+
final projectVendor = 'Forge Development LLC'
18+
description = 'High performance Event Bus library'
1719
group = 'net.minecraftforge'
18-
version = gitversion.version.tagOffset
20+
version = gitversion.tagOffset
21+
1922
print "Version: $version"
2023

2124
java {
@@ -24,11 +27,6 @@ java {
2427
withSourcesJar()
2528
}
2629

27-
repositories {
28-
mavenCentral()
29-
maven gradleutils.forgeMaven
30-
}
31-
3230
dependencies {
3331
api libs.jspecify.annotations
3432
errorprone libs.errorprone.core
@@ -56,19 +54,19 @@ tasks.withType(JavaCompile).configureEach {
5654
}
5755

5856
// Enforce the ErrorProne checks we care about
59-
errorProne.error("FieldCanBeFinal", "MethodCanBeStatic", "LambdaFunctionalInterface")
57+
errorProne.error 'FieldCanBeFinal', 'MethodCanBeStatic', 'LambdaFunctionalInterface'
6058
}
6159
}
6260

6361
tasks.named('jar', Jar) {
6462
manifest {
6563
attributes([
66-
'Specification-Title': 'EventBus',
67-
'Specification-Version': gitversion.version.info.tag,
68-
'Specification-Vendor': 'Forge Development LLC',
69-
'Implementation-Title': 'EventBus',
64+
'Specification-Title' : projectDisplayName,
65+
'Specification-Version' : gitversion.info.tag,
66+
'Specification-Vendor' : projectVendor,
67+
'Implementation-Title' : projectDisplayName,
7068
'Implementation-Version': project.version,
71-
'Implementation-Vendor': 'Forge Development LLC'
69+
'Implementation-Vendor' : projectVendor
7270
])
7371
}
7472

@@ -77,7 +75,7 @@ tasks.named('jar', Jar) {
7775
}
7876

7977
license {
80-
header = file("LICENSE-header.txt")
78+
header = file('LICENSE-header.txt')
8179
newLine = false
8280
}
8381

@@ -86,15 +84,17 @@ publishing {
8684
from components.java
8785
artifactId = 'eventbus'
8886
pom {
89-
name = 'EventBus'
90-
description = 'High performance Event Bus library'
87+
name = projectDisplayName
88+
description = project.description
9189

9290
gradleutils.pom.gitHubDetails = pom
9391

94-
license PomUtils.Licenses.LGPLv2_1
92+
licenses {
93+
license gradleutils.pom.licenses.LGPLv2_1
94+
}
9595

9696
developers {
97-
developer PomUtils.Developers.Paint_Ninja
97+
developer gradleutils.pom.developers.Paint_Ninja
9898
}
9999
}
100100
}
@@ -105,17 +105,17 @@ publishing {
105105
}
106106

107107
allprojects {
108-
ext.VALID_VMS = [
109-
'Adoptium': [21],
110-
'Amazon': [21],
111-
'Azul': (21),
112-
'BellSoft': (21),
113-
'Graal_VM': [21],
114-
'Microsoft': [21],
115-
'Oracle': (21),
116-
]
117-
118108
// Tests are expensive to run all variants, so only run if asked to
119109
if (!project.hasProperty('bulk_tests'))
120110
ext.VALID_VMS = ['Adoptium': [21]]
111+
else
112+
ext.VALID_VMS = [
113+
'Adoptium': [21],
114+
'Amazon': [21],
115+
'Azul': [21],
116+
'BellSoft': [21],
117+
'Graal_VM': [21],
118+
'Microsoft': [21],
119+
'Oracle': [21],
120+
]
121121
}

buildSrc/build.gradle

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@ plugins {
22
id 'groovy'
33
}
44

5-
repositories {
6-
mavenCentral()
7-
maven { url = 'https://jitpack.io' }
8-
}
9-
105
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
116

127
dependencies {
13-
implementation 'com.github.Steppschuh:Java-Markdown-Generator:1.3.2'
8+
implementation libs.markdown.generator
149
}

buildSrc/settings.gradle

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
rootProject.name = 'buildSrc'
2+
3+
dependencyResolutionManagement {
4+
repositories {
5+
mavenCentral()
6+
maven { url = 'https://jitpack.io' }
7+
}
8+
9+
versionCatalogs.register('libs') {
10+
library 'markdown-generator', 'com.github.Steppschuh', 'Java-Markdown-Generator' version '1.3.2'
11+
}
12+
}

buildSrc/src/main/groovy/ArchiveJfr.groovy

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
import groovy.xml.DOMBuilder
2-
import groovy.xml.dom.DOMCategory
31
import org.gradle.api.DefaultTask
42
import org.gradle.api.file.DirectoryProperty
5-
import org.gradle.api.file.RegularFileProperty
63
import org.gradle.api.tasks.InputDirectory
74
import org.gradle.api.tasks.OutputDirectory
8-
import org.gradle.api.tasks.OutputFile
95
import org.gradle.api.tasks.TaskAction
106

117
import java.nio.file.Files
12-
import java.nio.file.StandardCopyOption
138

149
abstract class ArchiveJfr extends DefaultTask {
1510
@InputDirectory

eventbus-jmh/build.gradle

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
plugins {
22
id 'java-library'
3-
id 'org.gradlex.extra-java-module-info'
4-
id 'net.minecraftforge.gradleutils'
5-
id 'net.minecraftforge.licenser'
6-
}
7-
8-
repositories {
9-
mavenCentral()
10-
maven gradleutils.forgeMaven
3+
alias libs.plugins.modules
4+
alias libs.plugins.gradleutils
5+
alias libs.plugins.licenser
116
}
127

138
java {
149
toolchain.languageVersion = JavaLanguageVersion.of(21)
1510
}
1611

1712
license {
18-
header = rootProject.file("LICENSE-header.txt")
13+
header = rootProject.file('LICENSE-header.txt')
1914
newLine = false
2015
}
2116

@@ -33,7 +28,6 @@ dependencies {
3328
extraJavaModuleInfo {
3429
failOnMissingModuleInfo = false
3530
automaticModule('org.openjdk.jmh:jmh-core', 'jmh.core')
36-
automaticModule('net.sf.jopt-simple:jopt-simple', 'jopt.simple')
3731
}
3832

3933
tasks.register('aggregateJmh', AggregateJmh) {

eventbus-test-jar/build.gradle

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
11
plugins {
22
id 'eclipse'
33
id 'java-library'
4-
id 'org.gradlex.extra-java-module-info'
5-
id 'net.minecraftforge.gradleutils'
6-
id 'net.minecraftforge.licenser'
7-
}
8-
9-
repositories {
10-
mavenCentral()
11-
maven gradleutils.forgeMaven
4+
alias libs.plugins.modules
5+
alias libs.plugins.gradleutils
6+
alias libs.plugins.licenser
127
}
138

149
java {
1510
toolchain.languageVersion = JavaLanguageVersion.of(21)
1611
}
1712

1813
dependencies {
19-
implementation(rootProject)
20-
implementation(libs.bundles.asm)
21-
implementation(libs.unsafe)
14+
implementation rootProject
15+
implementation libs.bundles.asm
16+
implementation libs.unsafe
2217

2318
implementation libs.jmh.core
2419
}
@@ -29,7 +24,7 @@ extraJavaModuleInfo {
2924
}
3025

3126
license {
32-
header = rootProject.file("LICENSE-header.txt")
27+
header = rootProject.file('LICENSE-header.txt')
3328
newLine = false
3429
}
3530

eventbus-test/build.gradle

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
plugins {
22
id 'eclipse'
33
id 'java-library'
4-
id 'net.minecraftforge.gradleutils'
5-
id 'net.minecraftforge.licenser'
6-
id 'org.gradlex.extra-java-module-info'
4+
alias libs.plugins.gradleutils
5+
alias libs.plugins.licenser
6+
alias libs.plugins.modules
77
id 'test-report-aggregation'
88
}
99

10-
repositories {
11-
mavenCentral()
12-
maven gradleutils.forgeMaven
13-
}
14-
1510
java {
1611
toolchain.languageVersion = JavaLanguageVersion.of(21)
1712
}
1813

1914
license {
20-
header = rootProject.file("LICENSE-header.txt")
15+
header = rootProject.file('LICENSE-header.txt')
2116
newLine = false
2217
}
2318

@@ -48,13 +43,15 @@ tasks.register('testAll', AggregateTest) {
4843
output.mkdirs()
4944
var task = tasks.register("test${javaVendor}${javaVersion}", Test) {
5045
useJUnitPlatform()
46+
classpath = configurations.runtimeClasspath
47+
testClassesDirs = sourceSets.main.output.classesDirs
5148
javaLauncher = javaToolchains.launcherFor {
5249
vendor = JvmVendorSpec."${javaVendor.toUpperCase(Locale.ROOT)}" as JvmVendorSpec
5350
languageVersion = JavaLanguageVersion.of(javaVersion)
5451
implementation = JvmImplementation.VENDOR_SPECIFIC
5552
}
56-
reports.html.destination = file("build/test-reports/${javaVendor}-${javaVersion}/")
57-
reports.junitXml.destination = output
53+
reports.html.outputLocation.fileValue file("build/test-reports/${javaVendor}-${javaVersion}/")
54+
reports.junitXml.outputLocation.fileValue output
5855
}
5956
tasks.named('testAll') {
6057
inputs.dir(output)

settings.gradle

Lines changed: 44 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,53 @@
1-
pluginManagement {
1+
plugins {
2+
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.10.0'
3+
}
4+
5+
dependencyResolutionManagement {
26
repositories {
3-
gradlePluginPortal()
7+
// TODO [Gradle9][GradleUtils3] Replace with gradleutils.forgeMaven
48
maven { url = 'https://maven.minecraftforge.net/' }
9+
mavenCentral()
510
}
6-
}
711

8-
plugins {
9-
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.9.0'
10-
}
12+
//@formatter:off
13+
versionCatalogs.register('libs') {
14+
plugin 'modules', 'org.gradlex.extra-java-module-info' version '1.11'
15+
plugin 'gradleutils', 'net.minecraftforge.gradleutils' version '2.5.1'
16+
plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0'
1117

12-
dependencyResolutionManagement {
13-
versionCatalogs {
14-
libs {
15-
// https://mvnrepository.com/artifact/org.jspecify/jspecify
16-
library('jspecify-annotations', 'org.jspecify', 'jspecify') version '1.0.0'
17-
18-
// https://mvnrepository.com/artifact/com.google.errorprone/error_prone_core
19-
library('errorprone-core', 'com.google.errorprone', 'error_prone_core') version '2.36.0'
20-
21-
// https://mvnrepository.com/artifact/com.uber.nullaway/nullaway
22-
library('nullaway', 'com.uber.nullaway', 'nullaway') version '0.12.4'
23-
24-
// ModLauncher stack
25-
library('modlauncher', 'net.minecraftforge:modlauncher:10.1.1')
26-
library('securemodules', 'net.minecraftforge:securemodules:2.2.21')
27-
library('unsafe', 'net.minecraftforge:unsafe:0.9.2')
28-
29-
// Generics from lambdas
30-
library('typetools', 'net.jodah:typetools:0.6.3')
31-
32-
library('nulls', 'org.jetbrains:annotations:23.0.0')
33-
library('jopt-simple', 'net.sf.jopt-simple:jopt-simple:5.0.4')
34-
library('log4j-api', 'org.apache.logging.log4j:log4j-api:2.17.1')
35-
36-
version('junit', '5.10.1')
37-
library('junit-api', 'org.junit.jupiter', 'junit-jupiter-api').versionRef('junit')
38-
library('junit-engine', 'org.junit.jupiter', 'junit-jupiter-engine').versionRef('junit')
39-
library('junit-platform-launcher', 'org.junit.platform:junit-platform-launcher:1.10.1')
40-
bundle('junit-runtime', ['junit-engine', 'junit-platform-launcher'])
41-
42-
version('asm', '9.7.1')
43-
library('asm', 'org.ow2.asm', 'asm' ).versionRef('asm')
44-
library('asm-tree', 'org.ow2.asm', 'asm-tree' ).versionRef('asm')
45-
library('asm-commons', 'org.ow2.asm', 'asm-commons').versionRef('asm')
46-
bundle('asm', ['asm', 'asm-tree', 'asm-commons'])
47-
48-
version('jmh', '1.37')
49-
library('jmh-core', 'org.openjdk.jmh', 'jmh-core') versionRef 'jmh'
50-
library('jmh-annotationProcessor', 'org.openjdk.jmh', 'jmh-generator-annprocess') versionRef 'jmh'
51-
}
18+
plugin 'errorprone', 'net.ltgt.errorprone' version '4.1.0'
19+
plugin 'nullaway', 'net.ltgt.nullaway' version '2.2.0'
20+
21+
// https://mvnrepository.com/artifact/org.jspecify/jspecify
22+
library 'jspecify-annotations', 'org.jspecify', 'jspecify' version '1.0.0'
23+
24+
// https://mvnrepository.com/artifact/com.google.errorprone/error_prone_core
25+
library 'errorprone-core', 'com.google.errorprone', 'error_prone_core' version '2.36.0'
26+
27+
// https://mvnrepository.com/artifact/com.uber.nullaway/nullaway
28+
library 'nullaway', 'com.uber.nullaway', 'nullaway' version '0.12.4'
29+
30+
31+
/* The rest is for testing */
32+
library 'unsafe', 'net.minecraftforge:unsafe:0.9.2'
33+
34+
version 'junit', '5.10.1'
35+
library 'junit-api', 'org.junit.jupiter', 'junit-jupiter-api' versionRef 'junit'
36+
library 'junit-engine', 'org.junit.jupiter', 'junit-jupiter-engine' versionRef 'junit'
37+
library 'junit-platform-launcher', 'org.junit.platform', 'junit-platform-launcher' version '1.10.1'
38+
bundle 'junit-runtime', ['junit-engine', 'junit-platform-launcher']
39+
40+
version 'asm', '9.7.1'
41+
library 'asm', 'org.ow2.asm', 'asm' versionRef 'asm'
42+
library 'asm-tree', 'org.ow2.asm', 'asm-tree' versionRef 'asm'
43+
library 'asm-commons', 'org.ow2.asm', 'asm-commons' versionRef 'asm'
44+
bundle 'asm', ['asm', 'asm-tree', 'asm-commons']
45+
46+
version 'jmh', '1.37'
47+
library 'jmh-core', 'org.openjdk.jmh', 'jmh-core' versionRef 'jmh'
48+
library 'jmh-annotationProcessor', 'org.openjdk.jmh', 'jmh-generator-annprocess' versionRef 'jmh'
5249
}
50+
//@formatter:on
5351
}
5452

5553
enableFeaturePreview 'TYPESAFE_PROJECT_ACCESSORS'

0 commit comments

Comments
 (0)