Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ version = gitversion.tagOffset

println "Version: $version"

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

dependencies {
compileOnly libs.nulls
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 2 additions & 5 deletions gradlew
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/sh

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

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


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

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

Expand Down Expand Up @@ -212,8 +210,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
"$@"

# Stop when "xargs" is not available.
Expand Down
3 changes: 1 addition & 2 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ goto fail
:execute
@rem Setup the command line

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


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

:end
@rem End local scope for the variables with windows NT shell
Expand Down
25 changes: 13 additions & 12 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,38 @@ gradle.beforeProject { Project project ->
project.repositories {
mavenCentral()
maven project.gradleutils.forgeMaven
//mavenLocal()
mavenLocal()
}
}
}

//formatter:off
dependencyResolutionManagement.versionCatalogs.register('libs') {
plugin 'licenser', 'net.minecraftforge.licenser' version '1.2.0'
plugin 'gradleutils', 'net.minecraftforge.gradleutils' version '3.3.18'
plugin 'gitversion', 'net.minecraftforge.gitversion' version '3.1.1'
plugin 'changelog', 'net.minecraftforge.changelog' version '3.1.2'
plugin 'gradleutils', 'net.minecraftforge.gradleutils' version '3.3.21'
plugin 'gitversion', 'net.minecraftforge.gitversion' version '3.1.6'
plugin 'changelog', 'net.minecraftforge.changelog' version '3.1.3'
plugin 'shadow', 'com.gradleup.shadow' version '9.2.2'

// Static Analysis
library 'nulls', 'org.jetbrains', 'annotations' version '26.0.2'
library 'nulls', 'org.jetbrains', 'annotations' version '26.0.2-1'

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

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

// Utilities
library 'utils-download', 'net.minecraftforge', 'download-utils' version '0.3.1'
library 'utils-files', 'net.minecraftforge', 'file-utils' version '0.3.1'
library 'utils-hash', 'net.minecraftforge', 'hash-utils' version '0.1.9'
library 'utils-data', 'net.minecraftforge', 'json-data-utils' version '0.2.3'
library 'utils-logging', 'net.minecraftforge', 'log-utils' version '0.3.1'
bundle 'utils', ['utils-download', 'utils-files', 'utils-hash', 'utils-data', 'utils-logging']
library 'utils-download', 'net.minecraftforge', 'download-utils' version '0.4.0'
library 'utils-files', 'net.minecraftforge', 'file-utils' version '0.3.2'
library 'utils-hash', 'net.minecraftforge', 'hash-utils' version '0.1.12'
library 'utils-data', 'net.minecraftforge', 'json-data-utils' version '0.4.0'
library 'utils-logging', 'net.minecraftforge', 'log-utils' version '0.5.0'
library 'utils-os', 'net.minecraftforge', 'os-utils' version '0.1.0'
bundle 'utils', ['utils-download', 'utils-files', 'utils-hash', 'utils-data', 'utils-logging', 'utils-os']
}
//formatter:on
32 changes: 17 additions & 15 deletions src/main/java/net/minecraftforge/mcmaven/cli/MCPDataTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,24 @@
import net.minecraftforge.srgutils.IMappingFile.IField;
import net.minecraftforge.srgutils.IMappingFile.IMethod;
import net.minecraftforge.srgutils.IMappingFile.IParameter;
import net.minecraftforge.util.logging.Log;
import net.minecraftforge.util.logging.Logger;

import static net.minecraftforge.mcmaven.impl.Mavenizer.LOGGER;

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

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

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

var options = parser.parse(args);
if (options.has(helpO)) {
parser.printHelpOn(Log.INFO);
parser.printHelpOn(LOGGER.getInfo());
return -1;
}

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

if (artifact == null) {
Log.error("Missing mcp --version or --artifact");
LOGGER.error("Missing mcp --version or --artifact");
return -2;
}

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

var key = options.valueOf(keyO);
if (key == null) {
Log.error("Missing --key option");
LOGGER.error("Missing --key option");
return -3;
}

var repo = new MCPConfigRepo(new Cache(cacheRoot, jdkCacheRoot));
Log.info(" Output: " + output.getAbsolutePath());
Log.info(" Cache: " + cacheRoot.getAbsolutePath());
Log.info(" JDK Cache: " + jdkCacheRoot.getAbsolutePath());
Log.info(" Artifact: " + artifact);
Log.info(" Key: " + key);
LOGGER.info(" Output: " + output.getAbsolutePath());
LOGGER.info(" Cache: " + cacheRoot.getAbsolutePath());
LOGGER.info(" JDK Cache: " + jdkCacheRoot.getAbsolutePath());
LOGGER.info(" Artifact: " + artifact);
LOGGER.info(" Key: " + key);
if (mappings != null)
Log.info(" Mappings: " + mappings);
Log.info();
LOGGER.info(" Mappings: " + mappings);
LOGGER.info();

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

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

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

Expand Down
66 changes: 34 additions & 32 deletions src/main/java/net/minecraftforge/mcmaven/cli/MCPTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@
import net.minecraftforge.util.data.json.JsonData;
import net.minecraftforge.util.hash.HashFunction;
import net.minecraftforge.util.hash.HashStore;
import net.minecraftforge.util.logging.Log;
import static net.minecraftforge.mcmaven.impl.Mavenizer.LOGGER;

import net.minecraftforge.util.logging.Logger;
import org.jetbrains.annotations.Nullable;

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

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

var options = parser.parse(args);
if (options.has(helpO)) {
parser.printHelpOn(Log.INFO);
Log.release();
parser.printHelpOn(LOGGER.getInfo());
LOGGER.release();
return;
}

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

