Skip to content

Commit 5cc3605

Browse files
committed
0.4 - Java 25, Complex OS Rules, Log Cache Misses, and Java Provisioner 2.0 (#6)
1 parent 3e9e348 commit 5cc3605

31 files changed

+352
-371
lines changed

build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ version = gitversion.tagOffset
1919

2020
println "Version: $version"
2121

22-
// TODO [Mavenizer] Update to Java 25 once ForgeGradle and ForgeDev target Gradle 9.1.0
23-
java.toolchain.languageVersion = JavaLanguageVersion.of(21)
22+
java.toolchain.languageVersion = JavaLanguageVersion.of(25)
2423

2524
dependencies {
2625
compileOnly libs.nulls

gradle/wrapper/gradle-wrapper.jar

1.88 KB
Binary file not shown.

gradlew

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22

33
#
4-
# Copyright © 2015-2021 the original authors.
4+
# Copyright © 2015 the original authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.
@@ -114,7 +114,6 @@ case "$( uname )" in #(
114114
NONSTOP* ) nonstop=true ;;
115115
esac
116116

117-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118117

119118

120119
# Determine the Java command to use to start the JVM.
@@ -172,7 +171,6 @@ fi
172171
# For Cygwin or MSYS, switch paths to Windows format before running java
173172
if "$cygwin" || "$msys" ; then
174173
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
175-
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
176174

177175
JAVACMD=$( cygpath --unix "$JAVACMD" )
178176

@@ -212,8 +210,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
212210

213211
set -- \
214212
"-Dorg.gradle.appname=$APP_BASE_NAME" \
215-
-classpath "$CLASSPATH" \
216-
org.gradle.wrapper.GradleWrapperMain \
213+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
217214
"$@"
218215

219216
# Stop when "xargs" is not available.

gradlew.bat

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,10 @@ goto fail
7070
:execute
7171
@rem Setup the command line
7272

73-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
7473

7574

7675
@rem Execute Gradle
77-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
76+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
7877

7978
:end
8079
@rem End local scope for the variables with windows NT shell

settings.gradle

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,30 @@ gradle.beforeProject { Project project ->
2020
//formatter:off
2121
dependencyResolutionManagement.versionCatalogs.register('libs') {
2222
plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0'
23-
plugin 'gradleutils', 'net.minecraftforge.gradleutils' version '3.3.18'
24-
plugin 'gitversion', 'net.minecraftforge.gitversion' version '3.1.1'
25-
plugin 'changelog', 'net.minecraftforge.changelog' version '3.1.2'
23+
plugin 'gradleutils', 'net.minecraftforge.gradleutils' version '3.3.21'
24+
plugin 'gitversion', 'net.minecraftforge.gitversion' version '3.1.6'
25+
plugin 'changelog', 'net.minecraftforge.changelog' version '3.1.3'
2626
plugin 'shadow', 'com.gradleup.shadow' version '9.2.2'
2727

2828
// Static Analysis
29-
library 'nulls', 'org.jetbrains', 'annotations' version '26.0.2'
29+
library 'nulls', 'org.jetbrains', 'annotations' version '26.0.2-1'
3030

3131
library 'gson', 'com.google.code.gson', 'gson' version '2.10.1'
3232
library 'jopt', 'net.sf.jopt-simple', 'jopt-simple' version '6.0-alpha-3'
33-
library 'jver', 'net.minecraftforge', 'java-provisioner' version '1.0.10'
33+
library 'jver', 'net.minecraftforge', 'java-provisioner' version '2.0.0'
3434
library 'srgutils', 'net.minecraftforge', 'srgutils' version '0.5.14'
3535
library 'diff', 'io.codechicken', 'DiffPatch' version '2.0.0.36' // Fuzzy patching
3636

3737
library 'fastcsv', 'de.siegmar', 'fastcsv' version '3.4.0'
3838
library 'commonsio', 'commons-io', 'commons-io' version '2.18.0'
3939

4040
// Utilities
41-
library 'utils-download', 'net.minecraftforge', 'download-utils' version '0.3.1'
42-
library 'utils-files', 'net.minecraftforge', 'file-utils' version '0.3.1'
43-
library 'utils-hash', 'net.minecraftforge', 'hash-utils' version '0.1.9'
44-
library 'utils-data', 'net.minecraftforge', 'json-data-utils' version '0.2.3'
45-
library 'utils-logging', 'net.minecraftforge', 'log-utils' version '0.3.1'
46-
bundle 'utils', ['utils-download', 'utils-files', 'utils-hash', 'utils-data', 'utils-logging']
41+
library 'utils-download', 'net.minecraftforge', 'download-utils' version '0.4.0'
42+
library 'utils-files', 'net.minecraftforge', 'file-utils' version '0.3.2'
43+
library 'utils-hash', 'net.minecraftforge', 'hash-utils' version '0.1.12'
44+
library 'utils-data', 'net.minecraftforge', 'json-data-utils' version '0.4.0'
45+
library 'utils-logging', 'net.minecraftforge', 'log-utils' version '0.5.0'
46+
library 'utils-os', 'net.minecraftforge', 'os-utils' version '0.1.0'
47+
bundle 'utils', ['utils-download', 'utils-files', 'utils-hash', 'utils-data', 'utils-logging', 'utils-os']
4748
}
4849
//formatter:on

src/main/java/net/minecraftforge/mcmaven/cli/MCPDataTask.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,24 @@
2020
import net.minecraftforge.srgutils.IMappingFile.IField;
2121
import net.minecraftforge.srgutils.IMappingFile.IMethod;
2222
import net.minecraftforge.srgutils.IMappingFile.IParameter;
23-
import net.minecraftforge.util.logging.Log;
23+
import net.minecraftforge.util.logging.Logger;
24+
25+
import static net.minecraftforge.mcmaven.impl.Mavenizer.LOGGER;
2426

2527
// TODO [Mavenizer][MCPDataTask] This is a copy of FG6's ExtractMCPData task.
2628
// its not the best, but I dont want to re-wrok INSTALLER_TOOLS to put the tsrg in the mappings zip
2729
public class MCPDataTask {
2830
public static void run(String[] args) throws Exception {
2931
int ret = runI(args);
3032
if (ret != 0) {
31-
Log.release();
33+
LOGGER.release();
3234
//System.exit(ret);
3335
}
3436
}
3537

3638
private static int runI(String[] args) throws Exception {
3739
// TODO [MCMavenizer] Make this into a --log [level] option
38-
Log.enabled = Log.Level.INFO;
40+
LOGGER.setEnabled(Logger.Level.INFO);
3941

4042
var parser = new OptionParser();
4143
parser.allowsUnrecognizedOptions();
@@ -87,7 +89,7 @@ private static int runI(String[] args) throws Exception {
8789

8890
var options = parser.parse(args);
8991
if (options.has(helpO)) {
90-
parser.printHelpOn(Log.INFO);
92+
parser.printHelpOn(LOGGER.getInfo());
9193
return -1;
9294
}
9395

@@ -103,7 +105,7 @@ private static int runI(String[] args) throws Exception {
103105
null;
104106

105107
if (artifact == null) {
106-
Log.error("Missing mcp --version or --artifact");
108+
LOGGER.error("Missing mcp --version or --artifact");
107109
return -2;
108110
}
109111

@@ -118,19 +120,19 @@ else if (options.has(parchmentO))
118120

119121
var key = options.valueOf(keyO);
120122
if (key == null) {
121-
Log.error("Missing --key option");
123+
LOGGER.error("Missing --key option");
122124
return -3;
123125
}
124126

125127
var repo = new MCPConfigRepo(new Cache(cacheRoot, jdkCacheRoot));
126-
Log.info(" Output: " + output.getAbsolutePath());
127-
Log.info(" Cache: " + cacheRoot.getAbsolutePath());
128-
Log.info(" JDK Cache: " + jdkCacheRoot.getAbsolutePath());
129-
Log.info(" Artifact: " + artifact);
130-
Log.info(" Key: " + key);
128+
LOGGER.info(" Output: " + output.getAbsolutePath());
129+
LOGGER.info(" Cache: " + cacheRoot.getAbsolutePath());
130+
LOGGER.info(" JDK Cache: " + jdkCacheRoot.getAbsolutePath());
131+
LOGGER.info(" Artifact: " + artifact);
132+
LOGGER.info(" Key: " + key);
131133
if (mappings != null)
132-
Log.info(" Mappings: " + mappings);
133-
Log.info();
134+
LOGGER.info(" Mappings: " + mappings);
135+
LOGGER.info();
134136

135137
var mcp = repo.get(artifact);
136138
var side = mcp.getSide("joined");
@@ -141,14 +143,14 @@ else if (options.has(parchmentO))
141143
path = "config/static_methods.txt";
142144

143145
if (path == null) {
144-
Log.error("Could not find data entry for '%s'".formatted(key));
146+
LOGGER.error("Could not find data entry for '%s'".formatted(key));
145147
return -4;
146148
}
147149

148150
try (ZipFile zip = new ZipFile(mcp.getData())) {
149151
var entry = zip.getEntry(path);
150152
if (entry == null) {
151-
Log.error("Invalid config zip, missing file: " + path);
153+
LOGGER.error("Invalid config zip, missing file: " + path);
152154
return -5;
153155
}
154156

src/main/java/net/minecraftforge/mcmaven/cli/MCPTask.java

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,16 @@
2424
import net.minecraftforge.util.data.json.JsonData;
2525
import net.minecraftforge.util.hash.HashFunction;
2626
import net.minecraftforge.util.hash.HashStore;
27-
import net.minecraftforge.util.logging.Log;
27+
import static net.minecraftforge.mcmaven.impl.Mavenizer.LOGGER;
28+
29+
import net.minecraftforge.util.logging.Logger;
2830
import org.jetbrains.annotations.Nullable;
2931

3032
// TODO [Mavenizer][MCPTask] Cleanup. Works well but is a mess.
3133
public class MCPTask {
3234
public static void run(String[] args) throws Exception {
3335
// TODO [MCMavenizer] Make this into a --log [level] option
34-
Log.enabled = Log.Level.INFO;
36+
LOGGER.setEnabled(Logger.Level.INFO);
3537

3638
var parser = new OptionParser();
3739
parser.allowsUnrecognizedOptions();
@@ -100,8 +102,8 @@ public static void run(String[] args) throws Exception {
100102

101103
var options = parser.parse(args);
102104
if (options.has(helpO)) {
103-
parser.printHelpOn(Log.INFO);
104-
Log.release();
105+
parser.printHelpOn(LOGGER.getInfo());
106+
LOGGER.release();
105107
return;
106108
}
107109

@@ -122,24 +124,24 @@ public static void run(String[] args) throws Exception {
122124
var sas = options.has(sasO) ? options.valueOf(sasO) : null;
123125

124126
if (artifact == null) {
125-
Log.error("Missing mcp --version or --artifact");
126-
Log.release();
127+
LOGGER.error("Missing mcp --version or --artifact");
128+
LOGGER.release();
127129
return;
128130
}
129131

130132
var repo = new MCPConfigRepo(new Cache(cacheRoot, jdkCacheRoot));
131-
Log.info(" Output: " + output.getAbsolutePath());
132-
Log.info(" Cache: " + cacheRoot.getAbsolutePath());
133-
Log.info(" JDK Cache: " + jdkCacheRoot.getAbsolutePath());
134-
Log.info(" Artifact: " + artifact);
135-
Log.info(" Pipeline: " + pipeline);
133+
LOGGER.info(" Output: " + output.getAbsolutePath());
134+
LOGGER.info(" Cache: " + cacheRoot.getAbsolutePath());
135+
LOGGER.info(" JDK Cache: " + jdkCacheRoot.getAbsolutePath());
136+
LOGGER.info(" Artifact: " + artifact);
137+
LOGGER.info(" Pipeline: " + pipeline);
136138
if (options.has(rawO)) {
137-
Log.info(" Raw Names: " + (options.has(seargeO) ? "Searge" : "Notch"));
139+
LOGGER.info(" Raw Names: " + (options.has(seargeO) ? "Searge" : "Notch"));
138140
} else {
139-
Log.info(" Access: " + (ats == null ? null : ats.getAbsolutePath()));
140-
Log.info(" SAS: " + (sas == null ? null : sas.getAbsolutePath()));
141+
LOGGER.info(" Access: " + (ats == null ? null : ats.getAbsolutePath()));
142+
LOGGER.info(" SAS: " + (sas == null ? null : sas.getAbsolutePath()));
141143
}
142-
Log.info();
144+
LOGGER.info();
143145

144146
var mcp = repo.get(artifact);
145147
var side = mcp.getSide(pipeline);
@@ -152,13 +154,13 @@ public static void run(String[] args) throws Exception {
152154
Task rawTask = searge ? side.getTasks().getSrgJar() : side.getTasks().getRawJar();
153155
File raw;
154156

155-
Log.info("Creating Raw Jar");
156-
var indent = Log.push();
157+
LOGGER.info("Creating Raw Jar");
158+
var indent = LOGGER.push();
157159
try {
158160
raw = rawTask.execute();
159161
cache.add("raw", raw);
160162
} finally {
161-
Log.pop(indent);
163+
LOGGER.pop(indent);
162164
}
163165

164166
if (!output.exists() || !cache.isSame()) {
@@ -198,21 +200,21 @@ public static void run(String[] args) throws Exception {
198200

199201
File sources = null;
200202
{
201-
Log.info("Creating MCP Source Jar");
202-
var indent = Log.push();
203+
LOGGER.info("Creating MCP Source Jar");
204+
var indent = LOGGER.push();
203205
try {
204206
sources = sourcesTask.execute();
205207
} finally {
206-
Log.pop(indent);
208+
LOGGER.pop(indent);
207209
}
208210
}
209211

210212
var cache = HashStore.fromFile(output)
211213
.add("sources", sources);
212214

213215
if (options.has(mappingsO)) {
214-
Log.info("Renaming MCP Source Jar");
215-
var indent = Log.push();
216+
LOGGER.info("Renaming MCP Source Jar");
217+
var indent = LOGGER.push();
216218
try {
217219
var mappings = options.has(parchmentO)
218220
? new ParchmentMappings(options.valueOf(parchmentO))
@@ -221,7 +223,7 @@ public static void run(String[] args) throws Exception {
221223
var renameTask = new RenameTask(side.getBuildFolder(), pipeline, side, sourcesTask, mappings, false);
222224
sources = renameTask.execute();
223225
} finally {
224-
Log.pop(indent);
226+
LOGGER.pop(indent);
225227
}
226228

227229
cache.add("renamed", sources);
@@ -242,14 +244,14 @@ public static void run(String[] args) throws Exception {
242244
// TODO [Mavenizer][Extra MCPTask Files] do this better
243245
private static void writeFiles(MCPTaskFactory mcpTaskFactory, File output) {
244246
var files = new MCPSetupFiles();
245-
files.versionManifest = mcpTaskFactory.findStep("downloadManifest").execute();
246-
files.versionJson = mcpTaskFactory.findStep("downloadJson").execute();
247-
files.clientRaw = mcpTaskFactory.findStep("downloadClient").execute();
248-
files.serverRaw = mcpTaskFactory.findStep("downloadServer").execute();
249-
files.serverExtracted = mcpTaskFactory.findStep("extractServer").execute();
250-
files.clientMappings = mcpTaskFactory.findStep("downloadClientMappings").execute();
251-
files.serverMappings = mcpTaskFactory.findStep("downloadServerMappings").execute();
252-
files.librariesList = mcpTaskFactory.findStep("listLibraries").execute();
247+
files.versionManifest = mcpTaskFactory.findStep("downloadManifest").execute().getAbsolutePath();
248+
files.versionJson = mcpTaskFactory.findStep("downloadJson").execute().getAbsolutePath();
249+
files.clientRaw = mcpTaskFactory.findStep("downloadClient").execute().getAbsolutePath();
250+
files.serverRaw = mcpTaskFactory.findStep("downloadServer").execute().getAbsolutePath();
251+
files.serverExtracted = mcpTaskFactory.findStep("extractServer").execute().getAbsolutePath();
252+
files.clientMappings = mcpTaskFactory.downloadClientMappings().execute().getAbsolutePath();
253+
files.serverMappings = mcpTaskFactory.downloadServerMappings().execute().getAbsolutePath();
254+
files.librariesList = mcpTaskFactory.findStep("listLibraries").execute().getAbsolutePath();
253255

254256
try {
255257
JsonData.toJson(files, output);

src/main/java/net/minecraftforge/mcmaven/cli/Main.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import joptsimple.OptionParser;
88
import joptsimple.OptionSpecBuilder;
9-
import net.minecraftforge.util.logging.Log;
9+
import static net.minecraftforge.mcmaven.impl.Mavenizer.LOGGER;
1010

1111
import java.time.Duration;
1212
import java.util.ArrayList;
@@ -16,22 +16,22 @@ public class Main {
1616
public static void main(String[] args) throws Exception {
1717
var start = System.nanoTime();
1818
try {
19-
Log.capture();
20-
Log.info(JarVersionInfo.of(DISPLAY_NAME, Main.class).implementation());
19+
LOGGER.capture();
20+
LOGGER.info(JarVersionInfo.of(DISPLAY_NAME, Main.class).implementation());
2121
run(args);
2222
} catch (Throwable e) {
23-
Log.release();
23+
LOGGER.release();
2424
throw e;
2525
}
2626

2727
var time = Duration.ofNanos(System.nanoTime() - start);
28-
if (Log.isCapturing()) {
29-
Log.drop();
30-
Log.INFO.print("Minecraft Maven is up-to-date");
28+
if (LOGGER.isCapturing()) {
29+
LOGGER.drop();
30+
LOGGER.getInfo().print("Minecraft Maven is up-to-date");
3131
} else {
32-
Log.INFO.print("Minecraft Maven has finished");
32+
LOGGER.getInfo().print("Minecraft Maven has finished");
3333
}
34-
Log.INFO.println(String.format(", took %d:%02d.%03d", time.toMinutesPart(), time.toSecondsPart(), time.toMillisPart()));
34+
LOGGER.getInfo().printf(", took %d:%02d.%03d%n", time.toMinutesPart(), time.toSecondsPart(), time.toMillisPart());
3535
}
3636

3737
private static void run(String[] args) throws Exception {
@@ -59,7 +59,7 @@ private static void run(String[] args) throws Exception {
5959
}
6060
}
6161

62-
parser.printHelpOn(Log.INFO);
63-
Log.release();
62+
parser.printHelpOn(LOGGER.getInfo());
63+
LOGGER.release();
6464
}
6565
}

0 commit comments

Comments
 (0)