public abstract class Linker
extends java.lang.Object
LinkerOrder
annotation to determine
the relative ordering of the Linkers. Exact order of Linker execution will be
determined by the order of add-linker
tags in the module
configuration. Each Linker should also be annotated with Shardable
;
non-shardable linkers are deprecated and will eventually not be supported.
A new instance of a linker is created each time a module is compiled or
during hosted mode when a module first loads (or is refreshed). During a
compile, link(TreeLogger, LinkerContext, ArtifactSet)
is called
exactly once on each non-shardable linker, and the artifact set will contain
any and all generated artifacts. For shardable linkers,
link(TreeLogger, LinkerContext, ArtifactSet, boolean)
is called once
for each compiled permutation and once after all compiles are finished. The
precise artifacts supplied differ with each call and are described in the
method's documentation.
When hosted mode starts for a module, it calls
link(TreeLogger, LinkerContext, ArtifactSet)
for non-shardable
linkers and link(TreeLogger, LinkerContext, ArtifactSet, boolean)
for shardable ones, passing false
as the
onePermutation
argument. If any artifacts are subsequently
generated during the course of running hosted mode,
relink(TreeLogger, LinkerContext, ArtifactSet)
will be called with
the new artifacts.
Constructor and Description |
---|
Linker() |
Modifier and Type | Method and Description |
---|---|
abstract java.lang.String |
getDescription()
Returns a human-readable String describing the Linker.
|
boolean |
isShardable()
Check whether this class is considered a shardable linker.
|
ArtifactSet |
link(TreeLogger logger,
LinkerContext context,
ArtifactSet artifacts)
This method is invoked for linkers not annotated with
Shardable . |
ArtifactSet |
link(TreeLogger logger,
LinkerContext context,
ArtifactSet artifacts,
boolean onePermutation)
This method is invoked for linkers annotated with
Shardable . |
ArtifactSet |
relink(TreeLogger logger,
LinkerContext context,
ArtifactSet newArtifacts)
Re-invoke the Linker with newly generated artifacts.
|
boolean |
supportsDevModeInJunit(LinkerContext context)
Returns
true if this linker supports DevMode. |
public abstract java.lang.String getDescription()
public final boolean isShardable()
Shardable
annotation or it
has a field named gwtIsShardable
. If such a field is present,
it doesn't matter what value the field holds. The latter mechanism is only
intended to support linkers that must compile against older versions of
GWT.public ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts) throws UnableToCompleteException
Shardable
. It
sees all artifacts across the whole compile and can modify them
arbitrarily. This method is only called if the linker is not annotated with
Shardable
.logger
- the TreeLogger to record tocontext
- provides access to the Linker's environmentartifacts
- an unmodifiable view of the artifacts to linkUnableToCompleteException
- if compilation violates assumptions made
by the Linker or for errors encountered by the Linkerpublic ArtifactSet link(TreeLogger logger, LinkerContext context, ArtifactSet artifacts, boolean onePermutation) throws UnableToCompleteException
This method is invoked for linkers annotated with Shardable
. It is
called at two points during compilation: after the compile of each
permutation, and after all compilation has finished. The
onePermutation
is true
for a per-permutation call
and false
for a global final-link call.
For one-permutation calls, this method is passed all artifacts generated for just the one permutation. For the global call at the end of compilation, this method sees artifacts for the whole compilation, but with two modifications intended to support builds on computer clusters:
Transferable
have been discarded.
logger
- the TreeLogger to record tocontext
- provides access to the Linker's environmentartifacts
- an unmodifiable view of the artifacts to linkonePermutation
- true for a one-permutation callUnableToCompleteException
- if compilation violates assumptions made
by the Linker or for errors encountered by the Linkerpublic ArtifactSet relink(TreeLogger logger, LinkerContext context, ArtifactSet newArtifacts) throws UnableToCompleteException
link(TreeLogger, LinkerContext, ArtifactSet)
should retain a copy
of the original artifact set in an instance variable.logger
- the TreeLogger to record tocontext
- provides access to the Linker's environmentnewArtifacts
- an unmodifiable view of the newly generated artifactsUnableToCompleteException
- if compilation violates assumptions made
by the Linker or for errors encountered by the Linkerpublic boolean supportsDevModeInJunit(LinkerContext context)
true
if this linker supports DevMode.context
- a LinkerContext