public final class JkKotlinCompiler
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
JkKotlinCompiler.Target
Represents the possible target platforms for the Kotlin compiler.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
KOTLIN_COMPILER_COORDINATES |
static JkPathMatcher |
KOTLIN_SOURCE_MATCHER |
static java.lang.String |
KOTLIN_VERSION_OPTION |
Modifier and Type | Method and Description |
---|---|
JkKotlinCompiler |
addJvmOption(java.lang.String option)
Adds JVM options to pass to compiler program (which is a Java program).
|
JkKotlinCompiler |
addOption(java.lang.String option)
Adds an option to the Kotlin compiler.
|
JkKotlinCompiler |
addPlugin(java.nio.file.Path pluginJar)
Adds a plugin JAR file to the Kotlin compiler.
|
JkKotlinCompiler |
addPlugin(java.lang.String coordinate)
Instructs this compiler to use the plugin identified by the specified coordinates.
|
JkKotlinCompiler |
addPluginOption(java.lang.String pluginId,
java.lang.String name,
java.lang.String value)
Adds a plugin option to the Kotlin compiler.
|
boolean |
compile(JkKotlinJvmCompileSpec compileSpec)
Compiles the source files to the output directory.
|
java.util.List<java.lang.String> |
getPluginOptions()
Returns the list of plugin options used by this compiler.
|
java.util.List<java.lang.String> |
getPlugins()
Returns the list of plugins used by this compiler.
|
JkRepoSet |
getRepos()
Retrieves the set of repositories to fetch stdlib and plugins.
|
JkPathSequence |
getStdJdk8Lib()
Returns the path of the standard JDK 8 libraries for the Kotlin compiler.
|
java.nio.file.Path |
getStdLib()
Returns path of stdlib located in JEKA_HOME (if the compiler is provided by the platform) of from
a repo (if the compiler is managed by JeKa, meaning the version is specified)
|
java.lang.String |
getVersion()
Returns the version of Kotlin this compiler stands for.
|
boolean |
isProvidedCompiler()
Returns true if this compiler is provided by the host machine, meaning it has not been downloaded and managed by Jeka.
|
static JkKotlinCompiler |
ofCommand(java.lang.String command)
Creates a
JkKotlinCompiler based on the specified command. |
static JkKotlinCompiler |
ofJvm(JkRepoSet repos)
Creates a
JkKotlinCompiler for JVM with the specified by 'jeka.kotlin.version' property
and fetched from the specified repository. |
static JkKotlinCompiler |
ofJvm(JkRepoSet repos,
java.lang.String version)
Creates a
JkKotlinCompiler for JVM with the specified version and fetched from the specified repository . |
static JkKotlinCompiler |
ofKotlinHomeCommand(java.lang.String command)
Creates a
JkKotlinCompiler based on the specified command located in `KOTLIN_HOME` directory. |
static JkKotlinCompiler |
ofTarget(JkRepoSet repos,
JkKotlinCompiler.Target target,
java.lang.String kotlinVersion)
Creates a
JkKotlinCompiler of the specified Kotlin version for the specified target platform. |
JkKotlinCompiler |
setFailOnError(boolean fail)
Sets the flag to indicate whether compilation should fail on error or not.
|
JkKotlinCompiler |
setLogCommand(boolean log)
Sets the flag to indicate whether the compiler command should be logged or not.
|
JkKotlinCompiler |
setLogOutput(boolean log)
Sets the flag to indicate whether the compiler output should be logged or not.
|
JkKotlinCompiler |
setRepos(JkRepoSet repos)
Set the repo to fetch stdlib and plugins.
|
public static final java.lang.String KOTLIN_COMPILER_COORDINATES
public static final java.lang.String KOTLIN_VERSION_OPTION
public static final JkPathMatcher KOTLIN_SOURCE_MATCHER
public static JkKotlinCompiler ofCommand(java.lang.String command)
JkKotlinCompiler
based on the specified command. The specified command is supposed to be
accessible from the working directory. Examples of command are "kotlinc", "kotlinc-native", "/my/kotlin/home/kotlin-js", ...public static JkKotlinCompiler ofKotlinHomeCommand(java.lang.String command)
JkKotlinCompiler
based on the specified command located in `KOTLIN_HOME` directory.
Examples of command are "kotlinc", "kotlin-jvm", "kotlin-js".public static JkKotlinCompiler ofTarget(JkRepoSet repos, JkKotlinCompiler.Target target, java.lang.String kotlinVersion)
JkKotlinCompiler
of the specified Kotlin version for the specified target platform. The
compiler matching the specified Kotlin version is downloaded from the specified repo.public static JkKotlinCompiler ofJvm(JkRepoSet repos, java.lang.String version)
JkKotlinCompiler
for JVM with the specified version and fetched from the specified repository .repos
- The repository set to download the Kotlin compiler from.version
- The version of Kotlin to use.java.lang.IllegalArgumentException
- if `version` is null.public static JkKotlinCompiler ofJvm(JkRepoSet repos)
JkKotlinCompiler
for JVM with the specified by 'jeka.kotlin.version' property
and fetched from the specified repository.repos
- The repository set to download the Kotlin compiler from.public boolean isProvidedCompiler()
public java.lang.String getVersion()
null
.public java.nio.file.Path getStdLib()
public JkPathSequence getStdJdk8Lib()
public JkKotlinCompiler setFailOnError(boolean fail)
public JkKotlinCompiler setLogCommand(boolean log)
public JkKotlinCompiler setLogOutput(boolean log)
public JkRepoSet getRepos()
public JkKotlinCompiler setRepos(JkRepoSet repos)
public JkKotlinCompiler addJvmOption(java.lang.String option)
public JkKotlinCompiler addPluginOption(java.lang.String pluginId, java.lang.String name, java.lang.String value)
public JkKotlinCompiler addPlugin(java.nio.file.Path pluginJar)
public JkKotlinCompiler addPlugin(java.lang.String coordinate)
Plugin
class provides constants about most common plugin coordinates.
public JkKotlinCompiler addOption(java.lang.String option)
public boolean compile(JkKotlinJvmCompileSpec compileSpec)
false
if a compilation error occurred.java.lang.IllegalStateException
- if a compilation error occurred and the 'withFailOnError' flag is true
.public java.util.List<java.lang.String> getPlugins()
public java.util.List<java.lang.String> getPluginOptions()