public final class CompileTask
extends org.apache.tools.ant.Task
Modifier and Type | Field and Description |
---|---|
private boolean |
angularPass |
private CompilationLevel |
compilationLevel |
private boolean |
debugOptions |
private java.util.List<org.apache.tools.ant.types.Parameter> |
defineParams |
private java.lang.String |
encoding |
private java.util.List<org.apache.tools.ant.types.Parameter> |
entryPointParams |
private CompilerOptions.Environment |
environment |
private java.util.List<org.apache.tools.ant.types.FileList> |
externFileLists |
private boolean |
forceRecompile |
private boolean |
generateExports |
private CompilerOptions.LanguageMode |
languageIn |
private CompilerOptions.LanguageMode |
languageOut |
private boolean |
manageDependencies |
private java.nio.charset.Charset |
outputEncoding |
private File |
outputFile |
private java.lang.String |
outputWrapper |
private File |
outputWrapperFile |
private boolean |
preferSingleQuotes |
private boolean |
prettyPrint |
private boolean |
printInputDelimiter |
private boolean |
replaceProperties |
private java.lang.String |
replacePropertiesPrefix |
private java.util.List<org.apache.tools.ant.types.FileList> |
sourceFileLists |
private java.lang.String |
sourceMapFormat |
private java.lang.String |
sourceMapLocationMapping |
private File |
sourceMapOutputFile |
private java.util.List<org.apache.tools.ant.types.Path> |
sourcePaths |
private WarningLevel |
warningLevel |
private java.util.List<Warning> |
warnings |
Constructor and Description |
---|
CompileTask() |
Modifier and Type | Method and Description |
---|---|
void |
addEntryPoint(org.apache.tools.ant.types.Parameter entrypoint)
Adds a
<entrypoint/> entry
Each entrypoint entry must have one attribute, name. |
void |
addExterns(org.apache.tools.ant.types.FileList list)
Sets the externs file.
|
void |
addPath(org.apache.tools.ant.types.Path list)
Adds a
|
void |
addSources(org.apache.tools.ant.types.FileList list)
Sets the source files.
|
void |
addWarning(Warning warning)
Adds a
<warning/> entry
Each warning entry must have two attributes, group and level. |
private void |
convertDefineParameters(CompilerOptions options)
Converts
<define/> nested elements into Compiler @define
replacements. |
private void |
convertEntryPointParameters(CompilerOptions options)
Converts
<entrypoint/> nested elements into Compiler entrypoint
replacements. |
private void |
convertPropertiesMap(CompilerOptions options)
Converts project properties beginning with the replacement prefix
into Compiler
@define replacements. |
private Compiler |
createCompiler(CompilerOptions options) |
private CompilerOptions |
createCompilerOptions() |
org.apache.tools.ant.types.Parameter |
createDefine()
Creates a new
<define/> nested element. |
org.apache.tools.ant.types.Parameter |
createEntryPoint()
Creates a new
<entrypoint/> nested element. |
void |
execute() |
private java.util.List<SourceFile> |
findExternFiles(CompilerOptions options) |
private java.util.List<SourceFile> |
findJavaScriptFiles(org.apache.tools.ant.types.ResourceCollection rc)
Translates an Ant resource collection into the file list format that
the compiler expects.
|
private java.util.List<SourceFile> |
findSourceFiles() |
private void |
flushSourceMap(SourceMap sourceMap) |
private java.util.List<SourceFile> |
getBuiltinExterns(CompilerOptions options)
Gets the default externs set.
|
private static long |
getLastModifiedTime(File file)
Returns the last modified timestamp of the given File.
|
private long |
getLastModifiedTime(java.util.List<?> fileLists)
Returns the most recent modified timestamp of the file collection.
|
private boolean |
isStale()
Determine if compilation must actually happen, i.e.
|
private static CompilerOptions.LanguageMode |
parseLanguageMode(java.lang.String value) |
void |
setAngularPass(boolean angularPass) |
void |
setCompilationLevel(java.lang.String value)
Set the compilation level.
|
void |
setDebug(boolean value)
Enable debugging options.
|
private boolean |
setDefine(CompilerOptions options,
java.lang.String key,
java.lang.Object value)
Maps Ant-style values (e.g., from Properties) into expected
Closure
@define literals |
void |
setEncoding(java.lang.String encoding)
Set input file encoding
|
void |
setEnvironment(java.lang.String value)
Set the environment which determines the builtin extern set.
|
void |
setForceRecompile(boolean forceRecompile)
Set force recompile option
|
void |
setGenerateExports(boolean generateExports)
Set generateExports option
|
void |
setLanguageIn(java.lang.String value)
Set the language to which input sources conform.
|
void |
setLanguageOut(java.lang.String value)
Set the language to which output sources conform.
|
void |
setManageDependencies(boolean value) |
void |
setOutput(File value)
Set output file.
|
void |
setOutputEncoding(java.lang.String outputEncoding)
Set output file encoding
|
void |
setOutputWrapper(java.lang.String value)
Set output wrapper.
|
void |
setOutputWrapperFile(File value)
Set output wrapper file.
|
void |
setPreferSingleQuotes(boolean singlequotes)
Normally, when there are an equal number of single and double quotes
in a string, the compiler will use double quotes.
|
void |
setPrettyPrint(boolean pretty)
Set pretty print formatting option
|
void |
setPrintInputDelimiter(boolean print)
Set print input delimiter formatting option
|
void |
setReplaceProperties(boolean value)
Whether to replace
@define lines with properties |
void |
setReplacePropertiesPrefix(java.lang.String value)
Set the replacement property prefix.
|
void |
setSourceMapFormat(java.lang.String format) |
void |
setSourceMapLocationMapping(java.lang.String mapping) |
void |
setSourceMapOutputFile(File sourceMapOutputFile) |
void |
setWarning(java.lang.String value)
Set the warning level.
|
private void |
writeResult(java.lang.String source) |
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
private CompilerOptions.LanguageMode languageIn
private CompilerOptions.LanguageMode languageOut
private WarningLevel warningLevel
private boolean debugOptions
private java.lang.String encoding
private java.nio.charset.Charset outputEncoding
private CompilationLevel compilationLevel
private CompilerOptions.Environment environment
private boolean manageDependencies
private boolean prettyPrint
private boolean printInputDelimiter
private boolean preferSingleQuotes
private boolean generateExports
private boolean replaceProperties
private boolean forceRecompile
private boolean angularPass
private java.lang.String replacePropertiesPrefix
private File outputFile
private java.lang.String outputWrapper
private File outputWrapperFile
private final java.util.List<org.apache.tools.ant.types.Parameter> defineParams
private final java.util.List<org.apache.tools.ant.types.Parameter> entryPointParams
private final java.util.List<org.apache.tools.ant.types.FileList> externFileLists
private final java.util.List<org.apache.tools.ant.types.FileList> sourceFileLists
private final java.util.List<org.apache.tools.ant.types.Path> sourcePaths
private final java.util.List<Warning> warnings
private java.lang.String sourceMapFormat
private File sourceMapOutputFile
private java.lang.String sourceMapLocationMapping
private static CompilerOptions.LanguageMode parseLanguageMode(java.lang.String value)
public void setLanguageIn(java.lang.String value)
value
- The name of the language.
(ECMASCRIPT3, ECMASCRIPT5, ECMASCRIPT5_STRICT).public void setLanguageOut(java.lang.String value)
value
- The name of the language.
(ECMASCRIPT3, ECMASCRIPT5, ECMASCRIPT5_STRICT).public void setWarning(java.lang.String value)
value
- The warning level by string name. (default, quiet, verbose).public void setEnvironment(java.lang.String value)
value
- The name of the environment.
(BROWSER, CUSTOM).public void setDebug(boolean value)
value
- True if debug mode is enabled.public void setCompilationLevel(java.lang.String value)
value
- The optimization level by string name.
(whitespace, simple, advanced).public void setManageDependencies(boolean value)
public void setOutput(File value)
public void setOutputWrapper(java.lang.String value)
public void setOutputWrapperFile(File value)
public void setReplacePropertiesPrefix(java.lang.String value)
public void setReplaceProperties(boolean value)
@define
lines with propertiespublic void setEncoding(java.lang.String encoding)
public void setOutputEncoding(java.lang.String outputEncoding)
public void setPrettyPrint(boolean pretty)
public void setPrintInputDelimiter(boolean print)
public void setPreferSingleQuotes(boolean singlequotes)
public void setForceRecompile(boolean forceRecompile)
public void setAngularPass(boolean angularPass)
public void setGenerateExports(boolean generateExports)
public void addExterns(org.apache.tools.ant.types.FileList list)
public void addWarning(Warning warning)
<warning/>
entry
Each warning entry must have two attributes, group and level. Group must
contain one of the constants from DiagnosticGroups (e.g.,
"ACCESS_CONTROLS"), while level must contain one of the CheckLevel
constants ("ERROR", "WARNING" or "OFF").public void addEntryPoint(org.apache.tools.ant.types.Parameter entrypoint)
<entrypoint/>
entry
Each entrypoint entry must have one attribute, name.public void addSources(org.apache.tools.ant.types.FileList list)
public void addPath(org.apache.tools.ant.types.Path list)
public void execute()
execute
in class org.apache.tools.ant.Task
private void flushSourceMap(SourceMap sourceMap)
private CompilerOptions createCompilerOptions()
public org.apache.tools.ant.types.Parameter createDefine()
<define/>
nested element. Supports name and value
attributes.public org.apache.tools.ant.types.Parameter createEntryPoint()
<entrypoint/>
nested element. Supports name
attribute.private void convertDefineParameters(CompilerOptions options)
<define/>
nested elements into Compiler @define
replacements. Note: unlike project properties, <define/>
elements
do not need to be named starting with the replacement prefix.private void convertEntryPointParameters(CompilerOptions options)
<entrypoint/>
nested elements into Compiler entrypoint
replacements.private void convertPropertiesMap(CompilerOptions options)
@define
replacements.options
- private boolean setDefine(CompilerOptions options, java.lang.String key, java.lang.Object value)
@define
literals@define
replacement succeeded, false if
the variable's value could not be mapped properly.private Compiler createCompiler(CompilerOptions options)
private java.util.List<SourceFile> findExternFiles(CompilerOptions options)
private java.util.List<SourceFile> findSourceFiles()
private java.util.List<SourceFile> findJavaScriptFiles(org.apache.tools.ant.types.ResourceCollection rc)
private java.util.List<SourceFile> getBuiltinExterns(CompilerOptions options)
CommandLineRunner
.private void writeResult(java.lang.String source)
private boolean isStale()
private long getLastModifiedTime(java.util.List<?> fileLists)
fileLists
- Collection of FileList or Pathprivate static long getLastModifiedTime(File file)
public void setSourceMapFormat(java.lang.String format)
public void setSourceMapOutputFile(File sourceMapOutputFile)
public void setSourceMapLocationMapping(java.lang.String mapping)