Class DefaultBuildContext
- All Implemented Interfaces:
AutoCloseable, BuildContext
-
Field Summary
Fields inherited from interface BuildContext
BUILD_EXTENSIONS, EXTENSIONS_SNAPSHOT_REPOSITORY, JDBLD_COMMON_DIRECTORY, JDBLD_DIRECTORY, JDBLD_VERSION -
Method Summary
Modifier and TypeMethodDescriptionReturns the build root.<T> TCall within this context.voidclose()Close the context.org.apache.commons.cli.CommandLineThe command line as processed by Apache Commons CLI.static Optional<DefaultBuildContext> context()Returns the context.static AbstractRootProjectcreateProjects(Path buildRoot, Class<? extends RootProject> rootProject, List<Class<? extends Project>> subprojects, Properties jdbldProps, org.apache.commons.cli.CommandLine commandLine) Creates and initializes the root project and the sub projects.error()Returns aPrintStreamfor errors.Executing future streams.executor()Returns the executor service used by this build to create futures.voidexecutor(ExecutorService executor) Sets the executor service used by this build to create futures.static booleanChecks if is provider invocation is allowed.out()Returns thePrintStreamfor the standard output.Returns the value of the given property.resources(ResourceProvider provider, ResourceRequest<T> requested) Obtains the stream of resources of the given type from the given provider.Returns the status line for the current thread.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BuildContext
commonCacheDirectory, jdbldDirectory
-
Method Details
-
executor
Returns the executor service used by this build to create futures.- Returns:
- the executor service
-
executor
Sets the executor service used by this build to create futures.- Parameters:
executor- the executor
-
executingFutureStreams
Executing future streams.- Returns:
- the awaitable counter
-
buildRoot
-
commandLine
Description copied from interface:BuildContextThe command line as processed by Apache Commons CLI.- Specified by:
commandLinein interfaceBuildContext- Returns:
- the parsed command line
-
property
Description copied from interface:BuildContextReturns the value of the given property. Properties are defined by (in order of precedence):
- command line options
- the file
.jdbld.propertiesin the directory of the root project - the file
.jdbld/jdbld.propertiesin the user's home directory
- Specified by:
propertyin interfaceBuildContext- Parameters:
name- the namedefaultValue- the default value- Returns:
- the string
-
context
-
call
-
statusLine
Description copied from interface:BuildContextReturns the status line for the current thread. The status line may be used by
ResourceProviders to indicate progress during the execution ofResourceProviderSpi.provide(ResourceRequest). AStatusLineis automatically allocated by the context whenBuildContext.resources(ResourceProvider, ResourceRequest)is invoked.When called while not executing
BuildContext.resources(ResourceProvider, ResourceRequest), this method returns a dummy status line that discards all updates.- Specified by:
statusLinein interfaceBuildContext- Returns:
- the status line
-
out
Description copied from interface:BuildContextReturns thePrintStreamfor the standard output.- Specified by:
outin interfaceBuildContext- Returns:
- the prints the stream
-
error
Description copied from interface:BuildContextReturns aPrintStreamfor errors. The data is sent to the standard output stream as withBuildContext.out(), but it is marked, typically in red, to indicate an error.- Specified by:
errorin interfaceBuildContext- Returns:
- the prints the stream
-
resources
public <T extends Resource> Stream<T> resources(ResourceProvider provider, ResourceRequest<T> requested) Description copied from interface:BuildContextObtains the stream of resources of the given type from the given provider. The result from invoking the provider is evaluated asynchronously and cached. Only when the returned stream is terminated will the invocation block until the result from the provider becomes available.
To avoid duplicate invocations of a non-project provider, any intends are removed from the request before such a provider is invoked.
- Specified by:
resourcesin interfaceBuildContext- Type Parameters:
T- the resource type- Parameters:
provider- the providerrequested- the request- Returns:
- the results
-
isProviderInvocationAllowed
Checks if is provider invocation is allowed. Clears the allowed flag to also detect nested invocations.- Returns:
- true, if is provider invocation allowed
-
close
Description copied from interface:BuildContextClose the context. The re-declaration of this method removes theIOException, which is never thrown.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceBuildContext
-
createProjects
public static AbstractRootProject createProjects(Path buildRoot, Class<? extends RootProject> rootProject, List<Class<? extends Project>> subprojects, Properties jdbldProps, org.apache.commons.cli.CommandLine commandLine) Creates and initializes the root project and the sub projects. Adds the sub projects to the root project automatically. This method should be used if the launcher detects the sub projects e.g. by reflection and the root project does not add its sub projects itself.- Parameters:
buildRoot- the build rootrootProject- the root projectsubprojects- the sub projectsjdbldProps- the builder propertiescommandLine- the command line- Returns:
- the root project
-