Class DefaultBuildContext

java.lang.Object
org.jdrupes.builder.core.DefaultBuildContext
All Implemented Interfaces:
AutoCloseable, BuildContext

public class DefaultBuildContext extends Object implements BuildContext
A context for building.
  • Method Details

    • executor

      Returns the executor service used by this build to create futures.
      Returns:
      the executor service
    • executor

      public void executor(ExecutorService 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

      public Path buildRoot()
      Returns the build root.
      Returns:
      the path
    • commandLine

      public org.apache.commons.cli.CommandLine commandLine()
      Description copied from interface: BuildContext
      The command line as processed by Apache Commons CLI.
      Specified by:
      commandLine in interface BuildContext
      Returns:
      the parsed command line
    • property

      public String property(String name, String defaultValue)
      Description copied from interface: BuildContext

      Returns the value of the given property. Properties are defined by (in order of precedence):

      1. command line options
      2. the file .jdbld.properties in the directory of the root project
      3. the file .jdbld/jdbld.properties in the user's home directory
      Specified by:
      property in interface BuildContext
      Parameters:
      name - the name
      defaultValue - the default value
      Returns:
      the string
    • context

      Returns the context.
      Returns:
      the optional
    • call

      public <T> T call(Supplier<T> supplier)
      Call within this context.
      Type Parameters:
      T - the generic type
      Parameters:
      supplier - the supplier
      Returns:
      the t
    • statusLine

      Description copied from interface: BuildContext

      Returns the status line for the current thread. The status line may be used by ResourceProviders to indicate progress during the execution of ResourceProviderSpi.provide(ResourceRequest). A StatusLine is automatically allocated by the context when BuildContext.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:
      statusLine in interface BuildContext
      Returns:
      the status line
    • out

      public PrintStream out()
      Description copied from interface: BuildContext
      Returns the PrintStream for the standard output.
      Specified by:
      out in interface BuildContext
      Returns:
      the prints the stream
    • error

      public PrintStream error()
      Description copied from interface: BuildContext
      Returns a PrintStream for errors. The data is sent to the standard output stream as with BuildContext.out(), but it is marked, typically in red, to indicate an error.
      Specified by:
      error in interface BuildContext
      Returns:
      the prints the stream
    • resources

      public <T extends Resource> Stream<T> resources(ResourceProvider provider, ResourceRequest<T> requested)
      Description copied from interface: BuildContext

      Obtains 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:
      resources in interface BuildContext
      Type Parameters:
      T - the resource type
      Parameters:
      provider - the provider
      requested - the request
      Returns:
      the results
    • isProviderInvocationAllowed

      public static boolean 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

      public void close()
      Description copied from interface: BuildContext
      Close the context. The re-declaration of this method removes the IOException, which is never thrown.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface BuildContext
    • 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 root
      rootProject - the root project
      subprojects - the sub projects
      jdbldProps - the builder properties
      commandLine - the command line
      Returns:
      the root project