Skip to content

Commit dc2fb57

Browse files
JonathingLexManos
authored andcommitted
Update Gradle Wrapper
Buildscripts cleanup, Gradle 8.14
1 parent 6c8e8a5 commit dc2fb57

File tree

11 files changed

+141
-121
lines changed

11 files changed

+141
-121
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,10 @@
77
/**/build/
88
/repo/
99
/cache/
10+
11+
# Tool Output - Jonathan uses the run directory
12+
/run/
13+
/output/
14+
15+
# Jonathan's IntelliJ Fuckery
16+
/.idea/

build.gradle

Lines changed: 57 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,42 +4,46 @@ plugins {
44
id 'java-library'
55
id 'idea'
66
id 'maven-publish'
7-
id 'net.minecraftforge.licenser' version '1.0.1'
8-
id 'net.minecraftforge.gradleutils' version '2.3.6'
9-
id 'com.github.johnrengelman.shadow' version '8.1.1'
10-
}
11-
12-
repositories {
13-
mavenCentral()
7+
alias libs.plugins.licenser
8+
alias libs.plugins.gradleutils
9+
alias libs.plugins.shadow
1410
}
1511

12+
final projectDisplayName = 'Java Version'
13+
final projectVendor = 'Forge Development LLC'
14+
description = 'Java Version management using Disco'
1615
group = 'net.minecraftforge'
16+
version = gitversion.tagOffset
1717

18-
version = gradleutils.tagOffsetVersion
19-
println('Version: ' + version)
18+
println "Version: $version"
19+
20+
java {
21+
// Currently JOpt is the limiting, requiring java 8
22+
// But also toolchains don't support building for anything lower then 8
23+
toolchain.languageVersion = JavaLanguageVersion.of 8
24+
withSourcesJar()
25+
}
2026

21-
tasks.register('createJavaProbeClass', buildsrc.ClassGeneratorTask) { }
27+
tasks.register('createJavaProbeClass', buildsrc.ClassGeneratorTask)
2228

2329
tasks.register('javaProbeJar', Jar) {
2430
destinationDirectory = layout.buildDirectory.dir('libs')
2531
archiveBaseName = project.name
2632
archiveClassifier = 'probe'
33+
2734
manifest {
2835
attributes([
29-
'Main-Class': 'JavaProbe'
30-
] as LinkedHashMap)
31-
attributes([
32-
'Main-Class': 'JavaProbe',
33-
'Specification-Title': 'Java Probe',
34-
'Specification-Vendor': 'Forge Development LLC',
35-
'Specification-Version': gradleutils.gitInfo.tag,
36-
'Implementation-Title': 'javaprobe',
37-
'Implementation-Vendor': 'Forge Development LLC',
36+
'Main-Class' : 'JavaProbe',
37+
'Specification-Title' : 'Java Probe',
38+
'Specification-Vendor' : projectVendor,
39+
'Specification-Version' : gitversion.info.tag,
40+
'Implementation-Title' : 'javaprobe',
41+
'Implementation-Vendor' : projectVendor,
3842
'Implementation-Version': project.version
39-
] as LinkedHashMap)
43+
])
4044
}
4145

42-
from(createJavaProbeClass.outputFile)
46+
from createJavaProbeClass.outputs.files
4347
}
4448

