Skip to content

Commit 9c9c401

Browse files
committed
Support ignore files in jars
1 parent 7ded566 commit 9c9c401

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

bs-dev/src/main/java/net/minecraftforge/bootstrap/dev/BootstrapDevClasspathFixer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ private boolean processAuto(List<Path[]> classpath) {
193193
} //else if (DEBUG) log("Unknown directory format: " + path);
194194
} else {
195195
var module = Util.findModule(path);
196-
if (module.name() == null) {
196+
if (module == null) {
197197
//var meta = JarMetadata.fromFileName(path, Set.of(), List.of());
198198
//module = new ModuleVersion(meta.name(), meta.version(), module.layer());
199199
if (DEBUG)

bs-prod/src/main/java/net/minecraftforge/bootstrap/prod/BootstrapProdClasspathFixer.java

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
*/
55
package net.minecraftforge.bootstrap.prod;
66

7+
import java.io.BufferedReader;
8+
import java.io.ByteArrayInputStream;
79
import java.io.IOException;
10+
import java.io.InputStreamReader;
811
import java.nio.charset.StandardCharsets;
12+
import java.nio.file.FileSystems;
913
import java.nio.file.Files;
1014
import java.nio.file.Path;
1115
import java.util.ArrayList;
@@ -17,7 +21,7 @@
1721
public class BootstrapProdClasspathFixer implements BootstrapClasspathModifier {
1822
private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("bsl.debug", "false"));
1923
private static final boolean IGNORE = Boolean.parseBoolean(System.getProperty("bsl.dev.ignore", "true" ));
20-
private static final Path IGNORE_FILE = Path.of("META-INF/forge-bootstrap-ignore");
24+
private static final String IGNORE_FILE = "META-INF/forge-bootstrap-ignore";
2125

2226
static void log(String message) {
2327
System.out.println(message);
@@ -47,15 +51,37 @@ private boolean processIgnore(List<Path[]> classpath) {
4751
for (var paths : classpath) {
4852
var ignoreSelf = false;
4953
for (var path : paths) {
50-
if (!Files.isDirectory(path))
51-
continue;
54+
byte[] data = null;
55+
56+
if (Files.isDirectory(path)) {
57+
var ignore = path.resolve(IGNORE_FILE);
58+
if (Files.exists(ignore)) {
59+
if (DEBUG) log("Ingore File: " + ignore);
60+
try {
61+
data = Files.readAllBytes(ignore);
62+
} catch (IOException e) {
63+
sneak(e);
64+
}
65+
}
66+
} else {
67+
try (var fs = FileSystems.newFileSystem(path)) {
68+
var root = fs.getRootDirectories().iterator().next();
69+
var ignore = root.resolve(IGNORE_FILE);
70+
71+
if (Files.exists(ignore)) {
72+
if (DEBUG) log("Ingore File: " + path + "!/" + ignore);
73+
data = Files.readAllBytes(ignore);
74+
}
75+
} catch (IOException e) {
76+
sneak(e);
77+
}
78+
}
5279

53-
var ignore = path.resolve(IGNORE_FILE);
54-
if (Files.exists(ignore)) {
55-
if (DEBUG) log("Ingore File: " + ignore);
80+
if (data != null) {
5681
var ignores = new ArrayList<String>();
57-
try {
58-
for (var line : Files.readAllLines(ignore, StandardCharsets.UTF_8)) {
82+
try (var reader = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(data), StandardCharsets.UTF_8.newDecoder()))) {
83+
String line = null;
84+
while ((line = reader.readLine()) != null) {
5985
int idx = line.indexOf('#');
6086
if (idx != -1)
6187
line = line.substring(0, idx);
@@ -64,7 +90,7 @@ private boolean processIgnore(List<Path[]> classpath) {
6490
ignores.add(line);
6591
}
6692
} catch (IOException e) {
67-
return sneak(e);
93+
sneak(e);
6894
}
6995

7096
if (ignores.isEmpty())

0 commit comments

Comments
 (0)