Skip to content

Commit 95c66f2

Browse files
committed
Test
1 parent 4288f29 commit 95c66f2

File tree

5 files changed

+80
-3
lines changed

5 files changed

+80
-3
lines changed

.github/workflows/test.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Test
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [ 'test' ]
7+
paths-ignore:
8+
- 'README.md'
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
test:
15+
continue-on-error: true
16+
strategy:
17+
matrix:
18+
command: [
19+
"--maven --forge --version 1.21.11-61.1.0",
20+
"--maven --forge --version 1.20.1-47.4.0",
21+
"--maven --forge --version 1.12.2-14.23.5.2859 --mappings snapshot:20171003-1.12",
22+
"--maven --client --version 1.20.1",
23+
"--maven --server --version 1.20.1",
24+
"--maven --mc --version 1.20.1",
25+
"--maven --client --version 26.1-snapshot-1",
26+
"--maven --server --version 26.1-snapshot-1"
27+
]
28+
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout sources
32+
uses: actions/checkout@v6
33+
with:
34+
fetch-tags: true
35+
- name: Setup Java
36+
uses: actions/setup-java@v4
37+
with:
38+
distribution: temurin
39+
java-version: 25
40+
- name: Setup Gradle
41+
uses: gradle/actions/setup-gradle@v5
42+
- name: Test Run
43+
run: ./gradlew run --args="--debug ${{ matrix.command }}"

build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import org.gradle.api.plugins.jvm.JvmTestSuite
22
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
33

44
plugins {
5-
id 'java'
5+
id 'application'
66
id 'jvm-test-suite'
77
id 'idea'
88
id 'eclipse'
@@ -52,6 +52,10 @@ license {
5252
exclude '**/ComparableVersion.java' // Apache class used as source-level dep as to not need the hundred+ other classes the library pulls in
5353
}
5454

55+
application {
56+
mainClass = 'net.minecraftforge.mcmaven.cli.Main'
57+
}
58+
5559
tasks.named('jar', Jar) {
5660
manifest {
5761
attributes([

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ dependencyResolutionManagement.versionCatalogs.register('libs') {
4040
// Utilities
4141
library 'utils-download', 'net.minecraftforge', 'download-utils' version '0.4.0'
4242
library 'utils-files', 'net.minecraftforge', 'file-utils' version '0.3.3'
43-
library 'utils-hash', 'net.minecraftforge', 'hash-utils' version '0.2.1'
43+
library 'utils-hash', 'net.minecraftforge', 'hash-utils' version '0.2.2'
4444
library 'utils-data', 'net.minecraftforge', 'json-data-utils' version '0.4.3'
4545
library 'utils-logging', 'net.minecraftforge', 'log-utils' version '0.5.1'
4646
library 'utils-os', 'net.minecraftforge', 'os-utils' version '0.1.0'

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,14 @@ static OptionParser run(String[] args, boolean getParser) throws Exception {
115115
"File to write extended output data to. Not compatible with bulk operations.")
116116
.withRequiredArg().ofType(File.class);
117117

118+
var debugO = parser.accepts("debug", "Sets the log level to DEBUG");
119+
118120
var shorthandOptions = new HashMap<String, OptionSpecBuilder>();
119121
var artifacts = Map.of(
120122
"forge", Constants.FORGE_ARTIFACT,
121123
"fml", Constants.FMLONLY_ARTIFACT,
122124
"mc", "net.minecraft:joined",
125+
"joined", "net.minecraft:joined",
123126
"client", "net.minecraft:client",
124127
"server", "net.minecraft:server",
125128
"mapping-data", "net.minecraft:mappings"
@@ -153,6 +156,8 @@ static OptionParser run(String[] args, boolean getParser) throws Exception {
153156
}
154157

155158
// global options
159+
if (options.has(debugO))
160+
LOGGER.setEnabled(Logger.Level.DEBUG);
156161
if (options.has(offlineO))
157162
Mavenizer.setOffline();
158163
if (options.has(cacheOnlyO))

src/main/java/net/minecraftforge/mcmaven/impl/Mavenizer.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,40 @@ public static void assertNotCacheOnly() {
5757
if (cacheOnly) {
5858
throw new IllegalArgumentException("Cache is out of date! Please run without --cache-only");
5959
} else if (!cacheMiss) {
60-
LOGGER.debug("Cache miss!", new Exception("Cache miss! Stacktrace for Information Only"));
60+
LOGGER.info("Cache miss!", new Exception("Cache miss! Stacktrace for Information Only"));
6161
cacheMiss = true;
6262
LOGGER.release();
6363
}
6464
}
6565

66+
private static void debug(String header, String data) {
67+
if (data.isEmpty())
68+
LOGGER.debug(header);
69+
else {
70+
var lines = data.split("\n");
71+
if (lines.length == 1)
72+
LOGGER.debug(header + ' ' + lines[0]);
73+
else {
74+
LOGGER.debug(header);
75+
LOGGER.push();
76+
for (var line : lines)
77+
LOGGER.debug(line);
78+
LOGGER.pop();
79+
}
80+
}
81+
}
82+
6683
public static boolean checkCache(File output, HashStore cache) {
6784
if (!ignoreCache && output.exists() && cache.isSame())
6885
return true;
86+
if (LOGGER.isEnabled(Logger.Level.DEBUG)) {
87+
LOGGER.debug("Cache miss: " + output.getAbsolutePath());
88+
LOGGER.push();
89+
LOGGER.debug("Exists: " + output.exists());
90+
debug("Old:", cache.dumpOld());
91+
debug("New:", cache.dump());
92+
LOGGER.pop();
93+
}
6994
Mavenizer.assertNotCacheOnly();
7095
return false;
7196
}

0 commit comments

Comments
 (0)