4549
dependencies {
@@ -50,85 +54,69 @@ dependencies {
5054
}
5155

5256
license {
53-
header project.file('LICENSE-header.txt')
57+
header rootProject.file('LICENSE-header.txt')
5458
newLine false
5559
}
5660

57-
java {
58-
// Currently JOpt is the limiting, requiring java 8
59-
// But also toolchains don't support building for anything lower then 8
60-
toolchain.languageVersion = JavaLanguageVersion.of(8)
61-
withSourcesJar()
62-
}
63-
64-
tasks.named('shadowJar', ShadowJar) {
65-
final String reloc = 'net.minecraftforge.java_version.reloc.'
66-
relocate 'joptsimple', reloc + 'jopt'
67-
relocate 'com.google.gson', reloc + 'gson'
68-
relocate 'org.kamranzafar.jtar', reloc + 'jtar'
69-
}
70-
7161
tasks.named('jar', Jar) {
7262
manifest {
7363
attributes([
74-
'Main-Class': 'net.minecraftforge.java_version.Main',
64+
'Main-Class' : 'net.minecraftforge.java_version.Main',
7565
'Automatic-Module-Name': 'net.minecraftforge.java_version',
76-
'Sealed': true
77-
] as LinkedHashMap)
66+
'Sealed' : true
67+
])
7868
attributes([
79-
'Specification-Title': 'Java Version',
80-
'Specification-Vendor': 'Forge Development LLC',
81-
'Specification-Version': gradleutils.gitInfo.tag,
82-
'Implementation-Title': 'Java Version',
83-
'Implementation-Vendor': 'Forge Development LLC',
69+
'Specification-Title' : projectDisplayName,
70+
'Specification-Vendor' : projectVendor,
71+
'Specification-Version' : gitversion.info.tag,
72+
'Implementation-Title' : projectDisplayName,
73+
'Implementation-Vendor' : projectVendor,
8474
'Implementation-Version': project.version
85-
] as LinkedHashMap, 'net/minecraftforge/java_version/')
75+
], 'net/minecraftforge/java_version/')
8676
}
87-
from(createJavaProbeClass.outputFile)
77+
78+
from createJavaProbeClass.outputs.files
8879
}
8980

