From 140e3d0e21220de29640fe4845457e45923c8057 Mon Sep 17 00:00:00 2001 From: Rafael Winterhalter Date: Wed, 13 Sep 2023 23:19:04 +0200 Subject: [PATCH] Fix functions for Gradle compatibility. --- .../android/ByteBuddyAndroidPlugin.java | 160 ++++++++++-------- 1 file changed, 89 insertions(+), 71 deletions(-) diff --git a/byte-buddy-gradle-plugin/android-plugin/src/main/java/net/bytebuddy/build/gradle/android/ByteBuddyAndroidPlugin.java b/byte-buddy-gradle-plugin/android-plugin/src/main/java/net/bytebuddy/build/gradle/android/ByteBuddyAndroidPlugin.java index 7be84a55b1..a064940494 100644 --- a/byte-buddy-gradle-plugin/android-plugin/src/main/java/net/bytebuddy/build/gradle/android/ByteBuddyAndroidPlugin.java +++ b/byte-buddy-gradle-plugin/android-plugin/src/main/java/net/bytebuddy/build/gradle/android/ByteBuddyAndroidPlugin.java @@ -469,9 +469,45 @@ public void accept(Project project, Variant variant, Configuration configuration new LegacyByteBuddyLocalClassesEnhancerTask.ConfigurationAction(configuration, project.getExtensions().getByType(BaseExtension.class), classPath)); variant.getArtifacts() .use(provider) - .wiredWith(GetLocalJarsFunction.INSTANCE, GetOutputDirFunction.INSTANCE) + .wiredWith(GetLocalClassesFunction.INSTANCE, GetOutputDirFunction.INSTANCE) .toTransform(MultipleArtifact.ALL_CLASSES_DIRS.INSTANCE); } + + /** + * A function representation of getting the local classes. + */ + protected enum GetLocalClassesFunction implements Function1> { + + /** + * The singleton instance. + */ + INSTANCE; + + /** + * {@inheritDoc} + */ + public ListProperty invoke(LegacyByteBuddyLocalClassesEnhancerTask task) { + return task.getLocalClassesDirs(); + } + } + + /** + * A function representation of getting the output directory. + */ + protected enum GetOutputDirFunction implements Function1 { + + /** + * The singleton instance. + */ + INSTANCE; + + /** + * {@inheritDoc} + */ + public DirectoryProperty invoke(LegacyByteBuddyLocalClassesEnhancerTask task) { + return task.getOutputDir(); + } + } } /** @@ -526,8 +562,8 @@ protected ForApk74CompatibleAndroid(Method forScope, Method use, Method toTransf */ public void accept(Project project, Variant variant, Configuration configuration, FileCollection classPath) { TaskProvider provider = project.getTasks().register(variant.getName() + "BytebuddyLocalTransform", - ByteBuddyLocalClassesEnhancerTask.class, - new ByteBuddyLocalClassesEnhancerTask.ConfigurationAction(configuration, project.getExtensions().getByType(BaseExtension.class), classPath)); + ByteBuddyLocalClassesEnhancerTask.class, + new ByteBuddyLocalClassesEnhancerTask.ConfigurationAction(configuration, project.getExtensions().getByType(BaseExtension.class), classPath)); try { toTransform.invoke(use.invoke(forScope.invoke(variant.getArtifacts(), scope), provider), artifact, @@ -540,88 +576,70 @@ public void accept(Project project, Variant variant, Configuration configuration throw new IllegalStateException("Failed to resolve runtime scope", exception.getCause()); } } - } - - /** - * Applies this dispatcher. - * - * @param project The current project. - * @param variant The variant to use. - * @param configuration The configuration to use. - * @param classPath The class path to use. - */ - void accept(Project project, Variant variant, Configuration configuration, FileCollection classPath); - - /** - * A function representation of resolving local jars. - */ - enum GetLocalJarsFunction implements Function1> { - - /** - * The singleton instance. - */ - INSTANCE; /** - * {@inheritDoc} + * A function representation of resolving local jars. */ - public ListProperty invoke(ByteBuddyLocalClassesEnhancerTask task) { - return task.getLocalJars(); + protected enum GetLocalJarsFunction implements Function1> { + + /** + * The singleton instance. + */ + INSTANCE; + + /** + * {@inheritDoc} + */ + public ListProperty invoke(ByteBuddyLocalClassesEnhancerTask task) { + return task.getLocalJars(); + } } - } - - /** - * A function representation of getting the local classes directory. - */ - enum GetLocalClassesDirsFunction implements Function1> { /** - * The singleton instance. + * A function representation of getting the local classes directory. */ - INSTANCE; - - /** - * {@inheritDoc} - */ - public ListProperty invoke(ByteBuddyLocalClassesEnhancerTask task) { - return task.getLocalClassesDirs(); + protected enum GetLocalClassesDirsFunction implements Function1> { + + /** + * The singleton instance. + */ + INSTANCE; + + /** + * {@inheritDoc} + */ + public ListProperty invoke(ByteBuddyLocalClassesEnhancerTask task) { + return task.getLocalClassesDirs(); + } } - } - - /** - * A function representation of getting the output directory. - */ - enum GetOutputDirFunction implements Function1 { /** - * The singleton instance. + * A function representation of getting the output file. */ - INSTANCE; - - /** - * {@inheritDoc} - */ - public DirectoryProperty invoke(LegacyByteBuddyLocalClassesEnhancerTask task) { - return task.getOutputDir(); + protected enum GetOutputFileFunction implements Function1 { + + /** + * The singleton instance. + */ + INSTANCE; + + /** + * {@inheritDoc} + */ + public RegularFileProperty invoke(ByteBuddyLocalClassesEnhancerTask task) { + return task.getOutputFile(); + } } } /** - * A function representation of getting the output file. + * Applies this dispatcher. + * + * @param project The current project. + * @param variant The variant to use. + * @param configuration The configuration to use. + * @param classPath The class path to use. */ - enum GetOutputFileFunction implements Function1 { - - /** - * The singleton instance. - */ - INSTANCE; - - /** - * {@inheritDoc} - */ - public RegularFileProperty invoke(ByteBuddyLocalClassesEnhancerTask task) { - return task.getOutputFile(); - } - } + void accept(Project project, Variant variant, Configuration configuration, FileCollection classPath); } -} \ No newline at end of file +}