2727import net .bytebuddy .utility .nullability .UnknownNull ;
2828import org .gradle .api .Action ;
2929import org .gradle .api .DefaultTask ;
30+ import org .gradle .api .Project ;
3031import org .gradle .api .logging .Logger ;
3132import org .gradle .api .tasks .Input ;
3233import org .gradle .api .tasks .Internal ;
@@ -399,7 +400,7 @@ protected void doApply(Plugin.Engine.Source source, Plugin.Engine.Target target)
399400 classFileVersion = this .classFileVersion ;
400401 getLogger ().debug ("Java version was configured: {}" , classFileVersion .getJavaVersion ());
401402 }
402- apply (getLogger (),
403+ apply (getProject (),
403404 getClass ().getClassLoader (),
404405 new ArrayList <Transformation >(getTransformations ()),
405406 getDiscovery (),
@@ -423,7 +424,7 @@ protected void doApply(Plugin.Engine.Source source, Plugin.Engine.Target target)
423424 /**
424425 * Dispatches a Byte Buddy instrumentation Gradle task.
425426 *
426- * @param logger The logger to use .
427+ * @param project The current project .
427428 * @param rootLoader The class loader that is used for searching types and applying plugins.
428429 * @param transformations The transformations to apply.
429430 * @param discovery The discovery for plugins to use.
@@ -444,7 +445,7 @@ protected void doApply(Plugin.Engine.Source source, Plugin.Engine.Target target)
444445 * @param target The target to use for instrumenting.
445446 * @throws IOException If an I/O error occurs.
446447 */
447- public static void apply (Logger logger ,
448+ public static void apply (Project project ,
448449 ClassLoader rootLoader ,
449450 List <Transformation > transformations ,
450451 Discovery discovery ,
@@ -484,27 +485,33 @@ public static void apply(Logger logger,
484485 } catch (ClassNotFoundException exception ) {
485486 throw new IllegalStateException ("Discovered plugin is not available: " + name , exception );
486487 }
487- logger .debug ("Registered discovered plugin: {}" , name );
488+ project . getLogger () .debug ("Registered discovered plugin: {}" , name );
488489 } else {
489- logger .info ("Skipping discovered plugin {} which was previously discovered or registered" , name );
490+ project . getLogger () .info ("Skipping discovered plugin {} which was previously discovered or registered" , name );
490491 }
491492 }
492493 }
493494 if (transformations .isEmpty ()) {
494- logger .warn ("No transformations are specified or discovered. Application will be non-operational." );
495+ project . getLogger () .warn ("No transformations are specified or discovered. Application will be non-operational." );
495496 } else {
496- logger .debug ("{} plugins are being applied via configuration and discovery" , transformations .size ());
497+ project .getLogger ().debug ("{} plugins are being applied via configuration and discovery" , transformations .size ());
498+ }
499+ List <File > classPath = new ArrayList <File >();
500+ for (File file : artifacts ) {
501+ classPath .add (file );
497502 }
498503 List <Plugin .Factory > factories = new ArrayList <Plugin .Factory >(transformations .size ());
499504 for (Transformation transformation : transformations ) {
500505 try {
501506 factories .add (new Plugin .Factory .UsingReflection (transformation .toPlugin (classLoader ))
502507 .with (transformation .makeArgumentResolvers ())
503508 .with (rootLocationResolver ,
504- Plugin .Factory .UsingReflection .ArgumentResolver .ForType .of (Logger .class , logger ),
505- Plugin .Factory .UsingReflection .ArgumentResolver .ForType .of (org .slf4j .Logger .class , logger ),
506- Plugin .Factory .UsingReflection .ArgumentResolver .ForType .of (BuildLogger .class , new GradleBuildLogger (logger ))));
507- logger .info ("Resolved plugin: {}" , transformation .toPluginName ());
509+ Plugin .Factory .UsingReflection .ArgumentResolver .ForType .of (Logger .class , project .getLogger ()),
510+ Plugin .Factory .UsingReflection .ArgumentResolver .ForType .of (org .slf4j .Logger .class , project .getLogger ()),
511+ Plugin .Factory .UsingReflection .ArgumentResolver .ForType .of (BuildLogger .class , new GradleBuildLogger (project .getLogger ())),
512+ Plugin .Factory .UsingReflection .ArgumentResolver .ForType .of (Project .class , project ),
513+ Plugin .Factory .UsingReflection .ArgumentResolver .ForType .of (File [].class , classPath .toArray (new File [0 ]))));
514+ project .getLogger ().info ("Resolved plugin: {}" , transformation .toPluginName ());
508515 } catch (Throwable throwable ) {
509516 throw new IllegalStateException ("Cannot resolve plugin: " + transformation .toPluginName (), throwable );
510517 }
@@ -526,7 +533,7 @@ public static void apply(Logger logger,
526533 : Plugin .Engine .PoolStrategy .Default .FAST )
527534 .with (classFileLocator )
528535 .with (multiReleaseClassFileVersion )
529- .with (new TransformationLogger (logger ))
536+ .with (new TransformationLogger (project . getLogger () ))
530537 .withErrorHandlers (Plugin .Engine .ErrorHandler .Enforcing .ALL_TYPES_RESOLVED , failOnLiveInitializer
531538 ? Plugin .Engine .ErrorHandler .Enforcing .NO_LIVE_INITIALIZERS
532539 : Plugin .Engine .Listener .NoOp .INSTANCE , failFast
@@ -547,9 +554,9 @@ public static void apply(Logger logger,
547554 if (!summary .getFailed ().isEmpty ()) {
548555 throw new IllegalStateException (summary .getFailed () + " type transformation(s) have failed" );
549556 } else if (warnOnEmptyTypeSet && summary .getTransformed ().isEmpty ()) {
550- logger .warn ("No types were transformed during plugin execution" );
557+ project . getLogger () .warn ("No types were transformed during plugin execution" );
551558 } else {
552- logger .info ("Transformed {} type(s)" , summary .getTransformed ().size ());
559+ project . getLogger () .info ("Transformed {} type(s)" , summary .getTransformed ().size ());
553560 }
554561 }
555562
0 commit comments