Package io.quarkus.builder
Class BuildContext
- java.lang.Object
-
- io.quarkus.builder.BuildContext
-
public final class BuildContext extends Object
The context passed to a deployer's operation.- Author:
- David M. Lloyd
-
-
Constructor Summary
Constructors Constructor Description BuildContext(ClassLoader classLoader, StepInfo stepInfo, Execution execution)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T extends SimpleBuildItem>
Tconsume(Class<T> type)Consume the value produced for the named item.<T extends MultiBuildItem>
List<T>consumeMulti(Class<T> type)Consume all the values produced for the named item.<T extends MultiBuildItem>
List<T>consumeMulti(Class<T> type, Comparator<? super T> comparator)Consume all the values produced for the named item, re-sorting it according to the given comparator.(package private) voiddepFinished()voiderror(Location location, String format, Object... args)Emit a build error.StringgetBuildTargetName()Get the name of this build target.ExecutorServicegetExecutor()Get an executor which can be used for asynchronous tasks.booleanisAvailableToConsume(Class<? extends BuildItem> type)Determine if an item was produced and is therefore available to be consumed.booleanisConsumed(Class<? extends BuildItem> type)Determine if an item will be consumed in this build.voidnote(Location location, String format, Object... args)Emit a build note.voidproduce(BuildItem item)Produce the given item.<T extends BuildItem>
voidproduce(Class<T> type, T item)Produce the given item.voidproduce(List<? extends MultiBuildItem> items)Produce the given items.(package private) voidrun()voidwarn(Location location, String format, Object... args)Emit a build warning.
-
-
-
Constructor Detail
-
BuildContext
BuildContext(ClassLoader classLoader, StepInfo stepInfo, Execution execution)
-
-
Method Detail
-
getBuildTargetName
public String getBuildTargetName()
Get the name of this build target. The resultant string is useful for diagnostic messages and does not have any other significance.- Returns:
- the name of this build target (not
null)
-
produce
public void produce(BuildItem item)
Produce the given item. If thetyperefers to an item which is declared with multiplicity, then this method can be called more than once for the giventype, otherwise it must be called no more than once.- Parameters:
item- the item value (must not benull)- Throws:
IllegalArgumentException- if the item does not allow multiplicity but this method is called more than one time, or if the type of item could not be determined
-
produce
public void produce(List<? extends MultiBuildItem> items)
Produce the given items. This method can be called more than once for the giventype- Parameters:
items- the items (must not benull)- Throws:
IllegalArgumentException- if the type of item could not be determined
-
produce
public <T extends BuildItem> void produce(Class<T> type, T item)
Produce the given item. If thetyperefers to an item which is declared with multiplicity, then this method can be called more than once for the giventype, otherwise it must be called no more than once.- Parameters:
type- the item type (must not benull)item- the item value (may benull)- Throws:
IllegalArgumentException- if this deployer was not declared to producetype, or iftypeisnull, or if the item does not allow multiplicity but this method is called more than one time
-
consume
public <T extends SimpleBuildItem> T consume(Class<T> type)
Consume the value produced for the named item.- Parameters:
type- the item type (must not benull)- Returns:
- the produced item (may be
null) - Throws:
IllegalArgumentException- if this deployer was not declared to consumetype, or iftypeisnullClassCastException- if the cast failed
-
consumeMulti
public <T extends MultiBuildItem> List<T> consumeMulti(Class<T> type)
Consume all the values produced for the named item. If the item type implementsComparable, it will be sorted by natural order before return. The returned list is a mutable copy.- Parameters:
type- the item element type (must not benull)- Returns:
- the produced items (may be empty, will not be
null) - Throws:
IllegalArgumentException- if this deployer was not declared to consumetype, or iftypeisnull
-
consumeMulti
public <T extends MultiBuildItem> List<T> consumeMulti(Class<T> type, Comparator<? super T> comparator)
Consume all the values produced for the named item, re-sorting it according to the given comparator. The returned list is a mutable copy.- Parameters:
type- the item element type (must not benull)comparator- the comparator to use (must not benull)- Returns:
- the produced items (may be empty, will not be
null) - Throws:
IllegalArgumentException- if this deployer was not declared to consumetype, or iftypeisnull
-
isAvailableToConsume
public boolean isAvailableToConsume(Class<? extends BuildItem> type)
Determine if an item was produced and is therefore available to be consumed.- Parameters:
type- the item type (must not benull)- Returns:
trueif the item was produced and is available,falseif it was not or if this deployer does not consume the named item
-
isConsumed
public boolean isConsumed(Class<? extends BuildItem> type)
Determine if an item will be consumed in this build. If an item is not consumed, then build steps are not required to produce it.- Parameters:
type- the item type (must not benull)- Returns:
trueif the item will be consumed,falseif it will not be or if this deployer does not produce the named item
-
note
public void note(Location location, String format, Object... args)
Emit a build note. This indicates information that the user may be interested in.- Parameters:
location- the location of interest (may benull)format- the format string (seeString.format(String, Object...))args- the format arguments
-
warn
public void warn(Location location, String format, Object... args)
Emit a build warning. This indicates a significant build problem that the user should be made aware of.- Parameters:
location- the location of interest (may benull)format- the format string (seeString.format(String, Object...))args- the format arguments
-
error
public void error(Location location, String format, Object... args)
Emit a build error. This indicates a build problem that prevents the build from proceeding.- Parameters:
location- the location of interest (may benull)format- the format string (seeString.format(String, Object...))args- the format arguments
-
getExecutor
public ExecutorService getExecutor()
Get an executor which can be used for asynchronous tasks.- Returns:
- an executor which can be used for asynchronous tasks
-
depFinished
void depFinished()
-
run
void run()
-
-