Package org.aspectj.tools.ant.taskdefs
Class AjcTask
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.MatchingTask
org.aspectj.tools.ant.taskdefs.AjcTask
- All Implemented Interfaces:
org.apache.tools.ant.types.selectors.SelectorContainer
public class AjcTask
extends org.apache.tools.ant.taskdefs.MatchingTask
This runs the AspectJ 1.1 compiler, supporting all the command-line options. In 1.1.1, ajc copies resources from input jars, but
you can copy resources from the source directories using sourceRootCopyFilter. When not forking, things will be copied as needed
for each iterative compile, but when forking things are only copied at the completion of a successful compile.
See the development environment guide for usage documentation.
- Since:
- AspectJ 1.1, Ant 1.5
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classCommandline wrapper that only permits addition of non-empty values and converts to argfile form if necessary. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AjcTask.GuardedCommandstatic final Stringstatic final intstatic final intFields inherited from class org.apache.tools.ant.taskdefs.MatchingTask
filesetFields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapperFields inherited from class org.apache.tools.ant.ProjectComponent
project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidaddFlaggedPath(String flag, org.apache.tools.ant.types.Path path, List<String> list) protected voidaddListArgs(List<String> list) Add to list any path or plural arguments.protected final booleanThrow BuildException unless file is valid.org.apache.tools.ant.types.Pathorg.apache.tools.ant.types.Pathorg.apache.tools.ant.types.Pathorg.apache.tools.ant.types.Pathorg.apache.tools.ant.types.Pathorg.apache.tools.ant.types.Pathorg.apache.tools.ant.types.Pathorg.apache.tools.ant.types.Pathorg.apache.tools.ant.types.Pathorg.apache.tools.ant.types.Commandline.Argumentsupport for nested <jvmarg> elementsorg.apache.tools.ant.types.Pathorg.apache.tools.ant.types.Pathorg.apache.tools.ant.types.Pathprotected voidCalled when compile or incremental compile is completing, this completes the output jar or directory by copying resources if requested.protected intexecInOtherVM(String[] args) Execute in another process using the same JDK and the base directory of the project.voidexecute()Compile using ajc per settings.protected voidexecuteInOtherVM(String[] args) Execute in a separate VM.protected voidexecuteInSameVM(String[] args) Run the compile in the same VM by loading the compiler (Main), setting up any message holders, doing the compile, and converting abort/failure and error messages to BuildException, as appropriate.static FileFind aspectjtools.jar on the task or system classpath.protected voidprotected org.apache.tools.ant.types.PathincPath(org.apache.tools.ant.types.Path source, org.apache.tools.ant.types.Path toAdd) Add path elements to source path and return result.booleanisForked()booleanbooleanprotected voidlogVerbose(String text) booleanquit()Halt processing.voidreadArguments(String[] args) Read arguments in as if from a command line, mainly to support compiler adapter compilerarg subelement.voidreset()to use this same Task more than once (testing)voidsetArgfiles(org.apache.tools.ant.types.Path path) voidsetArgfilesref(org.apache.tools.ant.types.Reference ref) voidsetAspectpath(org.apache.tools.ant.types.Path path) voidsetAspectpathref(org.apache.tools.ant.types.Reference ref) voidsetBootclasspath(org.apache.tools.ant.types.Path path) voidsetBootclasspathref(org.apache.tools.ant.types.Reference bootclasspathref) voidsetCheckRuntimeVersion(boolean b) voidsetClasspath(org.apache.tools.ant.types.Path path) voidsetClasspathref(org.apache.tools.ant.types.Reference classpathref) voidsetCommandEditor(ICommandEditor editor) direct API for testingvoidsetCommandEditorClass(String className) Setup command-line filter.voidsetCompliance(String input) Language compliance level.voidsetCopyInjars(boolean doCopy) Flag to copy all non-.class contents of injars to outjar after compile completes.voidsetCrossrefs(boolean on) voidsetDebug(boolean debug) voidsetDebugLevel(String level) voidsetDeprecation(boolean deprecation) voidsetDestdir(File dir) voidsetEmacssym(boolean emacssym) voidsetEncoding(String encoding) voidsetExtdirs(org.apache.tools.ant.types.Path path) voidsetExtdirsref(org.apache.tools.ant.types.Reference ref) voidsetFailonerror(boolean failonerror) voidsetFork(boolean fork) voidsetForkclasspath(org.apache.tools.ant.types.Path path) voidsetForkclasspathref(org.apache.tools.ant.types.Reference forkclasspathref) voidsetHelp(boolean help) voidsetIncremental(boolean incremental) voidsetInjars(org.apache.tools.ant.types.Path path) voidsetInjarsref(org.apache.tools.ant.types.Reference ref) voidsetInpath(org.apache.tools.ant.types.Path path) voidsetInpathDirCopyFilter(String filter) Option to copy all files from all inpath directories except the files specified here.voidsetInpathref(org.apache.tools.ant.types.Reference ref) voidsetInxml(org.apache.tools.ant.types.Path path) voidsetInxmlref(org.apache.tools.ant.types.Reference ref) voidsetListFileArgs(boolean listFileArgs) voidvoidsetLogCommand(boolean logCommand) voidvoidsetMessageHolder(IMessageHolder holder) direct API for testingvoidsetMessageHolderClass(String className) Setup custom message handling.voidsetNoExit(boolean noExit) voidsetNoImportError(boolean noImportError) voidsetNowarn(boolean nowarn) voidsetNoWeave(boolean b) voidvoidsetOutxml(boolean outxml) voidsetOutxmlfile(String name) voidsetParameters(boolean b) voidsetPreserveAllLocals(boolean preserveAllLocals) voidControls whether annotation processing and/or compilation is done.voidsetProceedOnError(boolean proceedOnError) voidsetProcessor(String processors) -processor class1[,class2,class3...] Names of the annotation processors to run.voidsetProcessorpath(String processorpath) -processorpath path Specify where to find annotation processors; if this option is not used, the class path will be searched for processors.voidsetReferenceInfo(boolean referenceInfo) void-s dir Specify the directory where to place generated source files.voidsetShowWeaveInfo(boolean showweaveinfo) voidSource compliance level.voidsetSourceRootCopyFilter(String filter) Option to copy all files from all source root directories except those specified here.voidsetSourceRoots(org.apache.tools.ant.types.Path roots) voidsetSourcerootsref(org.apache.tools.ant.types.Reference ref) voidsetSrcDir(org.apache.tools.ant.types.Path path) voidsetTagFile(File file) voidvoidsetTime(boolean time) voidsetTimers(boolean timers) setupAjc(org.apache.tools.ant.taskdefs.Javac javac) This method extracts javac arguments to ajc, and add arguments to make ajc behave more like javac in copying resources.protected voidCreate any pseudo-options required to implement some of the macro optionsvoidsetVerbose(boolean verbose) voidsetVersion(boolean version) voidvoidvoidsetXaddSerialVersionUID(boolean addUID) voidsetXDoneSignal(String doneSignal) voidsetXJoinpoints(String optionalJoinpoints) void-Xlint:{error|warning|info} - set default level for -Xlint messagesvoidsetXlintfile(File xlintFile) -Xlintfile {lint.properties} - enable or disable specific forms of -Xlint messages based on a lint properties file (default isorg/aspectj/weaver/XLintDefault.properties)voidsetXlintwarnings(boolean xlintwarnings) -Xlint - set default level of -Xlint messages to warning (same as-Xlint:warning)voidsetXmlConfigured(boolean xmlConfigured) voidsetXNoInline(boolean noInline) voidsetXNotReweavable(boolean notReweavable) voidsetXNoWeave(boolean b) voidsetXReweavable(boolean reweavable) voidsetXTerminateAfterCompilation(boolean b) voidsetXWeaveDir(File file) protected StringvalidCommaList(String list, List valid, String label) protected StringvalidCommaList(String list, List valid, String label, int max) protected voidprotected FilezipDirectory(File dir) Methods inherited from class org.apache.tools.ant.taskdefs.MatchingTask
add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItemsMethods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeMethods inherited from class org.apache.tools.ant.ProjectComponent
getProject
-
Field Details
-
COMMAND_EDITOR_NAME
-
JAVA_VERSION_MIN
public static final int JAVA_VERSION_MIN- See Also:
-
JAVA_VERSION_MAX
public static final int JAVA_VERSION_MAX- See Also:
-
cmd
-
-
Constructor Details
-
AjcTask
public AjcTask()
-
-
Method Details
-
setupAjc
This method extracts javac arguments to ajc, and add arguments to make ajc behave more like javac in copying resources.Pass ajc-specific options using compilerarg sub-element:
<javac srcdir="src"> <compilerarg compiler="..." line="-argfile src/args.lst"/> <javac>Some javac arguments are not supported in this component (yet):String memoryInitialSize; boolean includeAntRuntime = true; boolean includeJavaRuntime = false;
Other javac arguments are not supported in ajc 1.1:boolean optimize; String forkedExecutable; FacadeTaskHelper facade; boolean depend; String debugLevel; Path compileSourcepath;
- Parameters:
javac- the Javac command to implement (not null)- Returns:
- null if no error, or String error otherwise
-
findAspectjtoolsJar
Find aspectjtools.jar on the task or system classpath. Acceptaspectj{-}tools{...}.jarmainly to support build systems using maven-style re-naming (e.g.,aspectj-tools-1.1.0.jar. Note that we search the task classpath first, though an entry on the system classpath would be loaded first, because it seems more correct as the more specific one.- Returns:
- readable File for aspectjtools.jar, or null if not found.
-
reset
public void reset()to use this same Task more than once (testing) -
ignore
-
validCommaList
-
validCommaList
-
setProc
Controls whether annotation processing and/or compilation is done. -proc:none means that compilation takes place without annotation processing. -proc:only means that only annotation processing is done, without any subsequent compilation. -
setProcessor
-processor class1[,class2,class3...] Names of the annotation processors to run. This bypasses the default discovery process. -
setProcessorpath
-processorpath path Specify where to find annotation processors; if this option is not used, the class path will be searched for processors. -
setS
-s dir Specify the directory where to place generated source files. The directory must already exist; javac will not create it. If a class is part of a package, the compiler puts the source file in a subdirectory reflecting the package name, creating directories as needed. For example, if you specify -s C:\mysrc and the class is called com.mypackage.MyClass, then the source file will be placed in C:\mysrc\com\mypackage\MyClass.java. -
setIncremental
public void setIncremental(boolean incremental) -
setLogCommand
public void setLogCommand(boolean logCommand) -
setHelp
public void setHelp(boolean help) -
setVersion
public void setVersion(boolean version) -
setXTerminateAfterCompilation
public void setXTerminateAfterCompilation(boolean b) -
setXReweavable
public void setXReweavable(boolean reweavable) -
setXmlConfigured
public void setXmlConfigured(boolean xmlConfigured) -
setXJoinpoints
-
setCheckRuntimeVersion
public void setCheckRuntimeVersion(boolean b) -
setXNoWeave
public void setXNoWeave(boolean b) -
setNoWeave
public void setNoWeave(boolean b) -
setXNotReweavable
public void setXNotReweavable(boolean notReweavable) -
setXaddSerialVersionUID
public void setXaddSerialVersionUID(boolean addUID) -
setXNoInline
public void setXNoInline(boolean noInline) -
setShowWeaveInfo
public void setShowWeaveInfo(boolean showweaveinfo) -
setNowarn
public void setNowarn(boolean nowarn) -
setDeprecation
public void setDeprecation(boolean deprecation) -
setWarn
-
setDebug
public void setDebug(boolean debug) -
setDebugLevel
-
setEmacssym
public void setEmacssym(boolean emacssym) -
setCrossrefs
public void setCrossrefs(boolean on) -
setXlintwarnings
public void setXlintwarnings(boolean xlintwarnings) -Xlint - set default level of -Xlint messages to warning (same as-Xlint:warning) -
setXlint
-Xlint:{error|warning|info} - set default level for -Xlint messages- Parameters:
xlint- the String with one of error, warning, ignored
-
setXlintfile
-Xlintfile {lint.properties} - enable or disable specific forms of -Xlint messages based on a lint properties file (default isorg/aspectj/weaver/XLintDefault.properties)- Parameters:
xlintFile- the File with lint properties
-
setPreserveAllLocals
public void setPreserveAllLocals(boolean preserveAllLocals) -
setNoImportError
public void setNoImportError(boolean noImportError) -
setEncoding
-
setLog
-
setProceedOnError
public void setProceedOnError(boolean proceedOnError) -
setVerbose
public void setVerbose(boolean verbose) -
setTimers
public void setTimers(boolean timers) -
setListFileArgs
public void setListFileArgs(boolean listFileArgs) -
setReferenceInfo
public void setReferenceInfo(boolean referenceInfo) -
setTime
public void setTime(boolean time) -
setNoExit
public void setNoExit(boolean noExit) -
setFailonerror
public void setFailonerror(boolean failonerror) -
isForked
public boolean isForked()- Returns:
- true if fork was set
-
setFork
public void setFork(boolean fork) -
setMaxmem
-
createJvmarg
public org.apache.tools.ant.types.Commandline.Argument createJvmarg()support for nested <jvmarg> elements -
createCompilerarg
-
setTagFile
-
setOutjar
-
setOutxml
public void setOutxml(boolean outxml) -
setOutxmlfile
-
setDestdir
-
setTarget
- Parameters:
input- a String in TARGET_INPUTS
-
setCompliance
Language compliance level. If not set explicitly, eclipse default holds.- Parameters:
input- a String in COMPLIANCE_INPUTS
-
setSource
Source compliance level. If not set explicitly, eclipse default holds.- Parameters:
input- a String in SOURCE_INPUTS
-
setParameters
public void setParameters(boolean b) -
setCopyInjars
public void setCopyInjars(boolean doCopy) Flag to copy all non-.class contents of injars to outjar after compile completes. Requires both injars and outjar.- Parameters:
doCopy-
-
setSourceRootCopyFilter
Option to copy all files from all source root directories except those specified here. If this is specified and sourceroots are specified, then this will copy all files except those specified in the filter pattern. Requires sourceroots.- Parameters:
filter- a String acceptable as an excludes filter for an Ant Zip fileset.
-
setInpathDirCopyFilter
Option to copy all files from all inpath directories except the files specified here. If this is specified and inpath directories are specified, then this will copy all files except those specified in the filter pattern. Requires inpath. If the input does not contain "**\/*.class", then this prepends it, to avoid overwriting woven classes with unwoven input.- Parameters:
filter- a String acceptable as an excludes filter for an Ant Zip fileset.
-
setX
-
setXDoneSignal
-
setMessageHolder
direct API for testing -
setMessageHolderClass
Setup custom message handling.- Parameters:
className- the String fully-qualified-name of a class reachable from this object's class loader, implementing IMessageHolder, and having a public no-argument constructor.- Throws:
org.apache.tools.ant.BuildException- if unable to create instance of className
-
setCommandEditor
direct API for testing -
setCommandEditorClass
Setup command-line filter. To do this staticly, define the environment variableorg.aspectj.tools.ant.taskdefs.AjcTask.COMMAND_EDITORwith theclassNameparameter.- Parameters:
className- the String fully-qualified-name of a class reachable from this object's class loader, implementing ICommandEditor, and having a public no-argument constructor.- Throws:
org.apache.tools.ant.BuildException- if unable to create instance of className
-
incPath
protected org.apache.tools.ant.types.Path incPath(org.apache.tools.ant.types.Path source, org.apache.tools.ant.types.Path toAdd) Add path elements to source path and return result. Elements are added even if they do not exist.- Parameters:
source- the Path to add to - may be nulltoAdd- the Path to add - may be null- Returns:
- the (never-null) Path that results
-
setSourcerootsref
public void setSourcerootsref(org.apache.tools.ant.types.Reference ref) -
setSourceRoots
public void setSourceRoots(org.apache.tools.ant.types.Path roots) -
createSourceRoots
public org.apache.tools.ant.types.Path createSourceRoots() -
setXWeaveDir
-
setInjarsref
public void setInjarsref(org.apache.tools.ant.types.Reference ref) -
setInpathref
public void setInpathref(org.apache.tools.ant.types.Reference ref) -
setInjars
public void setInjars(org.apache.tools.ant.types.Path path) -
setInpath
public void setInpath(org.apache.tools.ant.types.Path path) -
createInjars
public org.apache.tools.ant.types.Path createInjars() -
createInpath
public org.apache.tools.ant.types.Path createInpath() -
setClasspath
public void setClasspath(org.apache.tools.ant.types.Path path) -
setClasspathref
public void setClasspathref(org.apache.tools.ant.types.Reference classpathref) -
createClasspath
public org.apache.tools.ant.types.Path createClasspath() -
setBootclasspath
public void setBootclasspath(org.apache.tools.ant.types.Path path) -
setBootclasspathref
public void setBootclasspathref(org.apache.tools.ant.types.Reference bootclasspathref) -
createBootclasspath
public org.apache.tools.ant.types.Path createBootclasspath() -
setForkclasspath
public void setForkclasspath(org.apache.tools.ant.types.Path path) -
setForkclasspathref
public void setForkclasspathref(org.apache.tools.ant.types.Reference forkclasspathref) -
createForkclasspath
public org.apache.tools.ant.types.Path createForkclasspath() -
setExtdirs
public void setExtdirs(org.apache.tools.ant.types.Path path) -
setExtdirsref
public void setExtdirsref(org.apache.tools.ant.types.Reference ref) -
createExtdirs
public org.apache.tools.ant.types.Path createExtdirs() -
setAspectpathref
public void setAspectpathref(org.apache.tools.ant.types.Reference ref) -
setAspectpath
public void setAspectpath(org.apache.tools.ant.types.Path path) -
createAspectpath
public org.apache.tools.ant.types.Path createAspectpath() -
setSrcDir
public void setSrcDir(org.apache.tools.ant.types.Path path) -
createSrc
public org.apache.tools.ant.types.Path createSrc() -
createSrcdir
public org.apache.tools.ant.types.Path createSrcdir() -
isInIncrementalMode
public boolean isInIncrementalMode()- Returns:
- true if in incremental mode (command-line or file)
-
isInIncrementalFileMode
public boolean isInIncrementalFileMode()- Returns:
- true if in incremental file mode
-
setArgfilesref
public void setArgfilesref(org.apache.tools.ant.types.Reference ref) -
setArgfiles
public void setArgfiles(org.apache.tools.ant.types.Path path) -
createArgfiles
public org.apache.tools.ant.types.Path createArgfiles() -
setInxmlref
public void setInxmlref(org.apache.tools.ant.types.Reference ref) -
setInxml
public void setInxml(org.apache.tools.ant.types.Path path) -
createInxml
public org.apache.tools.ant.types.Path createInxml() -
execute
public void execute() throws org.apache.tools.ant.BuildExceptionCompile using ajc per settings.- Overrides:
executein classorg.apache.tools.ant.Task- Throws:
org.apache.tools.ant.BuildException- if the compilation has problems or if there were compiler errors and failonerror is true.
-
quit
public boolean quit()Halt processing. This tells main in the same vm to quit. It fails when running in forked mode.- Returns:
- true if not in forked mode and main has quit or been told to quit
-
setupOptions
protected void setupOptions()Create any pseudo-options required to implement some of the macro options- Throws:
org.apache.tools.ant.BuildException- if options conflict
-
zipDirectory
-
verifyOptions
protected void verifyOptions()- Throws:
org.apache.tools.ant.BuildException- if options conflict
-
executeInSameVM
Run the compile in the same VM by loading the compiler (Main), setting up any message holders, doing the compile, and converting abort/failure and error messages to BuildException, as appropriate.- Throws:
org.apache.tools.ant.BuildException- if abort or failure messages or if errors and failonerror.
-
executeInOtherVM
Execute in a separate VM. Differences from normal same-VM execution:- ignores any message holder {class} set
- No resource-copying between interative runs
- failonerror fails when process interface fails to return negative values
- Parameters:
args- String[] of the complete compiler command to execute- Throws:
org.apache.tools.ant.BuildException- if ajc aborts (negative value) or if failonerror and there were compile errors.
-
execInOtherVM
Execute in another process using the same JDK and the base directory of the project. XXX correct? -
addFlaggedPath
-
addListArgs
-
check
protected final boolean check(File file, String name, boolean isDir, org.apache.tools.ant.Location loc) Throw BuildException unless file is valid.- Parameters:
file- the File to checkname- the symbolic name to print on errorisDir- if true, verify file is a directoryloc- the Location used to create sensible BuildException- Returns:
- Throws:
org.apache.tools.ant.BuildException- unless file valid
-
doCompletionTasks
protected void doCompletionTasks()Called when compile or incremental compile is completing, this completes the output jar or directory by copying resources if requested. Note: this is a callback run synchronously by the compiler. That means exceptions thrown here are caught by Main.run(..) and passed to the message handler. -
readArguments
Read arguments in as if from a command line, mainly to support compiler adapter compilerarg subelement.- Parameters:
args- the String[] of arguments to read
-
logVerbose
-