Skip to content

Commit

Permalink
Small cleanups.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Oct 8, 2023
1 parent 9495532 commit 82014e3
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 16 deletions.
5 changes: 0 additions & 5 deletions byte-buddy-gradle-plugin/android-plugin-test/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

public class TargetServiceImplementation implements ServiceDefinition {

@Override
public String getValue() {
return "Target service impl";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> 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"));
Expand Down
1 change: 0 additions & 1 deletion byte-buddy-gradle-plugin/android-plugin-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,26 @@
* 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;
}

/**
* {@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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,26 @@
* 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;
}

/**
* {@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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.service.definition.ServiceDefinition;

public class ServiceImplementation implements ServiceDefinition {
@Override

public String getValue() {
return "Service implementation";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.service.definition.ServiceDefinition;

public class ServiceImplementation implements ServiceDefinition {
@Override

public String getValue() {
return "Service implementation2";
}
Expand Down

0 comments on commit 82014e3

Please sign in to comment.