Class Compiler

java.lang.Object
com.karuslabs.elementary.Compiler

public class Compiler extends Object
Represents a Java compiler.
  • Method Details

    • javac

      public static Compiler javac()
      Creates a Java compiler.
      Returns:
      a Java compiler
    • compile

      public Results compile(JavaFileObject... files)
      Compiles the given Java source files.
      Parameters:
      files - the Java source files to be compiled
      Returns:
      the results of this compilation
    • compile

      public Results compile(Iterable<? extends JavaFileObject> files)
      Compiles the given Java source files.
      Parameters:
      files - the Java source files to be compiled
      Returns:
      the results of this compilation
    • processors

      public Compiler processors(Processor... processors)
      Adds the given annotation processors to this Compiler.
      Parameters:
      processors - the annotation processors
      Returns:
      this
    • processors

      public Compiler processors(Collection<Processor> processors)
      Adds the given annotation processors to this Compiler.
      Parameters:
      processors - the annotation processors
      Returns:
      this
    • options

      public Compiler options(String... options)
      Adds the given compiler options to this Compiler.
      Parameters:
      options - the compiler options
      Returns:
      this
      See Also:
    • options

      public Compiler options(Collection<String> options)
      Adds the given compiler options to this Compiler.
      Parameters:
      options - the compiler options
      Returns:
      this
      See Also:
    • module

      public Compiler module(Module module)
      Adds the module and its transitive dependencies to the compilation classpath.
      Parameters:
      module - the module
      Returns:
      this
    • currentClasspath

      public Compiler currentClasspath()
      Adds the current classpath as the compilation classpath.
      Returns:
      this
    • classpath

      public Compiler classpath(ClassLoader loader)
      Adds the classpath of the given ClassLoader as the compilation classpath.
      Parameters:
      loader - the ClassLoader which classpath is to be used during compilation
      Returns:
      this
      Throws:
      IllegalArgumentException - if the given ClassLoader or its parents are neither URLClassLoaders nor the system/platform classloader, or if they contain a classpath with folders
    • classpath

      public Compiler classpath(Collection<File> files)
      Adds the given classpath as the compilation classpath.
      Parameters:
      files - the compilation classpath
      Returns:
      this