name.remal.classes-processing

Plugin class: name.remal.gradle_plugins.plugins.classes_processing.ClassesProcessingPlugin

plugins {
    id 'name.remal.classes-processing' version '1.0.178'
}
plugins {
    id("name.remal.classes-processing") version "1.0.178"
}

 

The plugin applies plugin name.remal.common-settings.

 

This plugin add output classes processing for all tasks of type AbstractCompile. Basically sources of all JVM languages are built by such task.

Classes processing is implemented by services of type ClassesProcessor. Such services can be also created by ClassesProcessorsGradleTaskFactory factories.

The services and factories are loaded using ServiceLoader mechanism. Their class files are accessible using name.remal:gradle-plugins-api:1.0.178 Maven compile-only dependency.

 

name.remal.gradle_plugins.api.classes_processing.ClassesProcessor

Method Description
void process(byte[] bytecode, BytecodeModifier bytecodeModifier, String className, String resourceName, ProcessContext context) This method is executed for each being processed class file.
int getStage() Returns stage number for the processor. Processors are sorted by stage first and then by order.
int getOrder() Returns order number within stage for the processor. Processors are sorted by stage first and then by order.

name.remal.gradle_plugins.api.classes_processing.BytecodeModifier

Method Description
void modify(byte[] modifiedBytecode) Write modified bytecode.

name.remal.gradle_plugins.api.classes_processing.ProcessContext

Property Type Description
classesDir File Class files root directory.
classpath List<File> Compilation classpath.
classpathClassLoader ClassLoader Compilation classpath class loader.
Method Description
boolean doesResourceExist(String relativePath) Checks if resource exists in classesDir.
byte[]? readBinaryResource(String relativePath) Read binary resource from classesDir. Returns null if it doesn't exist.
String? readTextResource(String relativePath) Read text resource from classesDir. Returns null if it doesn't exist.
void writeBinaryResource(String relativePath, byte[] content) Write binary resource to classesDir.
void writeTextResource(String relativePath, String content) Write text resource to classesDir using UTF-8 charset.
void appendTextResource(String relativePath, String content) Append text resource to classesDir using UTF-8 charset.
void writeService(String serviceName, String implementationName) Add implementation class name to corresponding file in META-INF/services/<service-name>. It's used for ServiceLoader mechanism.
void writeService(Class<?> serviceClass, String implementationName) Add implementation class name to corresponding file in META-INF/services/<service-name>. It's used for ServiceLoader mechanism.
void writeService(String serviceName, Class<?> implementationClass) Add implementation class name to corresponding file in META-INF/services/<service-name>. It's used for ServiceLoader mechanism.
void writeService(Class<?> serviceClass, Class<?> implementationClass) Add implementation class name to corresponding file in META-INF/services/<service-name>. It's used for ServiceLoader mechanism.
boolean doesClasspathResourceExist(String relativePath) Checks if resource exists in classpath.
byte[]? readClasspathBinaryResource(String relativePath) Read binary resource from classpath. Returns null if it doesn't exist.
String? readClasspathTextResource(String relativePath) Read text resource from classpath. Returns null if it doesn't exist.

name.remal.gradle_plugins.api.classes_processing.ClassesProcessorsGradleTaskFactory

Method Description
List<ClassesProcessor> createClassesProcessors(AbstractCompile compileTask) Create a list of ClassesProcessor instances for specified AbstractCompile task.