5050import javax .xml .transform .stream .StreamResult ;
5151import javax .xml .transform .stream .StreamSource ;
5252
53- import org .jetbrains .annotations .Nullable ;
5453import org .w3c .dom .Node ;
5554import org .xml .sax .SAXException ;
5655
@@ -67,15 +66,15 @@ public record MinecraftMaven(
6766 boolean disableGradle ,
6867 boolean stubJars ,
6968 Set <String > mcpConfigVersions ,
70- @ Nullable File accessTransformer
69+ List < File > accessTransformer
7170) {
7271 // Only 1.14.4+ has official mappings, we can support more when we add more mappings
7372 private static final MinecraftVersion MIN_OFFICIAL_MAPPINGS = MinecraftVersion .from ("1.14.4" );
7473 private static final ComparableVersion MIN_SUPPORTED_FORGE = new ComparableVersion ("1.14.4" );
7574
7675 public MinecraftMaven (File output , boolean dependenciesOnly , File cacheRoot , File jdkCacheRoot , Mappings mappings ,
7776 Map <String , String > foreignRepositories , boolean globalAuxiliaryVariants , boolean disableGradle , boolean stubJars ,
78- @ Nullable File accessTransformer ) {
77+ List < File > accessTransformer ) {
7978 this (output , dependenciesOnly , new Cache (cacheRoot , jdkCacheRoot , foreignRepositories ), mappings , foreignRepositories , globalAuxiliaryVariants , disableGradle , stubJars , new HashSet <>(), accessTransformer );
8079 }
8180
@@ -92,8 +91,17 @@ public MinecraftMaven(File output, boolean dependenciesOnly, File cacheRoot, Fil
9291 LOGGER .info (" GradleVariantHack: " + globalAuxiliaryVariants );
9392 LOGGER .info (" Disable Gradle: " + disableGradle );
9493 LOGGER .info (" Stub Jars: " + stubJars );
95- if (accessTransformer != null )
96- LOGGER .info (" Access Transformer: " + accessTransformer .getAbsolutePath ());
94+ if (!accessTransformer .isEmpty ()) {
95+ LOGGER .getInfo ().print (" Access Transformer: " );
96+ var itor = accessTransformer .iterator ();
97+ while (itor .hasNext ()) {
98+ var file = itor .next ();
99+ LOGGER .getInfo ().print (file .getAbsolutePath ());
100+ if (itor .hasNext ())
101+ LOGGER .getInfo ().print (", " );
102+ }
103+ LOGGER .getInfo ().println ();
104+ }
97105 LOGGER .info ();
98106 }
99107
@@ -314,13 +322,14 @@ private void updateFile(File target, File source, Artifact artifact) {
314322 }
315323
316324 // Only transform main artifacts
317- if (accessTransformer != null && artifact .getClassifier () == null ) {
325+ if (! accessTransformer . isEmpty () && artifact .getClassifier () == null ) {
318326 writeAccessTransformed (target , source , artifact );
319327 return ;
320328 }
321329 }
322330
323331 var cache = HashStore .fromFile (target )
332+ .add (accessTransformer )
324333 .add ("source" , source );
325334
326335 var isPom = "pom" .equals (artifact .getExtension ());
@@ -383,7 +392,7 @@ private void writeAccessTransformed(File target, File source, Artifact artifact)
383392 var tool = this .cache .maven ().download (Constants .ACCESS_TRANSFORMER );
384393 var cache = HashStore .fromFile (target )
385394 .add ("tool" , tool )
386- .add ("at" , accessTransformer )
395+ .add (accessTransformer )
387396 .add ("source" , source );
388397
389398 if (target .exists () && cache .isSame ())
@@ -397,13 +406,15 @@ private void writeAccessTransformed(File target, File source, Artifact artifact)
397406 }
398407
399408 var log = new File (source .getAbsolutePath () + ".accesstransformer.log" );
400- var ret = ProcessUtils .runJar (jdk , source .getParentFile (), log , tool , Collections .emptyList (),
401- List .of (
402- "--inJar" , source .getAbsolutePath (),
403- "--outJar" , target .getAbsolutePath (),
404- "--atfile" , accessTransformer .getAbsolutePath ()
405- )
406- );
409+ var args = new ArrayList <>(List .of (
410+ "--inJar" , source .getAbsolutePath (),
411+ "--outJar" , target .getAbsolutePath ()
412+ ));
413+ for (var file : accessTransformer ) {
414+ args .add ("--atfile" );
415+ args .add (file .getAbsolutePath ());
416+ }
417+ var ret = ProcessUtils .runJar (jdk , source .getParentFile (), log , tool , Collections .emptyList (), args );
407418 if (ret .exitCode != 0 )
408419 throw new IllegalStateException ("Failed to Access Transform jar file (exit code " + ret .exitCode + "), See log: " + log .getAbsolutePath ());
409420
0 commit comments