Class JavaTool

All Implemented Interfaces:
Generator, Renamable, ResourceProvider
Direct Known Subclasses:
JavaCompiler, Javadoc

public abstract class JavaTool extends AbstractGenerator
A base class for generators that invoke java tools.
  • Constructor Details

    • JavaTool

      public JavaTool(Project project)
      Instantiates a new java tool.
      Parameters:
      project - the project
  • Method Details

    • moduleMode

      Returns the current module compilation mode. Defaults to ModuleMode.AUTO, which activates module-path compilation when a module-info.java is found among the sources.
      Returns:
      the module mode
    • moduleMode

      Sets the module compilation mode.
      Parameters:
      moduleMode - the new mode
      Returns:
      the java compiler
    • effectiveModuleMode

      Determines the effective module mode, resolving ModuleMode.AUTO to either ModuleMode.MODULE or ModuleMode.CLASSPATH based on whether a module-info.java exists among the sources.
      Returns:
      the effective mode
    • hasModuleInfo

      protected abstract boolean hasModuleInfo()
      Checks whether a module-info.java exists among the configured sources.
      Returns:
      true, if module-info.java is present
    • options

      public JavaTool options(Stream<String> options)
      Adds the given options.
      Parameters:
      options - the options
      Returns:
      the java tool
    • options

      public JavaTool options(String... options)
      Adds the given options.
      Parameters:
      options - the options
      Returns:
      the java tool
    • options

      public List<String> options()
      Return the options.
      Returns:
      the stream
    • optionArgument

      public Optional<String> optionArgument(String... names)
      Find the argument for the given option. As some options are allows in different styles, several names can be specified.
      Parameters:
      names - the names
      Returns:
      the optional
    • logDiagnostic

      protected void logDiagnostic(Diagnostic<? extends JavaFileObject> diagnostic)
      Log diagnostic.
      Parameters:
      diagnostic - the diagnostic
    • logDiagnostics

      protected void logDiagnostics(DiagnosticCollector<JavaFileObject> diagnostics)
      Log diagnostics.
      Parameters:
      diagnostics - the diagnostics