90-
tasks.named('compileJava', JavaCompile) {
91-
dependsOn javaProbeJar
81+
tasks.named('shadowJar', ShadowJar) {
82+
enableRelocation = true
83+
relocationPrefix = 'net.minecraftforge.java_version.shadow'
84+
}
85+
86+
tasks.withType(JavaCompile).configureEach {
9287
options.encoding = 'UTF-8'
9388
}
9489

9590
changelog {
9691
from '1.0'
9792
}
9893

99-
artifacts {
100-
//archives javaProbeJar
101-
}
102-
10394
publishing {
104-
publications.register('mavenJava', MavenPublication).configure {
105-
artifactId = project.name
95+
publications.register('mavenJava', MavenPublication) {
10696
from components.java
107-
artifact(javaProbeJar)
10897

109-
pom {
110-
name = project.name
111-
description = 'Minecraft Maven Repo Generator'
112-
url = 'https://github.com/MinecraftForge/java-version'
98+
artifactId = project.name
99+
artifact javaProbeJar
100+
101+
pom { pom ->
102+
name = projectDisplayName
103+
description = project.description
113104

114-
gradleutils.pom.setGitHubDetails(pom, 'java-version')
105+
gradleutils.pom.setGitHubDetails pom
115106

116-
license gradleutils.pom.licenses.LGPLv2_1
107+
licenses {
108+
license gradleutils.pom.licenses.LGPLv2_1
109+
}
117110

118111
developers {
119-
developer gradleutils.pom.Developers.LexManos
112+
developer gradleutils.pom.developers.LexManos
120113
}
121114
}
122115
}
116+
123117
repositories {
124118
maven gradleutils.publishingForgeMaven
125119
}
126120
}
127121

128-
idea {
129-
module {
130-
// IntelliJ IDEA does not do this by itself anymore...
131-
downloadJavadoc = true
132-
downloadSources = true
133-
}
134-
}
122+
idea.module { downloadJavadoc = downloadSources = true }

buildSrc/build.gradle

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
plugins {
22
id 'java-library'
3-
id 'net.minecraftforge.licenser' version '1.0.1'
3+
alias libs.plugins.licenser
44
}
55

6-
repositories {
7-
mavenCentral()
8-
}
6+
java.toolchain.languageVersion = JavaLanguageVersion.of 8
97

108
license {
119
header rootProject.file('../LICENSE-header.txt')
@@ -14,7 +12,5 @@ license {
1412

1513
dependencies {
1614
implementation gradleApi()
17-
implementation 'org.ow2.asm:asm:9.7.1'
18-
implementation 'org.ow2.asm:asm-tree:9.7.1'
19-
implementation 'org.ow2.asm:asm-util:9.7.1'
15+
implementation libs.bundles.asm
2016
}

buildSrc/settings.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
dependencyResolutionManagement {
2+
repositories {
3+
mavenCentral()
4+
}
5+
6+
versionCatalogs.register('libs') {
7+
plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0'
8+
9+
// Used to generate a Java 1 compatible class file
10+
version 'asm', '9.7.1'
11+
library 'asm', 'org.ow2.asm', 'asm' versionRef 'asm'
12+
library 'asm-tree', 'org.ow2.asm', 'asm-tree' versionRef 'asm'
13+
library 'asm-util', 'org.ow2.asm', 'asm-util' versionRef 'asm'
14+
bundle 'asm', ['asm', 'asm-tree', 'asm-util']
15+
}
16+
}
17+
18+
rootProject.name = 'java-version'

buildSrc/src/main/java/buildsrc/ClassGeneratorTask.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,33 @@
55
package buildsrc;
66

77
import org.gradle.api.DefaultTask;
8+
import org.gradle.api.file.ProjectLayout;
89
import org.gradle.api.file.RegularFileProperty;
910
import org.gradle.api.tasks.OutputFile;
1011
import org.gradle.api.tasks.TaskAction;
1112

1213
import org.objectweb.asm.ClassVisitor;
1314
import org.objectweb.asm.ClassWriter;
1415
import org.objectweb.asm.MethodVisitor;
16+
17+
import javax.inject.Inject;
18+
1519
import static org.objectweb.asm.Opcodes.*;
1620

1721
import java.io.IOException;
1822
import java.nio.file.Files;
1923
import java.nio.file.Path;
2024
import java.nio.file.StandardOpenOption;
2125

22-
abstract class ClassGeneratorTask extends DefaultTask {
26+
public abstract class ClassGeneratorTask extends DefaultTask {
2327
@OutputFile
24-
abstract RegularFileProperty getOutputFile();
28+
public abstract RegularFileProperty getOutputFile();
29+
30+
@Inject
31+
protected abstract ProjectLayout getLayout();
2532

2633
public ClassGeneratorTask() {
27-
// I don't think this is necessary, as the build cache should use the hash of this compiled class as the cache key
28-
// But just in case, this is how to make it always run.
29-
this.getOutputs().upToDateWhen(t -> false);
30-
this.getOutputFile().convention(this.getProject()
31-
.getLayout()
34+
this.getOutputFile().convention(this.getLayout()
3235
.getBuildDirectory()
3336
.file(this.getName() + "/JavaProbe.class")
3437
);

gradle.properties

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
org.gradle.caching=true
2+
org.gradle.parallel=true
3+
org.gradle.configureondemand=true
4+
5+
# TODO [MCMaven][Gradle9] Enable
6+
#org.gradle.configuration-cache=true
7+
#org.gradle.configuration-cache.parallel=true

gradle/wrapper/gradle-wrapper.jar

303 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

100644100755
Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
8890

8991
# Use the maximum available, or set MAX_FD != -1 to use that value.
9092
MAX_FD=maximum
@@ -112,7 +114,7 @@ case "$( uname )" in #(
112114
NONSTOP* ) nonstop=true ;;
113115
esac
114116

115-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
117+
CLASSPATH="\\\"\\\""
116118

117119

118120
# Determine the Java command to use to start the JVM.
@@ -203,15 +205,15 @@ fi
203205
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204206

205207
# Collect all arguments for the java command:
206-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
208+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207209
# and any embedded shellness will be escaped.
208210
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209211
# treated as '${Hostname}' itself on the command line.
210212

211213
set -- \
212214
"-Dorg.gradle.appname=$APP_BASE_NAME" \
213215
-classpath "$CLASSPATH" \
214-
org.gradle.wrapper.GradleWrapperMain \
216+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
215217
"$@"
216218

217219
# Stop when "xargs" is not available.

0 commit comments

Comments
 (0)