@Beta public abstract class Transform extends Object
For each added transform, a new task is created. The action of adding a transform takes care of handling dependencies between the tasks. This is done based on what the transform processes. The output of the transform becomes consumable by other transforms and these tasks get automatically linked together.
The Transform indicates what it applies to (content, scope) and what it generates (content). A transform receives input as a collectionTransformInput
, which is composed of
JarInput
s and DirectoryInput
s.
Both provide information about the QualifiedContent.Scope
s and QualifiedContent.ContentType
s associated with their
particular content.
The output is handled by TransformOutputProvider
which allows creating new self-contained
content, each associated with their own Scopes and Content Types.
The content handled by TransformInput/Output is managed by the transform system, and their
location is not configurable.
It is best practice to write into as many outputs as Jar/Folder Inputs have been received by the
transform. Combining all the inputs into a single output prevents downstream transform from
processing limited scopes.
While it's possible to differentiate different Content Types by file extension, it's not possible
to do so for Scopes. Therefore if a transform request a Scope but the only available Output
contains more than the requested Scope, the build will fail.getScopes()
return an empty list and use
getReferencedScopes()
to indicate what to read instead.
This API is non final and is subject to change. We are looking for feedback, and will
attempt to stabilize it in the 1.6 time frame.Constructor and Description |
---|
Transform() |
Modifier and Type | Method and Description |
---|---|
abstract Set<QualifiedContent.ContentType> |
getInputTypes()
Returns the type(s) of data that is consumed by the Transform.
|
abstract String |
getName()
Returns the unique name of the transform.
|
Set<QualifiedContent.ContentType> |
getOutputTypes()
Returns the type(s) of data that is generated by the Transform.
|
Map<String,Object> |
getParameterInputs()
Returns a map of non-file input parameters using a unique identifier as the map key.
|
Set<QualifiedContent.Scope> |
getReferencedScopes()
Returns the referenced scope(s) for the Transform.
|
abstract Set<QualifiedContent.Scope> |
getScopes()
Returns the scope(s) of the Transform.
|
Collection<File> |
getSecondaryDirectoryOutputs()
Returns a list of additional (out of streams) directory(ies) that this Transform creates.
|
Collection<File> |
getSecondaryFileInputs()
Deprecated.
|
Collection<File> |
getSecondaryFileOutputs()
Returns a list of additional (out of streams) file(s) that this Transform creates.
|
Collection<SecondaryFile> |
getSecondaryFiles()
Returns a list of additional file(s) that this Transform needs to run.
|
abstract boolean |
isIncremental()
Returns whether the Transform can perform incremental work.
|
void |
transform(Context context,
Collection<TransformInput> inputs,
Collection<TransformInput> referencedInputs,
TransformOutputProvider outputProvider,
boolean isIncremental)
Deprecated.
|
void |
transform(TransformInvocation transformInvocation)
Executes the Transform.
|
@NonNull public abstract String getName()
@NonNull public abstract Set<QualifiedContent.ContentType> getInputTypes()
QualifiedContent.DefaultContentType
@NonNull public Set<QualifiedContent.ContentType> getOutputTypes()
getInputTypes()
.
This must be of type QualifiedContent.DefaultContentType
@NonNull public abstract Set<QualifiedContent.Scope> getScopes()
@NonNull public Set<QualifiedContent.Scope> getReferencedScopes()
@Deprecated @NonNull public Collection<File> getSecondaryFileInputs()
getSecondaryFiles()
API which allow eah secondary file to indicate if changes
can be handled incrementally or not. This API will treat all additional file change as
a non incremental event.
Changes to files returned in this list will trigger a new execution of the Transform
even if the qualified-content inputs haven't been touched.
Any changes to these files will trigger a non incremental execution.
The default implementation returns an empty collection.@NonNull public Collection<SecondaryFile> getSecondaryFiles()
@NonNull public Collection<File> getSecondaryFileOutputs()
getSecondaryDirectoryOutputs()
Changes to files returned in this list will trigger a new execution of the Transform
even if the qualified-content inputs haven't been touched.
Changes to these output files force a non incremental execution.
The default implementation returns an empty collection.@NonNull public Collection<File> getSecondaryDirectoryOutputs()
getSecondaryFileOutputs()
Changes to directories returned in this list will trigger a new execution of the Transform
even if the qualified-content inputs haven't been touched.
Changes to these output directories force a non incremental execution.
The default implementation returns an empty collection.@NonNull public Map<String,Object> getParameterInputs()
public abstract boolean isIncremental()
@Deprecated public void transform(@NonNull Context context, @NonNull Collection<TransformInput> inputs, @NonNull Collection<TransformInput> referencedInputs, @Nullable TransformOutputProvider outputProvider, boolean isIncremental) throws IOException, TransformException, InterruptedException
public void transform(@NonNull TransformInvocation transformInvocation) throws TransformException, InterruptedException, IOException
TransformInvocation
TransformInput
. These are the inputs
that are consumed by this Transform. A transformed version of these inputs must
be written into the output. What is received is controlled through
getInputTypes()
, and getScopes()
.TransformInput
. This is
for reference only and should be not be transformed. What is received is controlled
through getReferencedScopes()
.getScopes()
, and what it wants to
see in getReferencedScopes()
.
Even though a transform's isIncremental()
returns true, this method may
be receive false
in isIncremental. This can be due to
getSecondaryFiles()
,
getSecondaryFileOutputs()
, getSecondaryDirectoryOutputs()
)getParameterInputs()
)JarInput.getStatus()
will return Status.NOTCHANGED
even though
the file may be added/changed.DirectoryInput.getChangedFiles()
will return an empty map even though
some files may be added/changed.transformInvocation
- the invocation object containing the transform inputs.IOException
- if an IO error occurs.InterruptedException
TransformException
- Generic exception encapsulating the cause.