Class Builder

java.lang.Object
com.github.sormuras.bach.Builder

public class Builder extends Object
A modular Java project builder.
  • Constructor Details

    • Builder

      public Builder(Bach bach, Project project)
      Initialize this builder with the given components.
      Parameters:
      bach - the underlying Bach instance
      project - the project to build
  • Method Details

    • bach

      public Bach bach()
      Returns:
      the underlying Bach instance
    • project

      public Project project()
      Returns:
      the project to build
    • build

      public void build()
      Builds a modular Java project.
    • loadRequiredAndMissingModules

      public void loadRequiredAndMissingModules()
      Load required and missing modules in a best-effort manner.
    • computeModuleLookup

      public ModuleLookup computeModuleLookup()
      Returns a module lookup composed of external module links and best-effort lookup.
      Returns:
      a module lookup
    • buildAllSpaces

      public void buildAllSpaces(CodeSpaces spaces)
      Builds all code spaces.
      Parameters:
      spaces - the code spaces to build
    • buildMainCodeSpace

      public void buildMainCodeSpace(MainCodeSpace main)
      Builds the main space.
      • javac + jar
      • javadoc
      • jlink
      • jpackage
      Parameters:
      main - the main space to build
    • computeMainJavacCall

      public ToolCall computeMainJavacCall(int release)
      Parameters:
      release - the release
      Returns:
      the javac call to compile all modules of the main space
    • computeMainJavacCall

      public ToolCall computeMainJavacCall(String module, SourceFolder folder)
      Parameters:
      module - the name of the module to compile
      folder - the source folder to compile
      Returns:
      the javac call to compile a version of a multi-release module
    • buildMainSingleReleaseVintageModules

      public void buildMainSingleReleaseVintageModules(int mainRelease)
      Builds all modules targeting Java 7 or Java 8.
      Parameters:
      mainRelease - the main classes release feature number
    • computeMainJarCall

      public ToolCall computeMainJarCall(ModuleDeclaration module)
      Parameters:
      module - the module declaration to create an archive for
      Returns:
      the jar call to archive all assets for the given module
    • computeMainJarFileName

      public String computeMainJarFileName(ModuleDeclaration module)
      Parameters:
      module - the module declaration
      Returns:
      the name of the JAR file for the given module declaration
    • computeMainJarTargetedDirectories

      public TreeMap<Integer,​List<Path>> computeMainJarTargetedDirectories(ModuleDeclaration module)
      Parameters:
      module - the module declaration
      Returns:
      a map with "release to list-of-path" entries
    • computeMainDocumentationJavadocCall

      public ToolCall computeMainDocumentationJavadocCall()
      Returns:
      the javadoc call generating the API documentation for all main modules
    • computeMainDocumentationJarCall

      public ToolCall computeMainDocumentationJarCall()
      Returns:
      the jar call generating the API documentation archive
    • computeMainJLinkCall

      public ToolCall computeMainJLinkCall()
      Returns:
      the jllink call
    • buildTestCodeSpace

      public void buildTestCodeSpace(TestCodeSpace test)
      Builds the test space.
      • javac + jar
      • junit
      Parameters:
      test - the test space to build
    • computeTestJavacCall

      public ToolCall computeTestJavacCall()
      Returns:
      the javac call to compile all modules of the test space.
    • computeTestJarCall

      public ToolCall computeTestJarCall(ModuleDeclaration declaration)
      Parameters:
      declaration - the module declaration to create an archive for
      Returns:
      the jar call to archive all assets for the given module
    • computeTestJUnitCall

      public ToolCall computeTestJUnitCall(ModuleDeclaration declaration)
      Parameters:
      declaration - the module declaration to scan for tests
      Returns:
      the junit call to launch the JUnit Platform for
    • isGenerateApiDocumentation

      public boolean isGenerateApiDocumentation()
      Returns:
      true if an API documenation should be generated, else false
    • isGenerateCustomRuntimeImage

      public boolean isGenerateCustomRuntimeImage()
      Returns:
      true if a custom runtime image should be generated, else false
    • isGenerateMavenPomFiles

      public boolean isGenerateMavenPomFiles()
      Returns:
      true if a custom runtime image should be generated, else false
    • isIncludeSourcesInModules

      public boolean isIncludeSourcesInModules()
      Returns:
      true if a custom runtime image should be generated, else false
    • run

      public void run(ToolCall call)
      Runs the given tool call.
      Parameters:
      call - the tool call to run
    • run

      public void run(Stream<ToolCall> calls)
      Runs tool calls of the given stream in parallel.
      Parameters:
      calls - the tool calls to run
    • computeToolCallArgumentsDescription

      public String computeToolCallArgumentsDescription(ToolCall call, int maxLineLength)
      Returns a description of the given tool call.
      Parameters:
      call - the tool call to describe
      maxLineLength - the maximum number of characters to return
      Returns:
      a string that describes a tool call