Class Compiler
- java.lang.Object
-
- org.codehaus.commons.compiler.AbstractCompiler
-
- org.codehaus.commons.compiler.jdk.Compiler
-
- All Implemented Interfaces:
ICompiler
public class Compiler extends AbstractCompiler
javax.tools
-based implementation of theICompiler
.
-
-
Field Summary
Fields Modifier and Type Field Description private javax.tools.JavaCompiler
compiler
private java.util.Collection<java.lang.String>
compilerOptions
-
Fields inherited from class org.codehaus.commons.compiler.AbstractCompiler
bootClassPath, classFileCreator, classFileFinder, classPath, compileErrorHandler, debugLines, debugSource, debugVars, extensionDirectories, sourceCharset, sourceFinder, sourceVersion, targetVersion, warningHandler
-
Fields inherited from interface org.codehaus.commons.compiler.ICompiler
CREATE_NEXT_TO_SOURCE_FILE, FIND_NEXT_TO_SOURCE_FILE, NO_DESTINATION_DIRECTORY
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static void
compile(javax.tools.JavaCompiler compiler, java.util.List<java.lang.String> options, java.util.Collection<javax.tools.JavaFileObject> sourceFileObjects, javax.tools.JavaFileManager fileManager, ErrorHandler compileErrorHandler, WarningHandler warningHandler, java.util.SortedSet<Location> offsets)
Compiles on theJavaFileManager
/JavaFileObject
level.(package private) static void
compile(javax.tools.JavaCompiler compiler, java.util.List<java.lang.String> options, ResourceFinder sourceFinder, java.nio.charset.Charset sourceFileCharset, ResourceFinder classFileFinder, ResourceCreator classFileCreator, Resource[] sourceFiles, ErrorHandler compileErrorHandler, WarningHandler warningHandler, java.util.SortedSet<Location> offsets)
void
compile(Resource[] sourceResources)
void
compile(Resource[] sourceResources, java.util.SortedSet<Location> offsets)
private static java.lang.String
filesToPath(java.io.File[] files)
private static javax.tools.JavaFileManager
getJavaFileManager(javax.tools.JavaCompiler compiler, ResourceFinder sourceFileFinder, java.nio.charset.Charset sourceFileCharset, ResourceFinder classFileFinder, ResourceCreator classFileCreator)
Creates aJavaFileManager
that implements the given sourceFileFinder, sourceFileCharset, classFileFinder and classFileCreator.void
setCompilerOptions(java.lang.String[] compilerOptions)
Adds command line options that are passed unchecked to theCompiler
.void
setVerbose(boolean verbose)
Equivalent of-verbose
.-
Methods inherited from class org.codehaus.commons.compiler.AbstractCompiler
compile, setBootClassPath, setCharacterEncoding, setClassFileCreator, setClassFileFinder, setClassFileFinder, setClassPath, setCompileErrorHandler, setDebugLines, setDebugSource, setDebugVars, setDestinationDirectory, setEncoding, setExtensionDirectories, setSourceCharset, setSourceFinder, setSourcePath, setSourceVersion, setTargetVersion, setWarningHandler
-
-
-
-
Method Detail
-
setVerbose
public void setVerbose(boolean verbose)
Description copied from interface:ICompiler
Equivalent of-verbose
.
-
setCompilerOptions
public void setCompilerOptions(java.lang.String[] compilerOptions)
Adds command line options that are passed unchecked to theCompiler
.Notice: Don't use the '-g' options - these are controlled through
AbstractCompiler.setDebugLines(boolean)
,AbstractCompiler.setDebugVars(boolean)
andAbstractCompiler.setDebugSource(boolean)
.- Parameters:
compilerOptions
- All command line options supported by the JDK JAVAC tool
-
compile
public void compile(Resource[] sourceResources) throws CompileException, java.io.IOException
Description copied from interface:ICompiler
- Parameters:
sourceResources
- Contain the compilation units to compile- Throws:
CompileException
java.io.IOException
-
compile
public void compile(Resource[] sourceResources, @Nullable java.util.SortedSet<Location> offsets) throws CompileException, java.io.IOException
- Throws:
CompileException
java.io.IOException
-
compile
static void compile(javax.tools.JavaCompiler compiler, java.util.List<java.lang.String> options, ResourceFinder sourceFinder, java.nio.charset.Charset sourceFileCharset, ResourceFinder classFileFinder, ResourceCreator classFileCreator, Resource[] sourceFiles, @Nullable ErrorHandler compileErrorHandler, @Nullable WarningHandler warningHandler, @Nullable java.util.SortedSet<Location> offsets) throws CompileException, java.io.IOException
- Throws:
CompileException
java.io.IOException
-
getJavaFileManager
private static javax.tools.JavaFileManager getJavaFileManager(javax.tools.JavaCompiler compiler, ResourceFinder sourceFileFinder, java.nio.charset.Charset sourceFileCharset, ResourceFinder classFileFinder, ResourceCreator classFileCreator)
Creates aJavaFileManager
that implements the given sourceFileFinder, sourceFileCharset, classFileFinder and classFileCreator.
-
compile
static void compile(javax.tools.JavaCompiler compiler, java.util.List<java.lang.String> options, java.util.Collection<javax.tools.JavaFileObject> sourceFileObjects, javax.tools.JavaFileManager fileManager, @Nullable ErrorHandler compileErrorHandler, @Nullable WarningHandler warningHandler, @Nullable java.util.SortedSet<Location> offsets) throws CompileException, java.io.IOException
Compiles on theJavaFileManager
/JavaFileObject
level.- Throws:
CompileException
java.io.IOException
-
filesToPath
private static java.lang.String filesToPath(java.io.File[] files)
-
-