Class CompileOptions

java.lang.Object
rife.bld.extension.kotlin.CompileOptions

public class CompileOptions extends Object
Configuration for the Kotlin compiler options.
Since:
1.0
Author:
Erik C. Thauvin
  • Constructor Details

    • CompileOptions

      public CompileOptions()
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • advancedOptions

      public CompileOptions advancedOptions(@NonNull String... options)
      Specify advanced compiler options.
      Parameters:
      options - one or more advanced options
      Returns:
      this operation instance
      Throws:
      NullPointerException - if options is null
      IllegalArgumentException - if options is empty, or contains null or empty elements
    • advancedOptions

      public final CompileOptions advancedOptions(@NonNull Collection<String> options)
      Specify advanced compiler options.
      Parameters:
      options - the compiler options
      Returns:
      this operation instance
      Throws:
      NullPointerException - if options is null
      IllegalArgumentException - if options is empty, or contains null or empty elements
    • advancedOptions

      public Set<String> advancedOptions()
      Retrieves advanced compiler options.
      Returns:
      the advanced compiler options
    • apiVersion

      public CompileOptions apiVersion(@NonNull String version)
      Allow using declarations only from the specified version of Kotlin bundled libraries.
      Parameters:
      version - the API version
      Returns:
      this operation instance
      Throws:
      NullPointerException - if version is null
      IllegalArgumentException - if version is empty
    • apiVersion

      public CompileOptions apiVersion(int version)
      Allow using declarations only from the specified version of Kotlin bundled libraries.
      Parameters:
      version - the API version
      Returns:
      this operation instance
    • apiVersion

      public String apiVersion()
      Retrieves the version of Kotlin bundled libraries.
      Returns:
      the API version
    • argFile

      public CompileOptions argFile(@NonNull String... files)
      Read the compiler options from the given files.

      Such a file can contain compiler options with values and paths to the source files. Options and paths should be separated by whitespaces. For example:

      • -include-runtime -d hello.jar hello.kt
      To pass values that contain whitespaces, surround them with single (') or double (") quotes. If a value contains quotation marks in it, escape them with a backslash (\).
      • -include-runtime -d 'My folder'
      If the files reside in locations different from the current directory, use relative paths.
      Parameters:
      files - one or more files
      Returns:
      this operation instance
      Throws:
      NullPointerException - if files is null
      IllegalArgumentException - if files is empty, or contains null or empty elements
    • argFile

      public CompileOptions argFile(@NonNull File... files)
      Read the compiler options from the given files.
      Parameters:
      files - one or more files
      Returns:
      this operation instance
      Throws:
      NullPointerException - if files is null
      IllegalArgumentException - if files is empty, or contains null elements
    • argFile

      public CompileOptions argFile(@NonNull Path... files)
      Read the compiler options from the given files.
      Parameters:
      files - one or more files
      Returns:
      this operation instance
      Throws:
      NullPointerException - if files is null
      IllegalArgumentException - if files is empty, or contains null elements
    • argFile

      public final CompileOptions argFile(@NonNull Collection<File> files)
      Read the compiler options from the given files.
      Parameters:
      files - the compiler options files
      Returns:
      this operation instance
      Throws:
      NullPointerException - if files is null
      IllegalArgumentException - if files is empty, or contains null elements
    • argFile

      public List<File> argFile()
      Retrieves the files containing compiler options.
      Returns:
      the compiler options files
    • argFilePaths

      public final CompileOptions argFilePaths(@NonNull Collection<Path> files)
      Read the compiler options from the given files.
      Parameters:
      files - the compiler options files (as Path)
      Returns:
      this operation instance
      Throws:
      NullPointerException - if files is null
      IllegalArgumentException - if files is empty, or contains null elements
    • argFileStrings

      public final CompileOptions argFileStrings(@NonNull Collection<String> files)
      Read the compiler options from the given files.
      Parameters:
      files - the compiler options files (as String)
      Returns:
      this operation instance
      Throws:
      NullPointerException - if files is null
      IllegalArgumentException - if files is empty, or contains null or empty elements
    • args

      public List<String> args()
      Returns the formatted arguments.
      Returns:
      the arguments
    • classpath

      public CompileOptions classpath(@NonNull String... paths)
      Search for class files in the specified paths.

      The classpath can contain file and directory paths, ZIP, or JAR files.

      Parameters:
      paths - one or more paths
      Returns:
      this operation instance
      Throws:
      NullPointerException - if paths is null
      IllegalArgumentException - if paths is empty, or contains null or empty elements
    • classpath

      public CompileOptions classpath(@NonNull File... paths)
      Search for class files in the specified paths.

      The classpath can contain file and directory paths, ZIP, or JAR files.

      Parameters:
      paths - one or more paths
      Returns:
      this operation instance
      Throws:
      NullPointerException - if paths is null
      IllegalArgumentException - if paths is empty, or contains null elements
    • classpath

      public CompileOptions classpath(@NonNull Path... paths)
      Search for class files in the specified paths.

      The classpath can contain file and directory paths, ZIP, or JAR files.

      Parameters:
      paths - one or more paths
      Returns:
      this operation instance
      Throws:
      NullPointerException - if paths is null
      IllegalArgumentException - if paths is empty, or contains null elements
    • classpath

      public final CompileOptions classpath(@NonNull Collection<File> paths)
      Search for class files in the specified paths.

      The classpath can contain file and directory paths, ZIP, or JAR files.

      Parameters:
      paths - the search paths
      Returns:
      this operation instance
      Throws:
      NullPointerException - if paths is null
      IllegalArgumentException - if paths is empty, or contains null elements
    • classpath

      public List<File> classpath()
      Retrieves the class files classpath.
      Returns:
      the class files classpath
    • classpathPaths

      public final CompileOptions classpathPaths(@NonNull Collection<Path> paths)
      Search for class files in the specified paths.
      Parameters:
      paths - the search paths (as Path)
      Returns:
      this operation instance
      Throws:
      NullPointerException - if paths is null
      IllegalArgumentException - if paths is empty, or contains null elements
    • classpathStrings

      public final CompileOptions classpathStrings(@NonNull Collection<String> paths)
      Search for class files in the specified paths.
      Parameters:
      paths - the search paths (as String)
      Returns:
      this operation instance
      Throws:
      NullPointerException - if paths is null
      IllegalArgumentException - if paths is empty, or contains null or empty elements
    • expression

      public CompileOptions expression(@NonNull String expression)
      Evaluate the given string as a Kotlin script.
      Parameters:
      expression - the expression
      Returns:
      this operation instance
      Throws:
      NullPointerException - if expression is null
      IllegalArgumentException - if expression is empty
    • expression

      public String expression()
      Retrieves the string to evaluate as a Kotlin script.
      Returns:
      the expression
    • hasRelease

      public boolean hasRelease()
      Indicates whether jdkRelease(String) was set.
      Returns:
      true if the release was set; or false otherwise
    • hasTarget

      public boolean hasTarget()
      Indicates whether jvmTarget(String) was set.
      Returns:
      true if the target was set; or false otherwise
    • includeRuntime

      public CompileOptions includeRuntime(boolean includeRuntime)
      Include the Kotlin runtime in the resulting JAR file.
      Parameters:
      includeRuntime - true or false
      Returns:
      this operation instance
    • isIncludeRuntime

      public boolean isIncludeRuntime()
      Indicates whether includeRuntime(boolean) was set.
      Returns:
      true or false
    • isJavaParameters

      public boolean isJavaParameters()
      Indicates whether javaParameters(boolean) was set.
      Returns:
      true or false
    • isNoJdk

      public boolean isNoJdk()
      Indicates whether noJdk(boolean) was set.
      Returns:
      true or false
    • isNoReflect

      public boolean isNoReflect()
      Indicates whether noReflect(boolean) was set.
      Returns:
      true or false
    • isNoStdLib

      public boolean isNoStdLib()
      Indicates whether noStdLib(boolean) was set.
      Returns:
      true or false
    • isNoWarn

      public boolean isNoWarn()
      Indicates whether noWarn(boolean) was set.
      Returns:
      true or false
    • isProgressive

      public boolean isProgressive()
      Indicates whether progressive(boolean) was set.
      Returns:
      true or false
    • isVerbose

      public boolean isVerbose()
      Indicates whether verbose(boolean) was set.
      Returns:
      true if verbose was set; or false otherwise
    • isWError

      public boolean isWError()
      Indicates whether warnings are turned into a compilation error.
      Returns:
      true or false
    • isWExtra

      public boolean isWExtra()
      Indicates whether additional declaration, expression, and type compiler checks emit warnings.
      Returns:
      true or false
    • javaParameters

      public CompileOptions javaParameters(boolean javaParameters)
      Generate metadata for Java 1.8 reflection on method parameters.
      Parameters:
      javaParameters - true or false
      Returns:
      this operation instance
    • jdkHome

      public CompileOptions jdkHome(@NonNull File jdkHome)
      Use a custom JDK home directory to include in the classpath if it differs from the default JAVA_HOME.
      Parameters:
      jdkHome - the JDK home path
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jdkHome is null
      IllegalArgumentException - if jdkHome is empty
    • jdkHome

      public CompileOptions jdkHome(@NonNull String jdkHome)
      Use a custom JDK home directory to include in the classpath if it differs from the default JAVA_HOME.
      Parameters:
      jdkHome - the JDK home path
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jdkHome is null
      IllegalArgumentException - if jdkHome is empty
    • jdkHome

      public CompileOptions jdkHome(@NonNull Path jdkHome)
      Use a custom JDK home directory to include in the classpath if it differs from the default JAVA_HOME.
      Parameters:
      jdkHome - the JDK home path
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jdkHome is null
      IllegalArgumentException - if jdkHome is empty
    • jdkHome

      public File jdkHome()
      Retrieves the custom JDK home directory.
      Returns:
      the JDK home path
    • jdkRelease

      public CompileOptions jdkRelease(@NonNull String version)
      Compile against the specified JDK API version.

      Limit the API of the JDK in the classpath to the specified Java version. Automatically sets JVM target version.

      Possible values are 1.8, 9, 10, ..., 23. The default value is 1.8.

      Parameters:
      version - the target version
      Returns:
      this operation instance
      Throws:
      NullPointerException - if version is null
      IllegalArgumentException - if version is empty
    • jdkRelease

      public CompileOptions jdkRelease(int version)
      Compile against the specified JDK API version.
      Parameters:
      version - the target version
      Returns:
      this operation instance
      See Also:
    • jdkRelease

      public String jdkRelease()
      Return the specified JDK API version.
      Returns:
      the API version
    • jvmDefault

      public CompileOptions jvmDefault(JvmDefault jvmDefault)
      Emit JVM default methods for interface declarations with bodies.
      Parameters:
      jvmDefault - the default methods option
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jvmDefault is null
      IllegalArgumentException - if jvmDefault is null
      Since:
      1.1.0
    • jvmDefault

      public JvmDefault jvmDefault()
      Retrieves the JVM default methods option.
      Returns:
      the default methods option
      Since:
      1.1.0
    • jvmTarget

      public CompileOptions jvmTarget(@NonNull String target)
      Specify the target version of the generated JVM bytecode.

      Possible values are 1.8, 9, 10, ..., 23. The default value is 1.8.

      Parameters:
      target - the target version
      Returns:
      this operation instance
      Throws:
      NullPointerException - if jvmTarget is null
      IllegalArgumentException - if jvmTarget is empty
    • jvmTarget

      public CompileOptions jvmTarget(int target)
      Specify the target version of the generated JVM bytecode.
      Parameters:
      target - the target version
      Returns:
      this operation instance
      See Also:
    • jvmTarget

      public String jvmTarget()
      Retrieves the target version of the generated JVM bytecode.
      Returns:
      the target version
    • kotlinHome

      public CompileOptions kotlinHome(@NonNull File path)
      Specify a custom path to the Kotlin compiler used for the discovery of runtime libraries.
      Parameters:
      path - the Kotlin home path
      Returns:
      this operation instance
      Throws:
      NullPointerException - if path is null
    • kotlinHome

      public CompileOptions kotlinHome(@NonNull Path path)
      Specify a custom path to the Kotlin compiler used for the discovery of runtime libraries.
      Parameters:
      path - the Kotlin home path
      Returns:
      this operation instance
      Throws:
      NullPointerException - if path is null
    • kotlinHome

      public CompileOptions kotlinHome(@NonNull String path)
      Specify a custom path to the Kotlin compiler used for the discovery of runtime libraries.
      Parameters:
      path - the Kotlin home path
      Returns:
      this operation instance
      Throws:
      NullPointerException - if path is null
      IllegalArgumentException - if path is empty
    • kotlinHome

      public File kotlinHome()
      Retrieves the custom path of the Kotlin compiler.
      Returns:
      the Kotlin home path
    • languageVersion

      public CompileOptions languageVersion(@NonNull String version)
      Provide source compatibility with the specified version of Kotlin.
      Parameters:
      version - the language version
      Returns:
      this operation instance
      Throws:
      NullPointerException - if version is null
      IllegalArgumentException - if version is empty
    • languageVersion

      public String languageVersion()
      Retrieves the language version.
      Returns:
      the language version
    • moduleName

      public CompileOptions moduleName(@NonNull String name)
      Set a custom name for the generated .kotlin_module file.
      Parameters:
      name - the module name
      Returns:
      this operation instance
      Throws:
      NullPointerException - if name is null
      IllegalArgumentException - if name is empty
    • moduleName

      public String moduleName()
      Retrieves the module name.
      Returns:
      the module name
    • noJdk

      public CompileOptions noJdk(boolean noJdk)
      Don't automatically include the Java runtime into the classpath.
      Parameters:
      noJdk - true or false
      Returns:
      this operation instance
    • noReflect

      public CompileOptions noReflect(boolean noReflect)
      Don't automatically include the Kotlin reflection (kotlin-reflect.jar) into the classpath.
      Parameters:
      noReflect - true or false
      Returns:
      this operation instance
    • noStdLib

      public CompileOptions noStdLib(boolean noStdLib)
      Don't automatically include the Kotlin/JVM stdlib (kotlin-stdlib.jar) and Kotlin reflection (kotlin-reflect.jar) into the classpath.
      Parameters:
      noStdLib - true or false
      Returns:
      this operation instance
    • noWarn

      public CompileOptions noWarn(boolean noWarn)
      Suppress the compiler from displaying warnings during compilation.
      Parameters:
      noWarn - true or false
      Returns:
      this operation instance
    • optIn

      public CompileOptions optIn(@NonNull String... annotations)
      Enable usages of API that requires opt-in with a requirement annotation with the given fully qualified name.
      Parameters:
      annotations - one or more annotation names
      Returns:
      this operation instance
      Throws:
      NullPointerException - if annotations is null
      IllegalArgumentException - if annotations is empty, or contains null or empty elements
    • optIn

      public final CompileOptions optIn(@NonNull Collection<String> annotations)
      Enable usages of API that requires opt-in with a requirement annotation with the given fully qualified name.
      Parameters:
      annotations - the annotation names
      Returns:
      this operation instance
      Throws:
      NullPointerException - if annotations is null
      IllegalArgumentException - if annotations is empty, or contains null or empty elements
    • optIn

      public Set<String> optIn()
      Retrieves the opt-in fully qualified names.
      Returns:
      the fully qualified names
    • options

      public CompileOptions options(@NonNull String... options)
      Specify additional compiler options.
      Parameters:
      options - one or more compiler options
      Returns:
      this operation instance
      Throws:
      NullPointerException - if options is null
      IllegalArgumentException - if options is empty, or contains null or empty elements
    • options

      public final CompileOptions options(@NonNull Collection<String> options)
      Specify additional compiler options.
      Parameters:
      options - the compiler options
      Returns:
      this operation instance
      Throws:
      NullPointerException - if options is null
      IllegalArgumentException - if options is empty, or contains null or empty elements
    • options

      public Set<String> options()
      Retrieves additional compiler options.
      Returns:
      the compiler options
    • path

      public CompileOptions path(@NonNull File path)
      Place the generated class files into the specified location.

      The location can be a directory, a ZIP, or a JAR file.

      Parameters:
      path - the location path
      Returns:
      this operation instance
      Throws:
      NullPointerException - if path is null
    • path

      public CompileOptions path(@NonNull Path path)
      Place the generated class files into the specified location.

      The location can be a directory, a ZIP, or a JAR file.

      Parameters:
      path - the location path
      Returns:
      this operation instance
      Throws:
      NullPointerException - if path is null
    • path

      public CompileOptions path(@NonNull String path)
      Place the generated class files into the specified location.

      The location can be a directory, a ZIP, or a JAR file.

      Parameters:
      path - the location path
      Returns:
      this operation instance
      Throws:
      NullPointerException - if path is null
      IllegalArgumentException - if path is empty
    • path

      public File path()
      Retrieves the location to place generated class files into.
      Returns:
      the location path
    • plugin

      public CompileOptions plugin(@NonNull String id, @NonNull String optionName, @NonNull String value)
      Pass an option to a plugin.
      Parameters:
      id - the plugin ID
      optionName - the plugin option name
      value - the plugin option value
      Returns:
      this operation instance
      Throws:
      NullPointerException - if id, optionName, or value are null
      IllegalArgumentException - if id, optionName, or value are empty
    • plugin

      public Set<String> plugin()
      Retrieves the plugin options.
      Returns:
      the plugin options
    • progressive

      public CompileOptions progressive(boolean progressive)
      Enable progressive compilation mode.
      Parameters:
      progressive - true or false
      Returns:
      this operation instance
    • scriptTemplates

      public CompileOptions scriptTemplates(@NonNull String... classNames)
      Script definition template classes.

      Use fully qualified class names.

      Parameters:
      classNames - one or more class names
      Returns:
      this operation instance
      Throws:
      NullPointerException - if classNames is null
      IllegalArgumentException - if classNames is empty, or contains null or empty elements
    • scriptTemplates

      public final CompileOptions scriptTemplates(@NonNull Collection<String> classNames)
      Script definition template classes.

      Use fully qualified class names.

      Parameters:
      classNames - the class names
      Returns:
      this operation instance
      Throws:
      NullPointerException - if classNames is null
      IllegalArgumentException - if classNames is empty, or contains null or empty elements
    • scriptTemplates

      public Set<String> scriptTemplates()
      Retrieves the script templates.
      Returns:
      the script templates
    • verbose

      public CompileOptions verbose(boolean verbose)
      Enable verbose logging output which includes details of the compilation process.
      Parameters:
      verbose - true or false
      Returns:
      this operation instance
    • wError

      public CompileOptions wError(boolean wError)
      Turn any warnings into a compilation error.
      Parameters:
      wError - true or false
      Returns:
      this operation instance
    • wExtra

      public CompileOptions wExtra(boolean wExtra)
      Enable additional declaration, expression, and type compiler checks that emit warnings if true.
      Parameters:
      wExtra - true or false
      Returns:
      this operation instance