public final class JkJavaCompiler<T>
extends java.lang.Object
JavaCompiler
instance either an external
process (forked mode).Modifier and Type | Method and Description |
---|---|
boolean |
compile(JkJavaCompileSpec compileSpec)
Actually compile the source files to the output directory.
|
static JkProcess |
getForkedProcessOnJavaSourceVersion(java.util.Map<java.lang.String,java.lang.String> jdkLocations,
java.lang.String version)
Returns a
JkProcess standing for a forking compiler with relevant JDK if this specified source version
does not match with the current running JDK. |
boolean |
isDefault()
Returns
true if no compiler or fork has been set on. |
static JkJavaCompiler<java.lang.Void> |
of()
Creates a
JkJavaCompiler without specifying a JavaCompiler instance or an external process. |
static <T> JkJavaCompiler<T> |
ofParent(T parent)
Same as
of() but mentioning a owner for parent chaining. |
JkJavaCompiler<T> |
setCompilerTool(javax.tools.JavaCompiler compiler)
Sets underlying java compiler tool to use.
|
JkJavaCompiler<T> |
setDefault()
Sets to default underlying compiler, meaning the compiler tool embedded in the running JDK
|
JkJavaCompiler<T> |
setForkingProcess(JkProcess compileProcess)
Sets the underlying compiler with the specified process.
|
JkJavaCompiler<T> |
setForkingWithJavac(java.lang.String... parameters)
Set the underlying compiler as an external process of the 'javac' tool provided with the running JDK.
|
JkJavaCompiler<T> |
setForkingWithJavacIf(boolean condition,
java.lang.String... parameters)
Same as
setForkingWithJavac(String...) but only operates if the specified condition is true |
public final T __
public static JkJavaCompiler<java.lang.Void> of()
JkJavaCompiler
without specifying a JavaCompiler
instance or an external process.
When nothing is specified, this compiler will try the default JavaCompiler
instance provided
by the running JDK.public static <T> JkJavaCompiler<T> ofParent(T parent)
of()
but mentioning a owner for parent chaining.public JkJavaCompiler<T> setCompilerTool(javax.tools.JavaCompiler compiler)
public JkJavaCompiler<T> setForkingProcess(JkProcess compileProcess)
public JkJavaCompiler<T> setDefault()
public JkJavaCompiler<T> setForkingWithJavac(java.lang.String... parameters)
setForkingProcess(JkProcess)
public JkJavaCompiler<T> setForkingWithJavacIf(boolean condition, java.lang.String... parameters)
setForkingWithJavac(String...)
but only operates if the specified condition is true
public boolean isDefault()
true
if no compiler or fork has been set on.public boolean compile(JkJavaCompileSpec compileSpec)
false
if a compilation error occurred.java.lang.IllegalStateException
- if a compilation error occurred and the 'withFailOnError' flag is true
.public static JkProcess getForkedProcessOnJavaSourceVersion(java.util.Map<java.lang.String,java.lang.String> jdkLocations, java.lang.String version)
JkProcess
standing for a forking compiler with relevant JDK if this specified source version
does not match with the current running JDK. The specified map may include
the JDK location for this source version.
If no need to fork, cause current JDK is aligned with target version, then this method returns null
.
The keys must be formatted as "jdk.[source version]". For example, "jdk.1.4" or
"jdk.7". The values must absolute path.