From 82014e3801dd24afa32f024b3cb6c7d52d78a106 Mon Sep 17 00:00:00 2001 From: Rafael Winterhalter Date: Sun, 8 Oct 2023 08:41:44 +0200 Subject: [PATCH] Small cleanups. --- .../android-plugin-test/.gitignore | 5 ----- .../lib/service/TargetServiceImplementation.java | 1 - .../android/test/ByteBuddyInstrumentedTest.java | 5 ++--- .../android-plugin-test/build.gradle | 1 - .../plugin/gradle/test/jar/PluginForLibClass.java | 13 +++++++++++-- .../plugin/gradle/test/jar/PluginForLocalClass.java | 13 +++++++++++-- .../com/service/usage/ServiceImplementation.java | 2 +- .../com/service/usage2/ServiceImplementation.java | 2 +- 8 files changed, 26 insertions(+), 16 deletions(-) delete mode 100644 byte-buddy-gradle-plugin/android-plugin-test/.gitignore diff --git a/byte-buddy-gradle-plugin/android-plugin-test/.gitignore b/byte-buddy-gradle-plugin/android-plugin-test/.gitignore deleted file mode 100644 index 55b147bea5..0000000000 --- a/byte-buddy-gradle-plugin/android-plugin-test/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -build/ -.gradle/ -.idea/ -local.properties -captures/ \ No newline at end of file diff --git a/byte-buddy-gradle-plugin/android-plugin-test/aar-bytebuddy-target/src/main/java/net/bytebuddy/android/test/aar/lib/service/TargetServiceImplementation.java b/byte-buddy-gradle-plugin/android-plugin-test/aar-bytebuddy-target/src/main/java/net/bytebuddy/android/test/aar/lib/service/TargetServiceImplementation.java index 9fe659434d..a144ba70a1 100644 --- a/byte-buddy-gradle-plugin/android-plugin-test/aar-bytebuddy-target/src/main/java/net/bytebuddy/android/test/aar/lib/service/TargetServiceImplementation.java +++ b/byte-buddy-gradle-plugin/android-plugin-test/aar-bytebuddy-target/src/main/java/net/bytebuddy/android/test/aar/lib/service/TargetServiceImplementation.java @@ -19,7 +19,6 @@ public class TargetServiceImplementation implements ServiceDefinition { - @Override public String getValue() { return "Target service impl"; } diff --git a/byte-buddy-gradle-plugin/android-plugin-test/app/src/androidTest/java/net/bytebuddy/android/test/ByteBuddyInstrumentedTest.java b/byte-buddy-gradle-plugin/android-plugin-test/app/src/androidTest/java/net/bytebuddy/android/test/ByteBuddyInstrumentedTest.java index 472475656d..3f040dde5f 100644 --- a/byte-buddy-gradle-plugin/android-plugin-test/app/src/androidTest/java/net/bytebuddy/android/test/ByteBuddyInstrumentedTest.java +++ b/byte-buddy-gradle-plugin/android-plugin-test/app/src/androidTest/java/net/bytebuddy/android/test/ByteBuddyInstrumentedTest.java @@ -16,19 +16,18 @@ public class ByteBuddyInstrumentedTest { @Test - public void bytecodeInstrumentation() { + public void testBytecodeInstrumentation() { assertEquals("instrumented local class from jar plugin", new SomeClass().method()); assertEquals("instrumented local class from aar plugin", new AnotherClass().method()); assertEquals("instrumented aar lib's class from jar plugin", new SomeAarClass().method()); } @Test - public void verifySPIsAreNotMissing() { + public void testVerifySPIsAreNotMissing() { List values = new ArrayList<>(); for (ServiceDefinition serviceDefinition : ServiceLoader.load(ServiceDefinition.class)) { values.add(serviceDefinition.getValue()); } - assertEquals(3, values.size()); assertTrue(values.contains("Target service impl")); assertTrue(values.contains("Service implementation")); diff --git a/byte-buddy-gradle-plugin/android-plugin-test/build.gradle b/byte-buddy-gradle-plugin/android-plugin-test/build.gradle index 52d8aa96b5..60e94062b4 100644 --- a/byte-buddy-gradle-plugin/android-plugin-test/build.gradle +++ b/byte-buddy-gradle-plugin/android-plugin-test/build.gradle @@ -9,7 +9,6 @@ buildscript { } dependencies { classpath group: 'com.android.tools.build', name: 'gradle', version: '7.4.0' - def byteBuddyPlugin = new File("${rootDir}/../build/libs/byte-buddy-gradle-plugin-${byteBuddyVersion}.jar").canonicalFile def byteBuddyLib = new File("$rootDir/../../byte-buddy/target/byte-buddy-${byteBuddyVersion}.jar").canonicalFile classpath files(byteBuddyPlugin) diff --git a/byte-buddy-gradle-plugin/android-plugin-test/jar-bytebuddy-plugin/src/main/java/net/bytebuddy/plugin/gradle/test/jar/PluginForLibClass.java b/byte-buddy-gradle-plugin/android-plugin-test/jar-bytebuddy-plugin/src/main/java/net/bytebuddy/plugin/gradle/test/jar/PluginForLibClass.java index b6eacb89be..4a71384673 100644 --- a/byte-buddy-gradle-plugin/android-plugin-test/jar-bytebuddy-plugin/src/main/java/net/bytebuddy/plugin/gradle/test/jar/PluginForLibClass.java +++ b/byte-buddy-gradle-plugin/android-plugin-test/jar-bytebuddy-plugin/src/main/java/net/bytebuddy/plugin/gradle/test/jar/PluginForLibClass.java @@ -27,8 +27,17 @@ * A sample plugin for instrumenting a jar file. */ public class PluginForLibClass implements Plugin { + + /** + * The Android descriptor. + */ private final AndroidDescriptor androidDescriptor; + /** + * Creates a new plugin. + * + * @param androidDescriptor The Android descriptor. + */ public PluginForLibClass(AndroidDescriptor androidDescriptor) { this.androidDescriptor = androidDescriptor; } @@ -36,8 +45,8 @@ public PluginForLibClass(AndroidDescriptor androidDescriptor) { /** * {@inheritDoc} */ - public boolean matches(TypeDescription typeDefinitions) { - return typeDefinitions.getSimpleName().contains("Some") && androidDescriptor.getTypeScope(typeDefinitions).equals(AndroidDescriptor.TypeScope.EXTERNAL); + public boolean matches(TypeDescription typeDescription) { + return typeDescription.getSimpleName().contains("Some") && androidDescriptor.getTypeScope(typeDescription).equals(AndroidDescriptor.TypeScope.EXTERNAL); } /** diff --git a/byte-buddy-gradle-plugin/android-plugin-test/jar-bytebuddy-plugin/src/main/java/net/bytebuddy/plugin/gradle/test/jar/PluginForLocalClass.java b/byte-buddy-gradle-plugin/android-plugin-test/jar-bytebuddy-plugin/src/main/java/net/bytebuddy/plugin/gradle/test/jar/PluginForLocalClass.java index c4550be813..cb83bfc883 100644 --- a/byte-buddy-gradle-plugin/android-plugin-test/jar-bytebuddy-plugin/src/main/java/net/bytebuddy/plugin/gradle/test/jar/PluginForLocalClass.java +++ b/byte-buddy-gradle-plugin/android-plugin-test/jar-bytebuddy-plugin/src/main/java/net/bytebuddy/plugin/gradle/test/jar/PluginForLocalClass.java @@ -27,8 +27,17 @@ * A sample plugin for instrumenting a jar file. */ public class PluginForLocalClass implements Plugin { + + /** + * The Android descriptor. + */ private final AndroidDescriptor androidDescriptor; + /** + * Creates a new plugin. + * + * @param androidDescriptor The Android descriptor. + */ public PluginForLocalClass(AndroidDescriptor androidDescriptor) { this.androidDescriptor = androidDescriptor; } @@ -36,8 +45,8 @@ public PluginForLocalClass(AndroidDescriptor androidDescriptor) { /** * {@inheritDoc} */ - public boolean matches(TypeDescription typeDefinitions) { - return typeDefinitions.getSimpleName().contains("Some") && androidDescriptor.getTypeScope(typeDefinitions).equals(AndroidDescriptor.TypeScope.LOCAL); + public boolean matches(TypeDescription typeDescription) { + return typeDescription.getSimpleName().contains("Some") && androidDescriptor.getTypeScope(typeDescription).equals(AndroidDescriptor.TypeScope.LOCAL); } /** diff --git a/byte-buddy-gradle-plugin/android-plugin-test/service-implementation-lib/src/main/java/com/service/usage/ServiceImplementation.java b/byte-buddy-gradle-plugin/android-plugin-test/service-implementation-lib/src/main/java/com/service/usage/ServiceImplementation.java index ffd9227442..b5f27a8e72 100644 --- a/byte-buddy-gradle-plugin/android-plugin-test/service-implementation-lib/src/main/java/com/service/usage/ServiceImplementation.java +++ b/byte-buddy-gradle-plugin/android-plugin-test/service-implementation-lib/src/main/java/com/service/usage/ServiceImplementation.java @@ -18,7 +18,7 @@ import com.service.definition.ServiceDefinition; public class ServiceImplementation implements ServiceDefinition { - @Override + public String getValue() { return "Service implementation"; } diff --git a/byte-buddy-gradle-plugin/android-plugin-test/service-implementation2-lib/src/main/java/com/service/usage2/ServiceImplementation.java b/byte-buddy-gradle-plugin/android-plugin-test/service-implementation2-lib/src/main/java/com/service/usage2/ServiceImplementation.java index cb0badac22..11764fa8e3 100644 --- a/byte-buddy-gradle-plugin/android-plugin-test/service-implementation2-lib/src/main/java/com/service/usage2/ServiceImplementation.java +++ b/byte-buddy-gradle-plugin/android-plugin-test/service-implementation2-lib/src/main/java/com/service/usage2/ServiceImplementation.java @@ -18,7 +18,7 @@ import com.service.definition.ServiceDefinition; public class ServiceImplementation implements ServiceDefinition { - @Override + public String getValue() { return "Service implementation2"; }