27
27
import net .bytebuddy .utility .nullability .UnknownNull ;
28
28
import org .gradle .api .Action ;
29
29
import org .gradle .api .DefaultTask ;
30
- import org .gradle .api .Project ;
31
30
import org .gradle .api .logging .Logger ;
32
31
import org .gradle .api .tasks .Input ;
33
32
import org .gradle .api .tasks .Internal ;
@@ -400,7 +399,7 @@ protected void doApply(Plugin.Engine.Source source, Plugin.Engine.Target target)
400
399
classFileVersion = this .classFileVersion ;
401
400
getLogger ().debug ("Java version was configured: {}" , classFileVersion .getJavaVersion ());
402
401
}
403
- apply (getProject (),
402
+ apply (getLogger (),
404
403
getClass ().getClassLoader (),
405
404
new ArrayList <Transformation >(getTransformations ()),
406
405
getDiscovery (),
@@ -424,7 +423,7 @@ protected void doApply(Plugin.Engine.Source source, Plugin.Engine.Target target)
424
423
/**
425
424
* Dispatches a Byte Buddy instrumentation Gradle task.
426
425
*
427
- * @param project The current project .
426
+ * @param logger The logger to use .
428
427
* @param rootLoader The class loader that is used for searching types and applying plugins.
429
428
* @param transformations The transformations to apply.
430
429
* @param discovery The discovery for plugins to use.
@@ -445,7 +444,7 @@ protected void doApply(Plugin.Engine.Source source, Plugin.Engine.Target target)
445
444
* @param target The target to use for instrumenting.
446
445
* @throws IOException If an I/O error occurs.
447
446
*/
448
- public static void apply (Project project ,
447
+ public static void apply (Logger logger ,
449
448
ClassLoader rootLoader ,
450
449
List <Transformation > transformations ,
451
450
Discovery discovery ,
@@ -485,16 +484,16 @@ public static void apply(Project project,
485
484
} catch (ClassNotFoundException exception ) {
486
485
throw new IllegalStateException ("Discovered plugin is not available: " + name , exception );
487
486
}
488
- project . getLogger () .debug ("Registered discovered plugin: {}" , name );
487
+ logger .debug ("Registered discovered plugin: {}" , name );
489
488
} else {
490
- project . getLogger () .info ("Skipping discovered plugin {} which was previously discovered or registered" , name );
489
+ logger .info ("Skipping discovered plugin {} which was previously discovered or registered" , name );
491
490
}
492
491
}
493
492
}
494
493
if (transformations .isEmpty ()) {
495
- project . getLogger () .warn ("No transformations are specified or discovered. Application will be non-operational." );
494
+ logger .warn ("No transformations are specified or discovered. Application will be non-operational." );
496
495
} else {
497
- project . getLogger () .debug ("{} plugins are being applied via configuration and discovery" , transformations .size ());
496
+ logger .debug ("{} plugins are being applied via configuration and discovery" , transformations .size ());
498
497
}
499
498
List <File > classPath = new ArrayList <File >();
500
499
for (File file : artifacts ) {
@@ -506,12 +505,11 @@ public static void apply(Project project,
506
505
factories .add (new Plugin .Factory .UsingReflection (transformation .toPlugin (classLoader ))
507
506
.with (transformation .makeArgumentResolvers ())
508
507
.with (rootLocationResolver ,
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 ),
508
+ Plugin .Factory .UsingReflection .ArgumentResolver .ForType .of (Logger .class , logger ),
509
+ Plugin .Factory .UsingReflection .ArgumentResolver .ForType .of (org .slf4j .Logger .class , logger ),
510
+ Plugin .Factory .UsingReflection .ArgumentResolver .ForType .of (BuildLogger .class , new GradleBuildLogger (logger )),
513
511
Plugin .Factory .UsingReflection .ArgumentResolver .ForType .of (File [].class , classPath .toArray (new File [0 ]))));
514
- project . getLogger () .info ("Resolved plugin: {}" , transformation .toPluginName ());
512
+ logger .info ("Resolved plugin: {}" , transformation .toPluginName ());
515
513
} catch (Throwable throwable ) {
516
514
throw new IllegalStateException ("Cannot resolve plugin: " + transformation .toPluginName (), throwable );
517
515
}
@@ -533,7 +531,7 @@ public static void apply(Project project,
533
531
: Plugin .Engine .PoolStrategy .Default .FAST )
534
532
.with (classFileLocator )
535
533
.with (multiReleaseClassFileVersion )
536
- .with (new TransformationLogger (project . getLogger () ))
534
+ .with (new TransformationLogger (logger ))
537
535
.withErrorHandlers (Plugin .Engine .ErrorHandler .Enforcing .ALL_TYPES_RESOLVED , failOnLiveInitializer
538
536
? Plugin .Engine .ErrorHandler .Enforcing .NO_LIVE_INITIALIZERS
539
537
: Plugin .Engine .Listener .NoOp .INSTANCE , failFast
@@ -554,9 +552,9 @@ public static void apply(Project project,
554
552
if (!summary .getFailed ().isEmpty ()) {
555
553
throw new IllegalStateException (summary .getFailed () + " type transformation(s) have failed" );
556
554
} else if (warnOnEmptyTypeSet && summary .getTransformed ().isEmpty ()) {
557
- project . getLogger () .warn ("No types were transformed during plugin execution" );
555
+ logger .warn ("No types were transformed during plugin execution" );
558
556
} else {
559
- project . getLogger () .info ("Transformed {} type(s)" , summary .getTransformed ().size ());
557
+ logger .info ("Transformed {} type(s)" , summary .getTransformed ().size ());
560
558
}
561
559
}
562
560
0 commit comments