@@ -49,11 +49,11 @@ public static List<Path[]> resolve() {
4949 final Set <String > gameShadedNames = Set .of (System .getProperty ("sponge.dev.gameShaded" ).split (File .pathSeparator ));
5050
5151 // boot layer
52- final Multimap <String , Path > bootUnions = new Multimap <>();
52+ final Multimap <String , WeightedPath > bootUnions = new Multimap <>();
5353 final List <Path > bootLibs = new ArrayList <>();
5454
5555 // game or plugin layer
56- final Multimap <String , Path > unions = new Multimap <>();
56+ final Multimap <String , WeightedPath > unions = new Multimap <>();
5757 final List <Path > libs = new ArrayList <>();
5858
5959 final AtomicBoolean hasAPISourceSet = new AtomicBoolean (false );
@@ -80,7 +80,7 @@ public static List<Path[]> resolve() {
8080 // ignore
8181 break ;
8282 case "modlauncher-transformers" , "library-manager" :
83- bootUnions .add (projectName , path );
83+ bootUnions .add (projectName , new WeightedPath ( 0 , path ) );
8484 break ;
8585 case "SpongeAPI" :
8686 switch (sourceSet .name ()) {
@@ -91,34 +91,35 @@ public static List<Path[]> resolve() {
9191 hasAPISourceSet .set (true );
9292 // no break
9393 default :
94- unions .add ("sponge" , path );
94+ unions .add ("sponge" , new WeightedPath ( 0 , path ) );
9595 break ;
9696 }
9797 break ;
9898 case "" , "vanilla" , "forge" , "neoforge" :
99+ final WeightedPath weightedPath = new WeightedPath (projectName .isEmpty () ? 1 : 2 , path );
99100 switch (sourceSet .name ()) {
100101 case "applaunchConfig" :
101102 case "applaunch" :
102- bootUnions .add ("applaunch" , path );
103+ bootUnions .add ("applaunch" , weightedPath );
103104 break ;
104105 case "lang" :
105- unions .add ("lang" , path );
106+ unions .add ("lang" , weightedPath );
106107 break ;
107108 default :
108- unions .add ("sponge" , path );
109+ unions .add ("sponge" , weightedPath );
109110 break ;
110111 }
111112 break ;
112113 default :
113- unions .add (projectName , path );
114+ unions .add (projectName , new WeightedPath ( 0 , path ) );
114115 break ;
115116 }
116117 } else {
117118 if (Bootstrap .DEBUG ) {
118119 System .out .println ("External SourceSet (" + sourceSet + "): " + path );
119120 }
120121
121- unions .add (sourceSet .project ().toString (), path );
122+ unions .add (sourceSet .project ().toString (), new WeightedPath ( 0 , path ) );
122123 }
123124 continue ;
124125 }
@@ -144,7 +145,7 @@ public static List<Path[]> resolve() {
144145 if (Bootstrap .DEBUG ) {
145146 System .out .println ("Sponge: " + path );
146147 }
147- unions .add ("sponge" , path );
148+ unions .add ("sponge" , new WeightedPath ( 0 , path ) );
148149 continue ;
149150 }
150151
@@ -160,12 +161,13 @@ public static List<Path[]> resolve() {
160161 classpath .add (new Path [] { lib });
161162 }
162163
163- for (final List <Path > sourceSets : bootUnions .values ()) {
164- classpath .add (sourceSets .toArray (Path []::new ));
164+ for (final List <WeightedPath > sourceSets : bootUnions .values ()) {
165+ classpath .add (sourceSets .stream (). sorted (). map ( WeightedPath :: path ). toArray (Path []::new ));
165166 }
166167
167168 if (hasAPISourceSet .get ()) {
168- unions .get ("sponge" ).removeIf ((path ) -> {
169+ unions .get ("sponge" ).removeIf ((w ) -> {
170+ final Path path = w .path ();
169171 if (Files .isRegularFile (path )) {
170172 final String fileName = path .getFileName ().toString ();
171173 if (fileName .startsWith ("spongeapi" ) && fileName .endsWith (".jar" )) {
@@ -183,10 +185,8 @@ public static List<Path[]> resolve() {
183185 for (final Path resource : libs ) {
184186 resourcesEnvBuilder .append (resource ).append (File .pathSeparator );
185187 }
186- for (final List <Path > project : unions .values ()) {
187- for (final Path resource : project ) {
188- resourcesEnvBuilder .append (resource ).append ('&' );
189- }
188+ for (final List <WeightedPath > project : unions .values ()) {
189+ project .stream ().sorted ().forEachOrdered (w -> resourcesEnvBuilder .append (w .path ()).append ('&' ));
190190 resourcesEnvBuilder .setCharAt (resourcesEnvBuilder .length () - 1 , File .pathSeparatorChar );
191191 }
192192 resourcesEnvBuilder .setLength (resourcesEnvBuilder .length () - 1 );
0 commit comments