|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.android.build.api.transform.Transform
@Beta public abstract class Transform
A Transform that processes intermediary build artifacts.
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
JarInputs and DirectoryInputs.
Both provide information about the QualifiedContent.Scopes and QualifiedContent.ContentTypes 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 Summary | |
|---|---|
Transform()
|
|
| Method Summary | |
|---|---|
abstract java.util.Set<QualifiedContent.ContentType> |
getInputTypes()
Returns the type(s) of data that is consumed by the Transform. |
abstract java.lang.String |
getName()
Returns the unique name of the transform. |
java.util.Set<QualifiedContent.ContentType> |
getOutputTypes()
Returns the type(s) of data that is generated by the Transform. |
java.util.Map<java.lang.String,java.lang.Object> |
getParameterInputs()
Returns a map of non-file input parameters using a unique identifier as the map key. |
java.util.Set<QualifiedContent.Scope> |
getReferencedScopes()
Returns the referenced scope(s) for the Transform. |
abstract java.util.Set<QualifiedContent.Scope> |
getScopes()
Returns the scope(s) of the Transform. |
java.util.Collection<java.io.File> |
getSecondaryDirectoryOutputs()
Returns a list of additional (out of streams) directory(ies) that this Transform creates. |
java.util.Collection<java.io.File> |
getSecondaryFileInputs()
Returns a list of additional file(s) that this Transform needs to run. |
java.util.Collection<java.io.File> |
getSecondaryFileOutputs()
Returns a list of additional (out of streams) file(s) that this Transform creates. |
abstract boolean |
isIncremental()
Returns whether the Transform can perform incremental work. |
abstract void |
transform(Context context,
java.util.Collection<TransformInput> inputs,
java.util.Collection<TransformInput> referencedInputs,
TransformOutputProvider outputProvider,
boolean isIncremental)
Executes the Transform. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Transform()
| Method Detail |
|---|
@NonNull public abstract java.lang.String getName()
@NonNull public abstract java.util.Set<QualifiedContent.ContentType> getInputTypes()
QualifiedContent.DefaultContentType
@NonNull public java.util.Set<QualifiedContent.ContentType> getOutputTypes()
getInputTypes().
This must be of type QualifiedContent.DefaultContentType
@NonNull public abstract java.util.Set<QualifiedContent.Scope> getScopes()
@NonNull public java.util.Set<QualifiedContent.Scope> getReferencedScopes()
@NonNull public java.util.Collection<java.io.File> getSecondaryFileInputs()
@NonNull public java.util.Collection<java.io.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 java.util.Collection<java.io.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 java.util.Map<java.lang.String,java.lang.Object> getParameterInputs()
public abstract boolean isIncremental()
public abstract void transform(@NonNull
Context context,
@NonNull
java.util.Collection<TransformInput> inputs,
@NonNull
java.util.Collection<TransformInput> referencedInputs,
@Nullable
TransformOutputProvider outputProvider,
boolean isIncremental)
throws java.io.IOException,
TransformException,
java.lang.InterruptedException
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
getSecondaryFileInputs(),
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.
context - the context in which the transform is run.inputs - the inputs/outputs of the transform.referencedInputs - the referenced-only inputs.outputProvider - the output provider allowing to create content.isIncremental - whether the transform execution is incremental.
java.io.IOException - if an IO error occurs.
java.lang.InterruptedException
TransformException - Generic exception encapsulating the cause.
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||