Schnittstelle TransformAction<T extends TransformParameters>
- Typparameter:
T- Parameter type for the transform action. Should beTransformParameters.Noneif the action does not have parameters.
public interface TransformAction<T extends TransformParameters>
Interface for artifact transform actions.
A transform action implementation is an abstract class implementing the transform(TransformOutputs) method.
A minimal implementation may look like this:
import org.gradle.api.artifacts.transform.TransformParameters;
public abstract class MyTransform implements TransformAction<TransformParameters.None> {
@InputArtifact
public abstract Provider<FileSystemLocation> getInputArtifact();
@Override
public void transform(TransformOutputs outputs) {
File input = getInputArtifact().get().getAsFile();
File output = outputs.file(input.getName() + ".transformed");
// Do something to generate output from input
}
}
Implementations of TransformAction are subject to the following constraints:
- Do not implement
getParameters()in your class, the method will be implemented by Gradle. - Implementations may only have a default constructor.
- An abstract getter annotated with
InputArtifactwill receive the input artifact location, which is the file or directory that the transform should be applied to. - An abstract getter with
InputArtifactDependencieswill receive the dependencies of its input artifact.
- Seit:
- 5.3
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungThe object provided byTransformSpec.getParameters()when registering the artifact transform.voidtransform(TransformOutputs outputs) Executes the transform.
-
Methodendetails
-
getParameters
The object provided byTransformSpec.getParameters()when registering the artifact transform.Do not implement this method in your subclass. Gradle provides the implementation when registering the transform action via
DependencyHandler.registerTransform(Class, Action). -
transform
Executes the transform.This method must be implemented in the subclass.
- Parameter:
outputs- Receives the outputs of the transform.
-