44 */
55package net .minecraftforge .bootstrap .prod ;
66
7+ import java .io .BufferedReader ;
8+ import java .io .ByteArrayInputStream ;
79import java .io .IOException ;
10+ import java .io .InputStreamReader ;
811import java .nio .charset .StandardCharsets ;
12+ import java .nio .file .FileSystems ;
913import java .nio .file .Files ;
1014import java .nio .file .Path ;
1115import java .util .ArrayList ;
1721public 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