if (artifact == null) {
Log.error("Missing mcp --version or --artifact");
Log.release();
LOGGER.error("Missing mcp --version or --artifact");
LOGGER.release();
return;
}

var repo = new MCPConfigRepo(new Cache(cacheRoot, jdkCacheRoot));
Log.info(" Output: " + output.getAbsolutePath());
Log.info(" Cache: " + cacheRoot.getAbsolutePath());
Log.info(" JDK Cache: " + jdkCacheRoot.getAbsolutePath());
Log.info(" Artifact: " + artifact);
Log.info(" Pipeline: " + pipeline);
LOGGER.info(" Output: " + output.getAbsolutePath());
LOGGER.info(" Cache: " + cacheRoot.getAbsolutePath());
LOGGER.info(" JDK Cache: " + jdkCacheRoot.getAbsolutePath());
LOGGER.info(" Artifact: " + artifact);
LOGGER.info(" Pipeline: " + pipeline);
if (options.has(rawO)) {
Log.info(" Raw Names: " + (options.has(seargeO) ? "Searge" : "Notch"));
LOGGER.info(" Raw Names: " + (options.has(seargeO) ? "Searge" : "Notch"));
} else {
Log.info(" Access: " + (ats == null ? null : ats.getAbsolutePath()));
Log.info(" SAS: " + (sas == null ? null : sas.getAbsolutePath()));
LOGGER.info(" Access: " + (ats == null ? null : ats.getAbsolutePath()));
LOGGER.info(" SAS: " + (sas == null ? null : sas.getAbsolutePath()));
}
Log.info();
LOGGER.info();

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

Log.info("Creating Raw Jar");
var indent = Log.push();
LOGGER.info("Creating Raw Jar");
var indent = LOGGER.push();
try {
raw = rawTask.execute();
cache.add("raw", raw);
} finally {
Log.pop(indent);
LOGGER.pop(indent);
}

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

File sources = null;
{
Log.info("Creating MCP Source Jar");
var indent = Log.push();
LOGGER.info("Creating MCP Source Jar");
var indent = LOGGER.push();
try {
sources = sourcesTask.execute();
} finally {
Log.pop(indent);
LOGGER.pop(indent);
}
}

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

if (options.has(mappingsO)) {
Log.info("Renaming MCP Source Jar");
var indent = Log.push();
LOGGER.info("Renaming MCP Source Jar");
var indent = LOGGER.push();
try {
var mappings = options.has(parchmentO)
? new ParchmentMappings(options.valueOf(parchmentO))
Expand All @@ -221,7 +223,7 @@ public static void run(String[] args) throws Exception {
var renameTask = new RenameTask(side.getBuildFolder(), pipeline, side, sourcesTask, mappings, false);
sources = renameTask.execute();
} finally {
Log.pop(indent);
LOGGER.pop(indent);
}

cache.add("renamed", sources);
Expand All @@ -242,14 +244,14 @@ public static void run(String[] args) throws Exception {
// TODO [Mavenizer][Extra MCPTask Files] do this better
private static void writeFiles(MCPTaskFactory mcpTaskFactory, File output) {
var files = new MCPSetupFiles();
files.versionManifest = mcpTaskFactory.findStep("downloadManifest").execute();
files.versionJson = mcpTaskFactory.findStep("downloadJson").execute();
files.clientRaw = mcpTaskFactory.findStep("downloadClient").execute();
files.serverRaw = mcpTaskFactory.findStep("downloadServer").execute();
files.serverExtracted = mcpTaskFactory.findStep("extractServer").execute();
files.clientMappings = mcpTaskFactory.findStep("downloadClientMappings").execute();
files.serverMappings = mcpTaskFactory.findStep("downloadServerMappings").execute();
files.librariesList = mcpTaskFactory.findStep("listLibraries").execute();
files.versionManifest = mcpTaskFactory.findStep("downloadManifest").execute().getAbsolutePath();
files.versionJson = mcpTaskFactory.findStep("downloadJson").execute().getAbsolutePath();
files.clientRaw = mcpTaskFactory.findStep("downloadClient").execute().getAbsolutePath();
files.serverRaw = mcpTaskFactory.findStep("downloadServer").execute().getAbsolutePath();
files.serverExtracted = mcpTaskFactory.findStep("extractServer").execute().getAbsolutePath();
files.clientMappings = mcpTaskFactory.downloadClientMappings().execute().getAbsolutePath();
files.serverMappings = mcpTaskFactory.downloadServerMappings().execute().getAbsolutePath();
files.librariesList = mcpTaskFactory.findStep("listLibraries").execute().getAbsolutePath();

try {
JsonData.toJson(files, output);
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/net/minecraftforge/mcmaven/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import joptsimple.OptionParser;
import joptsimple.OptionSpecBuilder;
import net.minecraftforge.util.logging.Log;
import static net.minecraftforge.mcmaven.impl.Mavenizer.LOGGER;

import java.time.Duration;
import java.util.ArrayList;
Expand All @@ -16,22 +16,22 @@ public class Main {
public static void main(String[] args) throws Exception {
var start = System.nanoTime();
try {
Log.capture();
Log.info(JarVersionInfo.of(DISPLAY_NAME, Main.class).implementation());
LOGGER.capture();
LOGGER.info(JarVersionInfo.of(DISPLAY_NAME, Main.class).implementation());
run(args);
} catch (Throwable e) {
Log.release();
LOGGER.release();
throw e;
}

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

private static void run(String[] args) throws Exception {
Expand Down Expand Up @@ -59,7 +59,7 @@ private static void run(String[] args) throws Exception {
}
}

parser.printHelpOn(Log.INFO);
Log.release();
parser.printHelpOn(LOGGER.getInfo());
LOGGER.release();
}
}
Loading