Skip to content
Merged
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
44 changes: 44 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Test

on:
pull_request:
#push:
# branches: [ 'master' ]
# paths-ignore:
# - '.github/workflows/**'
# - 'README.md'

permissions:
contents: read

jobs:
test:
continue-on-error: true
strategy:
matrix:
command: [
"--forge --version 1.21.11-61.1.0",
"--forge --version 1.20.1-47.4.0",
"--forge --version 1.12.2-14.23.5.2859 --mappings snapshot:20171003-1.12",
"--client --version 1.20.1",
"--server --version 1.20.1",
"--mc --version 1.20.1",
"--client --version 26.1-snapshot-1",
"--server --version 26.1-snapshot-1"
]

runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v6
with:
fetch-tags: true
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 25
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Test Run
run: ./gradlew run --args="--debug ${{ matrix.command }}"
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import org.gradle.api.plugins.jvm.JvmTestSuite
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar

plugins {
id 'java'
id 'application'
id 'jvm-test-suite'
id 'idea'
id 'eclipse'
Expand Down Expand Up @@ -52,6 +52,10 @@ license {
exclude '**/ComparableVersion.java' // Apache class used as source-level dep as to not need the hundred+ other classes the library pulls in
}

application {
mainClass = 'net.minecraftforge.mcmaven.cli.Main'
}

tasks.named('jar', Jar) {
manifest {
attributes([
Expand Down
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencyResolutionManagement.versionCatalogs.register('libs') {
// Utilities
library 'utils-download', 'net.minecraftforge', 'download-utils' version '0.4.0'
library 'utils-files', 'net.minecraftforge', 'file-utils' version '0.3.3'
library 'utils-hash', 'net.minecraftforge', 'hash-utils' version '0.2.1'
library 'utils-hash', 'net.minecraftforge', 'hash-utils' version '0.2.2'
library 'utils-data', 'net.minecraftforge', 'json-data-utils' version '0.4.3'
library 'utils-logging', 'net.minecraftforge', 'log-utils' version '0.5.1'
library 'utils-os', 'net.minecraftforge', 'os-utils' version '0.1.0'
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/net/minecraftforge/mcmaven/cli/MCPDataTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,13 @@
import net.minecraftforge.srgutils.IMappingFile.IField;
import net.minecraftforge.srgutils.IMappingFile.IMethod;
import net.minecraftforge.srgutils.IMappingFile.IParameter;
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
class MCPDataTask {
static OptionParser run(String[] args, boolean getParser) throws Exception {
// TODO [MCMavenizer] Make this into a --log [level] option
LOGGER.setEnabled(Logger.Level.INFO);

var parser = new OptionParser();
parser.allowsUnrecognizedOptions();

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/net/minecraftforge/mcmaven/cli/MCPTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@
import net.minecraftforge.util.hash.HashFunction;
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.
class MCPTask {
static OptionParser run(String[] args, boolean getParser) throws Exception {
// TODO [MCMavenizer] Make this into a --log [level] option
LOGGER.setEnabled(Logger.Level.INFO);

var parser = new OptionParser();
parser.allowsUnrecognizedOptions();

Expand Down
7 changes: 7 additions & 0 deletions src/main/java/net/minecraftforge/mcmaven/cli/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ private static void run(String[] args) throws Exception {
"Displays this help message and exits")
.forHelp();

var debugO = parser.accepts("debug", "Sets the log level to DEBUG");

for (var task : tasks)
opts.add(parser.accepts(task.key, task.description));

Expand All @@ -58,6 +60,11 @@ private static void run(String[] args) throws Exception {

var options = parser.parse(args);

if (options.has(debugO))
LOGGER.setEnabled(Logger.Level.DEBUG);
else
LOGGER.setEnabled(Logger.Level.INFO);

for (var task : tasks) {
if (options.has(task.key)) {
task.callback.run(args, false);
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/net/minecraftforge/mcmaven/cli/MavenTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@
import net.minecraftforge.mcmaven.impl.mappings.ParchmentMappings;
import net.minecraftforge.mcmaven.impl.util.Artifact;
import net.minecraftforge.mcmaven.impl.util.Constants;
import net.minecraftforge.util.logging.Logger;

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

class MavenTask {
static OptionParser run(String[] args, boolean getParser) throws Exception {
// TODO [MCMavenizer] Make this into a --log [level] option
LOGGER.setEnabled(Logger.Level.INFO);

var parser = new OptionParser();
parser.allowsUnrecognizedOptions();

Expand Down Expand Up @@ -120,6 +116,7 @@ static OptionParser run(String[] args, boolean getParser) throws Exception {
"forge", Constants.FORGE_ARTIFACT,
"fml", Constants.FMLONLY_ARTIFACT,
"mc", "net.minecraft:joined",
"joined", "net.minecraft:joined",
"client", "net.minecraft:client",
"server", "net.minecraft:server",
"mapping-data", "net.minecraft:mappings"
Expand Down
27 changes: 26 additions & 1 deletion src/main/java/net/minecraftforge/mcmaven/impl/Mavenizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,40 @@ public static void assertNotCacheOnly() {
if (cacheOnly) {
throw new IllegalArgumentException("Cache is out of date! Please run without --cache-only");
} else if (!cacheMiss) {
LOGGER.debug("Cache miss!", new Exception("Cache miss! Stacktrace for Information Only"));
LOGGER.info("Cache miss!", new Exception("Cache miss! Stacktrace for Information Only"));
cacheMiss = true;
LOGGER.release();
}
}

private static void debug(String header, String data) {
if (data.isEmpty())
LOGGER.debug(header);
else {
var lines = data.split("\n");
if (lines.length == 1)
LOGGER.debug(header + ' ' + lines[0]);
else {
LOGGER.debug(header);
LOGGER.push();
for (var line : lines)
LOGGER.debug(line);
LOGGER.pop();
}
}
}

public static boolean checkCache(File output, HashStore cache) {
if (!ignoreCache && output.exists() && cache.isSame())
return true;
if (LOGGER.isEnabled(Logger.Level.DEBUG)) {
LOGGER.debug("Cache miss: " + output.getAbsolutePath());
LOGGER.push();
LOGGER.debug("Exists: " + output.exists());
debug("Old:", cache.dumpOld());
debug("New:", cache.dump());
LOGGER.pop();
}
Mavenizer.assertNotCacheOnly();
return false;
}
Expand Down