Class DefaultCompilerAdapter
- java.lang.Object
-
- org.apache.tools.ant.taskdefs.compilers.DefaultCompilerAdapter
-
- All Implemented Interfaces:
CompilerAdapter,CompilerAdapterExtension
public abstract class DefaultCompilerAdapter extends java.lang.Object implements CompilerAdapter, CompilerAdapterExtension
This is the default implementation for the CompilerAdapter interface. Currently, this is a cut-and-paste of the original javac task.- Since:
- Ant 1.3
-
-
Field Summary
Fields Modifier and Type Field Description protected Javacattributesprotected Pathbootclasspathprotected PathcompileClasspathprotected java.io.File[]compileListprotected PathcompileSourcepathprotected booleandebugprotected booleandependprotected booleandeprecationprotected java.io.FiledestDirprotected java.lang.Stringencodingprotected Pathextdirsprotected booleanincludeAntRuntimeprotected booleanincludeJavaRuntimeprotected Locationlocationprotected static java.lang.StringlSepDeprecated.protected java.lang.StringmemoryInitialSizeprotected java.lang.StringmemoryMaximumSizeprotected Pathmodulepathprotected PathmoduleSourcepathprotected booleanoptimizeprotected Projectprojectprotected java.lang.Stringreleaseprotected Pathsrcprotected java.lang.Stringtargetprotected Pathupgrademodulepathprotected booleanverbose
-
Constructor Summary
Constructors Constructor Description DefaultCompilerAdapter()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected voidaddCurrentCompilerArgs(Commandline cmd)Adds the command line arguments specific to the current implementation.protected voidaddExtdirsToClasspath(Path classpath)Deprecated.since 1.5.x.protected booleanassumeJava1_1Plus()Shall we assume JDK 1.1+ command line switches?protected booleanassumeJava1_2Plus()Shall we assume JDK 1.2+ command line switches?protected booleanassumeJava1_3Plus()Shall we assume JDK 1.3+ command line switches?protected booleanassumeJava1_4Plus()Shall we assume JDK 1.4+ command line switches?protected booleanassumeJava1_5Plus()Shall we assume JDK 1.5+ command line switches?protected booleanassumeJava1_6Plus()Shall we assume JDK 1.6+ command line switches?protected booleanassumeJava1_7Plus()Shall we assume JDK 1.7+ command line switches?protected booleanassumeJava1_8Plus()Shall we assume JDK 1.8+ command line switches?protected booleanassumeJava10Plus()Shall we assume JDK 10+ command line switches?protected booleanassumeJava11()Deprecated.since Ant 1.10.7, use assumeJava1_1Plus, if necessary combined with !assumeJava1_2Plusprotected booleanassumeJava12()Deprecated.since Ant 1.10.7, use assumeJava1_2Plus, if necessary combined with !assumeJava1_3Plusprotected booleanassumeJava13()Deprecated.since Ant 1.10.7, use assumeJava1_3Plus, if necessary combined with !assumeJava1_4Plusprotected booleanassumeJava14()Deprecated.since Ant 1.10.7, use assumeJava1_4Plus, if necessary combined with !assumeJava1_5Plusprotected booleanassumeJava15()Deprecated.since Ant 1.10.7, use assumeJava1_5Plus, if necessary combined with !assumeJava1_6Plusprotected booleanassumeJava16()Deprecated.since Ant 1.10.7, use assumeJava1_6Plus, if necessary combined with !assumeJava1_7Plusprotected booleanassumeJava17()Deprecated.since Ant 1.10.7, use assumeJava1_7Plus, if necessary combined with !assumeJava1_8Plusprotected booleanassumeJava18()Deprecated.since Ant 1.10.7, use assumeJava1_8Plus, if necessary combined with !assumeJava9Plusprotected booleanassumeJava19()Deprecated.use #assumeJava9 insteadprotected booleanassumeJava9()Deprecated.since Ant 1.10.7, use assumeJava9Plus, in the future if necessary combined with !assumeJava10Plusprotected booleanassumeJava9Plus()Shall we assume JDK 9+ command line switches?protected intexecuteExternalCompile(java.lang.String[] args, int firstFileName)Do the compile with the specified arguments.protected intexecuteExternalCompile(java.lang.String[] args, int firstFileName, boolean quoteFiles)Do the compile with the specified arguments.protected PathgetBootClassPath()Combines a user specified bootclasspath with the system bootclasspath taking build.sysclasspath into account.protected PathgetCompileClasspath()Builds the compilation classpath.JavacgetJavac()Get the Javac task instance associated with this compiler adapterprotected PathgetModulepath()Builds the modulepath.protected PathgetModulesourcepath()Builds the modulesourcepath for multi module compilation.protected java.lang.StringgetNoDebugArgument()The argument the compiler wants to see if the debug attribute has been set to false.protected ProjectgetProject()Get the project this compiler adapter was created in.java.lang.String[]getSupportedFileExtensions()By default, only recognize files with a Java extension, but specialized compilers can recognize multiple kinds of files.protected PathgetUpgrademodulepath()Builds the upgrademodulepath.protected voidlogAndAddFilesToCompile(Commandline cmd)Logs the compilation parameters, adds the files to compile and logs the "niceSourceList"voidsetJavac(Javac attributes)Set the Javac instance which contains the configured compilation attributes.protected CommandlinesetupJavacCommand()Set up the command line.protected CommandlinesetupJavacCommand(boolean debugLevelCheck)Does the command line argument processing for classic and adds the files to compile as well.protected CommandlinesetupJavacCommandlineSwitches(Commandline cmd)Get the command line arguments for the switches.protected CommandlinesetupJavacCommandlineSwitches(Commandline cmd, boolean useDebugLevel)Does the command line argument processing common to classic and modern.protected CommandlinesetupModernJavacCommand()Does the command line argument processing for modern and adds the files to compile as well.protected CommandlinesetupModernJavacCommandlineSwitches(Commandline cmd)Does the command line argument processing for modern.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.tools.ant.taskdefs.compilers.CompilerAdapter
execute
-
-
-
-
Field Detail
-
lSep
@Deprecated protected static final java.lang.String lSep
Deprecated.
-
src
protected Path src
-
destDir
protected java.io.File destDir
-
encoding
protected java.lang.String encoding
-
debug
protected boolean debug
-
optimize
protected boolean optimize
-
deprecation
protected boolean deprecation
-
depend
protected boolean depend
-
verbose
protected boolean verbose
-
target
protected java.lang.String target
-
release
protected java.lang.String release
-
bootclasspath
protected Path bootclasspath
-
extdirs
protected Path extdirs
-
compileClasspath
protected Path compileClasspath
-
modulepath
protected Path modulepath
-
upgrademodulepath
protected Path upgrademodulepath
-
compileSourcepath
protected Path compileSourcepath
-
moduleSourcepath
protected Path moduleSourcepath
-
project
protected Project project
-
location
protected Location location
-
includeAntRuntime
protected boolean includeAntRuntime
-
includeJavaRuntime
protected boolean includeJavaRuntime
-
memoryInitialSize
protected java.lang.String memoryInitialSize
-
memoryMaximumSize
protected java.lang.String memoryMaximumSize
-
compileList
protected java.io.File[] compileList
-
attributes
protected Javac attributes
-
-
Method Detail
-
setJavac
public void setJavac(Javac attributes)
Set the Javac instance which contains the configured compilation attributes.- Specified by:
setJavacin interfaceCompilerAdapter- Parameters:
attributes- a configured Javac task.
-
getJavac
public Javac getJavac()
Get the Javac task instance associated with this compiler adapter- Returns:
- the configured Javac task instance used by this adapter.
-
getSupportedFileExtensions
public java.lang.String[] getSupportedFileExtensions()
By default, only recognize files with a Java extension, but specialized compilers can recognize multiple kinds of files.- Specified by:
getSupportedFileExtensionsin interfaceCompilerAdapterExtension- Returns:
- list of source file extensions recognized by this compiler adapter.
-
getProject
protected Project getProject()
Get the project this compiler adapter was created in.- Returns:
- the owner project
- Since:
- Ant 1.6
-
getCompileClasspath
protected Path getCompileClasspath()
Builds the compilation classpath.- Returns:
- the compilation class path
-
getModulepath
protected Path getModulepath()
Builds the modulepath.- Returns:
- the modulepath
- Since:
- 1.9.7
-
getUpgrademodulepath
protected Path getUpgrademodulepath()
Builds the upgrademodulepath.- Returns:
- the upgrademodulepath
- Since:
- 1.9.7
-
getModulesourcepath
protected Path getModulesourcepath()
Builds the modulesourcepath for multi module compilation.- Returns:
- the modulesourcepath
- Since:
- 1.9.7
-
setupJavacCommandlineSwitches
protected Commandline setupJavacCommandlineSwitches(Commandline cmd)
Get the command line arguments for the switches.- Parameters:
cmd- the command line- Returns:
- the command line
-
setupJavacCommandlineSwitches
protected Commandline setupJavacCommandlineSwitches(Commandline cmd, boolean useDebugLevel)
Does the command line argument processing common to classic and modern. Doesn't add the files to compile.- Parameters:
cmd- the command lineuseDebugLevel- if true set set the debug level with the -g switch- Returns:
- the command line
-
setupModernJavacCommandlineSwitches
protected Commandline setupModernJavacCommandlineSwitches(Commandline cmd)
Does the command line argument processing for modern. Doesn't add the files to compile.- Parameters:
cmd- the command line- Returns:
- the command line
-
setupModernJavacCommand
protected Commandline setupModernJavacCommand()
Does the command line argument processing for modern and adds the files to compile as well.- Returns:
- the command line
-
setupJavacCommand
protected Commandline setupJavacCommand()
Set up the command line.- Returns:
- the command line
-
setupJavacCommand
protected Commandline setupJavacCommand(boolean debugLevelCheck)
Does the command line argument processing for classic and adds the files to compile as well.- Parameters:
debugLevelCheck- if true set the debug level with the -g switch- Returns:
- the command line
-
logAndAddFilesToCompile
protected void logAndAddFilesToCompile(Commandline cmd)
Logs the compilation parameters, adds the files to compile and logs the "niceSourceList"- Parameters:
cmd- the command line
-
executeExternalCompile
protected int executeExternalCompile(java.lang.String[] args, int firstFileName)Do the compile with the specified arguments.- Parameters:
args- - arguments to pass to process on command linefirstFileName- - index of the first source file in args, if the index is negative, no temporary file will ever be created, but this may hit the command line length limit on your system.- Returns:
- the exit code of the compilation
-
executeExternalCompile
protected int executeExternalCompile(java.lang.String[] args, int firstFileName, boolean quoteFiles)Do the compile with the specified arguments.The working directory if the executed process will be the project's base directory.
- Parameters:
args- - arguments to pass to process on command linefirstFileName- - index of the first source file in args, if the index is negative, no temporary file will ever be created, but this may hit the command line length limit on your system.quoteFiles- - if set to true, filenames containing spaces will be quoted when they appear in the external file. This is necessary when running JDK 1.4's javac and probably others.- Returns:
- the exit code of the compilation
- Since:
- Ant 1.6
-
addExtdirsToClasspath
@Deprecated protected void addExtdirsToClasspath(Path classpath)
Deprecated.since 1.5.x. Use org.apache.tools.ant.types.Path#addExtdirs instead.Add extdirs to classpath- Parameters:
classpath- the classpath to use
-
addCurrentCompilerArgs
protected void addCurrentCompilerArgs(Commandline cmd)
Adds the command line arguments specific to the current implementation.- Parameters:
cmd- the command line to use
-
assumeJava11
@Deprecated protected boolean assumeJava11()
Deprecated.since Ant 1.10.7, use assumeJava1_1Plus, if necessary combined with !assumeJava1_2PlusShall we assume JDK 1.1 command line switches?- Returns:
- true if jdk 1.1
- Since:
- Ant 1.5
-
assumeJava1_1Plus
protected boolean assumeJava1_1Plus()
Shall we assume JDK 1.1+ command line switches?- Returns:
- true if jdk 1.1 and above
- Since:
- Ant 1.10.7
-
assumeJava12
@Deprecated protected boolean assumeJava12()
Deprecated.since Ant 1.10.7, use assumeJava1_2Plus, if necessary combined with !assumeJava1_3PlusShall we assume JDK 1.2 command line switches?- Returns:
- true if jdk 1.2
- Since:
- Ant 1.5
-
assumeJava1_2Plus
protected boolean assumeJava1_2Plus()
Shall we assume JDK 1.2+ command line switches?- Returns:
- true if jdk 1.2 and above
- Since:
- Ant 1.10.7
-
assumeJava13
@Deprecated protected boolean assumeJava13()
Deprecated.since Ant 1.10.7, use assumeJava1_3Plus, if necessary combined with !assumeJava1_4PlusShall we assume JDK 1.3 command line switches?- Returns:
- true if jdk 1.3
- Since:
- Ant 1.5
-
assumeJava1_3Plus
protected boolean assumeJava1_3Plus()
Shall we assume JDK 1.3+ command line switches?- Returns:
- true if jdk 1.3 and above
- Since:
- Ant 1.10.7
-
assumeJava14
@Deprecated protected boolean assumeJava14()
Deprecated.since Ant 1.10.7, use assumeJava1_4Plus, if necessary combined with !assumeJava1_5PlusShall we assume JDK 1.4 command line switches?- Returns:
- true if jdk 1.4
- Since:
- Ant 1.6.3
-
assumeJava1_4Plus
protected boolean assumeJava1_4Plus()
Shall we assume JDK 1.4+ command line switches?- Returns:
- true if jdk 1.4 and above
- Since:
- Ant 1.10.7
-
assumeJava15
@Deprecated protected boolean assumeJava15()
Deprecated.since Ant 1.10.7, use assumeJava1_5Plus, if necessary combined with !assumeJava1_6PlusShall we assume JDK 1.5 command line switches?- Returns:
- true if JDK 1.5
- Since:
- Ant 1.6.3
-
assumeJava1_5Plus
protected boolean assumeJava1_5Plus()
Shall we assume JDK 1.5+ command line switches?- Returns:
- true if jdk 1.5 and above
- Since:
- Ant 1.10.7
-
assumeJava16
@Deprecated protected boolean assumeJava16()
Deprecated.since Ant 1.10.7, use assumeJava1_6Plus, if necessary combined with !assumeJava1_7PlusShall we assume JDK 1.6 command line switches?- Returns:
- true if JDK 1.6
- Since:
- Ant 1.7
-
assumeJava1_6Plus
protected boolean assumeJava1_6Plus()
Shall we assume JDK 1.6+ command line switches?- Returns:
- true if jdk 1.6 and above
- Since:
- Ant 1.10.7
-
assumeJava17
@Deprecated protected boolean assumeJava17()
Deprecated.since Ant 1.10.7, use assumeJava1_7Plus, if necessary combined with !assumeJava1_8PlusShall we assume JDK 1.7 command line switches?- Returns:
- true if JDK 1.7
- Since:
- Ant 1.8.2
-
assumeJava1_7Plus
protected boolean assumeJava1_7Plus()
Shall we assume JDK 1.7+ command line switches?- Returns:
- true if jdk 1.7 and above
- Since:
- Ant 1.10.7
-
assumeJava18
@Deprecated protected boolean assumeJava18()
Deprecated.since Ant 1.10.7, use assumeJava1_8Plus, if necessary combined with !assumeJava9PlusShall we assume JDK 1.8 command line switches?- Returns:
- true if JDK 1.8
- Since:
- Ant 1.8.3
-
assumeJava1_8Plus
protected boolean assumeJava1_8Plus()
Shall we assume JDK 1.8+ command line switches?- Returns:
- true if jdk 1.8 and above
- Since:
- Ant 1.10.7
-
assumeJava19
@Deprecated protected boolean assumeJava19()
Deprecated.use #assumeJava9 insteadShall we assume JDK 9 command line switches?- Returns:
- true if JDK 9
- Since:
- Ant 1.9.4
-
assumeJava9
@Deprecated protected boolean assumeJava9()
Deprecated.since Ant 1.10.7, use assumeJava9Plus, in the future if necessary combined with !assumeJava10PlusShall we assume JDK 9 command line switches?- Returns:
- true if JDK 9
- Since:
- Ant 1.9.8
-
assumeJava9Plus
protected boolean assumeJava9Plus()
Shall we assume JDK 9+ command line switches?- Returns:
- true if JDK 9+
- Since:
- Ant 1.10.2
-
assumeJava10Plus
protected boolean assumeJava10Plus()
Shall we assume JDK 10+ command line switches?- Returns:
- true if JDK 10+
- Since:
- Ant 1.10.7
-
getBootClassPath
protected Path getBootClassPath()
Combines a user specified bootclasspath with the system bootclasspath taking build.sysclasspath into account.- Returns:
- a non-null Path instance that combines the user specified and the system bootclasspath.
-
getNoDebugArgument
protected java.lang.String getNoDebugArgument()
The argument the compiler wants to see if the debug attribute has been set to false.A return value of
nullmeans no argument at all.- Returns:
- "-g:none" unless we expect to invoke a JDK 1.1 compiler.
- Since:
- Ant 1.6.3
-
-