diff --git a/byte-buddy-gradle-plugin/android-plugin/src/main/java/net/bytebuddy/build/gradle/android/ByteBuddyLocalClassesEnhancerTask.java b/byte-buddy-gradle-plugin/android-plugin/src/main/java/net/bytebuddy/build/gradle/android/ByteBuddyLocalClassesEnhancerTask.java index ae2c31f4ab..96ff3bd411 100644 --- a/byte-buddy-gradle-plugin/android-plugin/src/main/java/net/bytebuddy/build/gradle/android/ByteBuddyLocalClassesEnhancerTask.java +++ b/byte-buddy-gradle-plugin/android-plugin/src/main/java/net/bytebuddy/build/gradle/android/ByteBuddyLocalClassesEnhancerTask.java @@ -29,8 +29,8 @@ import org.gradle.api.DefaultTask; import org.gradle.api.GradleException; import org.gradle.api.JavaVersion; -import org.gradle.api.Project; import org.gradle.api.file.*; +import org.gradle.api.logging.Logger; import org.gradle.api.provider.ListProperty; import org.gradle.api.provider.Property; import org.gradle.api.tasks.*; @@ -226,7 +226,7 @@ public void execute() throws IOException { try { Class discovery = Class.forName("net.bytebuddy.build.gradle.Discovery"); Class.forName("net.bytebuddy.build.gradle.AbstractByteBuddyTask").getMethod("apply", - Project.class, + Logger.class, ClassLoader.class, List.class, discovery, @@ -245,7 +245,7 @@ public void execute() throws IOException { boolean.class, Plugin.Engine.Source.class, Plugin.Engine.Target.class).invoke(null, - getProject(), + getLogger(), classLoader, transformations, discovery.getMethod("valueOf", String.class).invoke(null, getDiscovery().get().name()), diff --git a/byte-buddy-gradle-plugin/common.gradle b/byte-buddy-gradle-plugin/common.gradle index 2ffd79a4fe..f02b4b0423 100644 --- a/byte-buddy-gradle-plugin/common.gradle +++ b/byte-buddy-gradle-plugin/common.gradle @@ -87,7 +87,7 @@ if (Boolean.getBoolean('net.bytebuddy.misc.extras')) { } javadoc { options { - links 'https://docs.oracle.com/javase/1.5.0/docs/api' + links 'https://docs.oracle.com/javase/6/docs/api' links 'https://docs.gradle.org/7.5/javadoc' linksOffline "https://javadoc.io/doc/net.bytebuddy/byte-buddy/${pom.parent.version.text().toString()}", '../byte-buddy/target/apidocs' } diff --git a/byte-buddy-gradle-plugin/src/main/java/net/bytebuddy/build/gradle/AbstractByteBuddyTask.java b/byte-buddy-gradle-plugin/src/main/java/net/bytebuddy/build/gradle/AbstractByteBuddyTask.java index 071208e6c9..1bccb3b03f 100644 --- a/byte-buddy-gradle-plugin/src/main/java/net/bytebuddy/build/gradle/AbstractByteBuddyTask.java +++ b/byte-buddy-gradle-plugin/src/main/java/net/bytebuddy/build/gradle/AbstractByteBuddyTask.java @@ -27,7 +27,6 @@ import net.bytebuddy.utility.nullability.UnknownNull; import org.gradle.api.Action; import org.gradle.api.DefaultTask; -import org.gradle.api.Project; import org.gradle.api.logging.Logger; import org.gradle.api.tasks.Input; import org.gradle.api.tasks.Internal; @@ -400,7 +399,7 @@ protected void doApply(Plugin.Engine.Source source, Plugin.Engine.Target target) classFileVersion = this.classFileVersion; getLogger().debug("Java version was configured: {}", classFileVersion.getJavaVersion()); } - apply(getProject(), + apply(getLogger(), getClass().getClassLoader(), new ArrayList(getTransformations()), getDiscovery(), @@ -424,7 +423,7 @@ protected void doApply(Plugin.Engine.Source source, Plugin.Engine.Target target) /** * Dispatches a Byte Buddy instrumentation Gradle task. * - * @param project The current project. + * @param logger The logger to use. * @param rootLoader The class loader that is used for searching types and applying plugins. * @param transformations The transformations to apply. * @param discovery The discovery for plugins to use. @@ -445,7 +444,7 @@ protected void doApply(Plugin.Engine.Source source, Plugin.Engine.Target target) * @param target The target to use for instrumenting. * @throws IOException If an I/O error occurs. */ - public static void apply(Project project, + public static void apply(Logger logger, ClassLoader rootLoader, List transformations, Discovery discovery, @@ -485,16 +484,16 @@ public static void apply(Project project, } catch (ClassNotFoundException exception) { throw new IllegalStateException("Discovered plugin is not available: " + name, exception); } - project.getLogger().debug("Registered discovered plugin: {}", name); + logger.debug("Registered discovered plugin: {}", name); } else { - project.getLogger().info("Skipping discovered plugin {} which was previously discovered or registered", name); + logger.info("Skipping discovered plugin {} which was previously discovered or registered", name); } } } if (transformations.isEmpty()) { - project.getLogger().warn("No transformations are specified or discovered. Application will be non-operational."); + logger.warn("No transformations are specified or discovered. Application will be non-operational."); } else { - project.getLogger().debug("{} plugins are being applied via configuration and discovery", transformations.size()); + logger.debug("{} plugins are being applied via configuration and discovery", transformations.size()); } List classPath = new ArrayList(); for (File file : artifacts) { @@ -506,12 +505,11 @@ public static void apply(Project project, factories.add(new Plugin.Factory.UsingReflection(transformation.toPlugin(classLoader)) .with(transformation.makeArgumentResolvers()) .with(rootLocationResolver, - Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(Logger.class, project.getLogger()), - Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(org.slf4j.Logger.class, project.getLogger()), - Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(BuildLogger.class, new GradleBuildLogger(project.getLogger())), - Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(Project.class, project), + Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(Logger.class, logger), + Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(org.slf4j.Logger.class, logger), + Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(BuildLogger.class, new GradleBuildLogger(logger)), Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(File[].class, classPath.toArray(new File[0])))); - project.getLogger().info("Resolved plugin: {}", transformation.toPluginName()); + logger.info("Resolved plugin: {}", transformation.toPluginName()); } catch (Throwable throwable) { throw new IllegalStateException("Cannot resolve plugin: " + transformation.toPluginName(), throwable); } @@ -533,7 +531,7 @@ public static void apply(Project project, : Plugin.Engine.PoolStrategy.Default.FAST) .with(classFileLocator) .with(multiReleaseClassFileVersion) - .with(new TransformationLogger(project.getLogger())) + .with(new TransformationLogger(logger)) .withErrorHandlers(Plugin.Engine.ErrorHandler.Enforcing.ALL_TYPES_RESOLVED, failOnLiveInitializer ? Plugin.Engine.ErrorHandler.Enforcing.NO_LIVE_INITIALIZERS : Plugin.Engine.Listener.NoOp.INSTANCE, failFast @@ -554,9 +552,9 @@ public static void apply(Project project, if (!summary.getFailed().isEmpty()) { throw new IllegalStateException(summary.getFailed() + " type transformation(s) have failed"); } else if (warnOnEmptyTypeSet && summary.getTransformed().isEmpty()) { - project.getLogger().warn("No types were transformed during plugin execution"); + logger.warn("No types were transformed during plugin execution"); } else { - project.getLogger().info("Transformed {} type(s)", summary.getTransformed().size()); + logger.info("Transformed {} type(s)", summary.getTransformed().size()); } } diff --git a/byte-buddy-gradle-plugin/src/main/java/net/bytebuddy/build/gradle/AbstractByteBuddyTaskExtension.java b/byte-buddy-gradle-plugin/src/main/java/net/bytebuddy/build/gradle/AbstractByteBuddyTaskExtension.java index d58358237c..f3ee2ac897 100644 --- a/byte-buddy-gradle-plugin/src/main/java/net/bytebuddy/build/gradle/AbstractByteBuddyTaskExtension.java +++ b/byte-buddy-gradle-plugin/src/main/java/net/bytebuddy/build/gradle/AbstractByteBuddyTaskExtension.java @@ -482,6 +482,11 @@ protected void configure(T task) { doConfigure(task); } + /** + * Defines the discovery set to use. + * + * @param fileCollection The file collection that represents the discovery set. + */ protected abstract void discoverySet(FileCollection fileCollection); /** diff --git a/byte-buddy-maven-plugin/src/main/java/net/bytebuddy/build/maven/ByteBuddyMojo.java b/byte-buddy-maven-plugin/src/main/java/net/bytebuddy/build/maven/ByteBuddyMojo.java index edc43d10e0..dc782b2963 100644 --- a/byte-buddy-maven-plugin/src/main/java/net/bytebuddy/build/maven/ByteBuddyMojo.java +++ b/byte-buddy-maven-plugin/src/main/java/net/bytebuddy/build/maven/ByteBuddyMojo.java @@ -389,7 +389,6 @@ protected Plugin.Engine.Summary transform(List classPath, .with(Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(File.class, file), Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(Log.class, getLog()), Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(BuildLogger.class, new MavenBuildLogger(getLog())), - Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(MavenProject.class, project), Plugin.Factory.UsingReflection.ArgumentResolver.ForType.of(File[].class, artifacts.toArray(new File[0])))); getLog().info("Resolved plugin: " + plugin); } catch (Throwable throwable) {