Skip to content

Commit

Permalink
Fix functions for Gradle compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
raphw committed Sep 13, 2023
1 parent 2faeefa commit 140e3d0
Showing 1 changed file with 89 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<LegacyByteBuddyLocalClassesEnhancerTask, ListProperty<Directory>> {

/**
* The singleton instance.
*/
INSTANCE;

/**
* {@inheritDoc}
*/
public ListProperty<Directory> invoke(LegacyByteBuddyLocalClassesEnhancerTask task) {
return task.getLocalClassesDirs();
}
}

/**
* A function representation of getting the output directory.
*/
protected enum GetOutputDirFunction implements Function1<LegacyByteBuddyLocalClassesEnhancerTask, DirectoryProperty> {

/**
* The singleton instance.
*/
INSTANCE;

/**
* {@inheritDoc}
*/
public DirectoryProperty invoke(LegacyByteBuddyLocalClassesEnhancerTask task) {
return task.getOutputDir();
}
}
}

/**
Expand Down Expand Up @@ -526,8 +562,8 @@ protected ForApk74CompatibleAndroid(Method forScope, Method use, Method toTransf
*/
public void accept(Project project, Variant variant, Configuration configuration, FileCollection classPath) {
TaskProvider<ByteBuddyLocalClassesEnhancerTask> 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,
Expand All @@ -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<ByteBuddyLocalClassesEnhancerTask, ListProperty<RegularFile>> {

/**
* The singleton instance.
*/
INSTANCE;

/**
* {@inheritDoc}
* A function representation of resolving local jars.
*/
public ListProperty<RegularFile> invoke(ByteBuddyLocalClassesEnhancerTask task) {
return task.getLocalJars();
protected enum GetLocalJarsFunction implements Function1<ByteBuddyLocalClassesEnhancerTask, ListProperty<RegularFile>> {

/**
* The singleton instance.
*/
INSTANCE;

/**
* {@inheritDoc}
*/
public ListProperty<RegularFile> invoke(ByteBuddyLocalClassesEnhancerTask task) {
return task.getLocalJars();
}
}
}

/**
* A function representation of getting the local classes directory.
*/
enum GetLocalClassesDirsFunction implements Function1<ByteBuddyLocalClassesEnhancerTask, ListProperty<Directory>> {

/**
* The singleton instance.
* A function representation of getting the local classes directory.
*/
INSTANCE;

/**
* {@inheritDoc}
*/
public ListProperty<Directory> invoke(ByteBuddyLocalClassesEnhancerTask task) {
return task.getLocalClassesDirs();
protected enum GetLocalClassesDirsFunction implements Function1<ByteBuddyLocalClassesEnhancerTask, ListProperty<Directory>> {

/**
* The singleton instance.
*/
INSTANCE;

/**
* {@inheritDoc}
*/
public ListProperty<Directory> invoke(ByteBuddyLocalClassesEnhancerTask task) {
return task.getLocalClassesDirs();
}
}
}

/**
* A function representation of getting the output directory.
*/
enum GetOutputDirFunction implements Function1<LegacyByteBuddyLocalClassesEnhancerTask, DirectoryProperty> {

/**
* 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<ByteBuddyLocalClassesEnhancerTask, RegularFileProperty> {

/**
* 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<ByteBuddyLocalClassesEnhancerTask, RegularFileProperty> {

/**
* The singleton instance.
*/
INSTANCE;

/**
* {@inheritDoc}
*/
public RegularFileProperty invoke(ByteBuddyLocalClassesEnhancerTask task) {
return task.getOutputFile();
}
}
void accept(Project project, Variant variant, Configuration configuration, FileCollection classPath);
}
}
}

0 comments on commit 140e3d0

Please sign in to comment.