Package org.codehaus.mojo.aspectj
Class AbstractAjcCompiler
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.codehaus.mojo.aspectj.AbstractAjcMojo
org.codehaus.mojo.aspectj.AbstractAjcCompiler
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
AjcCompileMojo
,AjcTestCompileMojo
Base class for the two aspectJ compile-time weaving mojos.
For all available options see ajc-ref
- Author:
- Kaare Nilsen
-
Field Summary
Modifier and TypeFieldDescriptionSets additional compiler arguments, e.g.Holder for ajc compiler optionsprotected String
Where to find the ajdt build definition file.protected String
The filename holding AJC build arguments.protected String
The source directory for the aspects.protected String
Override location of VM's bootclasspath for purposes of evaluating types when compiling.protected String
Specify compiler compliance setting (same as setting 'source' and 'target' to the same level).protected boolean
generate .ajsym file into the output directoryprotected boolean
Toggle warning messages on deprecationsprotected boolean
Generate .ajesym symbol files for emacs support.protected String
Specify default source encoding format.protected String[]
List of ant-style patterns used to specify the aspects that should be excluded when compiling.protected boolean
Forces re-compilation, regardless of whether the compiler arguments or the sources have changed.protected String[]
List of ant-style patterns used to specify the aspects that should be included when compiling.protected boolean
Emit no errors for unresolved imports;protected boolean
Generate aop.xml file for load-time weaving with default name (/META-INF/aop.xml).protected String
Generate aop.xml file for load-time weaving with custom name.protected boolean
Set the compiler "parameters" argument.protected boolean
Preserve all local variables during code generation (to facilitate debugging).protected String
Set the compiler "proc" argument.protected boolean
Keep compiling after error, dumping class files with problem methodsprotected boolean
Compute reference information.protected int
Repeat compilation process N times (typically to do performance analysis).Holds all files found using the includes, excludes parameters.protected boolean
Emit messages about weavingprotected String
Specify source code language level (1.3 to 1.9, 10 to 17).protected String
Specify bytecode target setting (1.3 to 1.9, 10 to 17).protected String
The source directory for the test aspects.protected boolean
Emit messages about accessed/processed compilation unitsprotected String
Emit warnings for any instances of the comma-delimited list of questionable code.protected boolean
Causes the compiler to calculate and add the SerialVersionUID field to any type implementingSerializable
that is affected by an aspect.protected String
(Experimental) Allows code to be generated that targets a 1.2 or a 1.5 level AspectJ runtime (default 1.5)List holding all accepted values for theXajruntimetarget
parameter.protected boolean
Enables the compiler to support hasmethod(method_pattern) and hasfield(field_pattern) type patterns, but only within declare statements.protected String
supply a comma separated list of new joinpoints that can be identified by pointcuts.protected String
Set default level for messages about potential programming mistakes in crosscutting code.protected File
Specify properties file to set levels for specific crosscutting messages.protected boolean
(Experimental) do not inline around adviceprotected boolean
(Experimental) Create class files that can't be subsequently rewoven by AspectJ.protected boolean
(Experimental) runs weaver in reweavable mode which causes it to create woven classes that can be rewoven, subject to the restriction that on attempting a reweave all the types that advised the woven type must be accessible.protected boolean
(Experimental) Normally it is an error to declare aspectsSerializable
.Allows the caller to provide additional arguments in a Map format.protected boolean
Causes compiler to terminate before weavingFields inherited from class org.codehaus.mojo.aspectj.AbstractAjcMojo
aspectLibraries, basedir, project, weaveDependencies, weaveDirectories, xmlConfigured
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Assembles a complete ajc compiler arguments list.void
execute()
Do the AspectJ compiling.protected abstract String
Abstract method used by child classes to specify additional aspect paths.Abstract method used by child classes to specify the correct output directory for compiled classes.protected abstract File
The directory for sources generated by annotation processing.protected abstract org.codehaus.plexus.util.Scanner[]
protected abstract File
The directory where compiled classes go.Abstract method used by child classes to specify the correct source directory for classes.protected boolean
Checks modifications that would make us need a buildvoid
setArgumentFileName
(String argumentFileName) void
setBootClassPath
(String bootclasspath) void
setComplianceLevel
(String complianceLevel) Setters which when called sets compiler argumentsvoid
setCrossrefs
(boolean crossrefs) void
setDeprecation
(boolean deprecation) void
setEmacssym
(boolean emacssym) void
setEncoding
(String encoding) void
setNoImportError
(boolean noImportError) void
setOutxml
(boolean outxml) void
setOutxmlfile
(String outxmlfile) void
setParameters
(boolean parameters) void
setPreserveAllLocals
(boolean preserveAllLocals) void
setProceedOnError
(boolean proceedOnError) void
setReferenceInfo
(boolean referenceInfo) void
setRepeat
(int repeat) void
setShowWeaveInfo
(boolean showWeaveInfo) void
void
void
setVerbose
(boolean verbose) void
void
setXaddSerialVersionUID
(boolean xaddSerialVersionUID) void
setXajruntimetarget
(String xajruntimetarget) void
setXhasMember
(boolean xhasMember) void
setXjoinpoints
(String xjoinpoints) void
void
setXlintfile
(File xlintfile) void
setXnoInline
(boolean xnoInline) void
setXnotReweavable
(boolean xnotReweavable) void
setXreweavable
(boolean xreweavable) void
setXserializableAspects
(boolean xserializableAspects) void
void
setXterminateAfterCompilation
(boolean xterminateAfterCompilation) Methods inherited from class org.codehaus.mojo.aspectj.AbstractAjcMojo
isSkip, setXmlConfigured
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
XAJRUNTIMETARGET_SUPPORTED_VALUES
List holding all accepted values for theXajruntimetarget
parameter. -
aspectDirectory
The source directory for the aspects. -
testAspectDirectory
The source directory for the test aspects. -
includes
List of ant-style patterns used to specify the aspects that should be included when compiling. When none specified all .java and .aj files in the project source directories, or directories specified by the ajdtDefFile property are included. -
excludes
List of ant-style patterns used to specify the aspects that should be excluded when compiling. When none specified all .java and .aj files in the project source directories, or directories specified by the ajdtDefFile property are included. -
ajdtBuildDefFile
Where to find the ajdt build definition file. If set this will override the use of project sourcedirs. -
outxml
@Parameter protected boolean outxmlGenerate aop.xml file for load-time weaving with default name (/META-INF/aop.xml). -
outxmlfile
Generate aop.xml file for load-time weaving with custom name. -
emacssym
@Parameter protected boolean emacssymGenerate .ajesym symbol files for emacs support. -
proc
Set the compiler "proc" argument. Aspectj supports Annotation processing since 1.8.2, it can been disabled byproc:none
.- See Also:
-
parameters
@Parameter protected boolean parametersSet the compiler "parameters" argument. -
Xset
Allows the caller to provide additional arguments in a Map format. For example:<configuration> <Xset> <overWeaving>true</overWeaving> <avoidFinal>false</avoidFinal> </Xset> </configuration>
- Since:
- 1.5
-
crossrefs
@Parameter protected boolean crossrefsgenerate .ajsym file into the output directory -
Xlint
Set default level for messages about potential programming mistakes in crosscutting code. {level} may be ignore, warning, or error. This overrides entries in org/aspectj/weaver/XlintDefault.properties from aspectjtools.jar. -
Xlintfile
Specify properties file to set levels for specific crosscutting messages. PropertyFile is a path to a Java .properties file that takes the same property names and values as org/aspectj/weaver/XlintDefault.properties from aspectjtools.jar, which it also overrides. -
XhasMember
@Parameter protected boolean XhasMemberEnables the compiler to support hasmethod(method_pattern) and hasfield(field_pattern) type patterns, but only within declare statements. It's experimental and undocumented because it may change, and because it doesn't yet take into account ITDs.- Since:
- 1.3
-
target
Specify bytecode target setting (1.3 to 1.9, 10 to 17). See 'complianceLevel' for details.- See Also:
-
source
Specify source code language level (1.3 to 1.9, 10 to 17). See 'complianceLevel' for details.- See Also:
-
complianceLevel
Specify compiler compliance setting (same as setting 'source' and 'target' to the same level). Permitted values: 1.3, 1.4, 1.5, 5, 5.0, 1.6, 6, 6.0, 1.7, 7, 7.0, 1.8, 8, 8.0, 1.9, 9, 9.0, 10, 10.0, 11, 11.0, 12, 12.0, 13, 13.0, 14, 14.0, 15, 15.0, 16, 16.0, 17, 17.0- See Also:
-
deprecation
@Parameter protected boolean deprecationToggle warning messages on deprecations -
noImportError
@Parameter protected boolean noImportErrorEmit no errors for unresolved imports; -
proceedOnError
@Parameter protected boolean proceedOnErrorKeep compiling after error, dumping class files with problem methods -
preserveAllLocals
@Parameter protected boolean preserveAllLocalsPreserve all local variables during code generation (to facilitate debugging). -
referenceInfo
@Parameter protected boolean referenceInfoCompute reference information. -
encoding
Specify default source encoding format. -
verbose
@Parameter protected boolean verboseEmit messages about accessed/processed compilation units -
showWeaveInfo
@Parameter protected boolean showWeaveInfoEmit messages about weaving -
repeat
@Parameter protected int repeatRepeat compilation process N times (typically to do performance analysis). -
Xreweavable
@Parameter protected boolean Xreweavable(Experimental) runs weaver in reweavable mode which causes it to create woven classes that can be rewoven, subject to the restriction that on attempting a reweave all the types that advised the woven type must be accessible. -
XnotReweavable
@Parameter protected boolean XnotReweavable(Experimental) Create class files that can't be subsequently rewoven by AspectJ. -
XnoInline
@Parameter protected boolean XnoInline(Experimental) do not inline around advice -
XserializableAspects
@Parameter protected boolean XserializableAspects(Experimental) Normally it is an error to declare aspectsSerializable
. This option removes that restriction. -
XaddSerialVersionUID
@Parameter protected boolean XaddSerialVersionUIDCauses the compiler to calculate and add the SerialVersionUID field to any type implementingSerializable
that is affected by an aspect. The field is calculated based on the class before weaving has taken place. -
XterminateAfterCompilation
@Parameter protected boolean XterminateAfterCompilationCauses compiler to terminate before weaving -
Xajruntimetarget
(Experimental) Allows code to be generated that targets a 1.2 or a 1.5 level AspectJ runtime (default 1.5) -
Xjoinpoints
supply a comma separated list of new joinpoints that can be identified by pointcuts. Values are: arrayconstruction, synchronization -
bootclasspath
Override location of VM's bootclasspath for purposes of evaluating types when compiling. Path is a single argument containing a list of paths to zip files or directories, delimited by the platform-specific path delimiter. -
warn
Emit warnings for any instances of the comma-delimited list of questionable code. Supported values are shown in the list below, with their respective explanations - as copied directly from the AJC reference.- constructorName
- method with constructor name
- packageDefaultMethod
- attempt to override package-default method
- deprecation
- usage of deprecated type or member
- maskedCatchBlocks
- hidden catch block
- unusedLocals
- local variable never read
- unusedArguments
- method argument never read
- unusedImports
- import statement not used by code in file
- none
- suppress all compiler warnings
- See Also:
-
argumentFileName
The filename holding AJC build arguments. The file will be placed in the project build output directory, and will contain all the arguments passed to the AJC compiler in the last run, and also all the files included in the AJC build.Sample content shown below to illustrate typical content within the builddef.lst file:
-1.6 -encoding UTF-8 -classpath /my/library/lib.jar:/somewhere/aspectjrt.jar:/my/project/target/classes -d /my/project/target/classes /my/project/src/main/java/org/acme/ValidationAspect.java
-
forceAjcCompile
@Parameter(defaultValue="false") protected boolean forceAjcCompileForces re-compilation, regardless of whether the compiler arguments or the sources have changed. -
additionalCompilerArgs
Sets additional compiler arguments, e.g.
This option can be used in case you want to use AJC options not (yet) supported by this plugin.<compilerArgs> <arg>-Xmaxerrs=1000</arg> <arg>-Xlint</arg> <arg>-J-Duser.language=en_us</arg> </compilerArgs>
Caveat: Be careful when using this option and select the additional compiler arguments wisely, because behaviour is undefined if you add arguments which have already been added by the plugin using regular parameters or their default values. The resulting compiler command line will in that case contain duplicate arguments, which might be illegal depending on the specific argument. Do not expect to be able to manually override existing arguments using this option or to replace whole argument lists.
- Since:
- 1.13
-
ajcOptions
Holder for ajc compiler options -
resolvedIncludes
Holds all files found using the includes, excludes parameters.
-
-
Constructor Details
-
AbstractAjcCompiler
public AbstractAjcCompiler()
-
-
Method Details
-
getClasspathDirectories
Abstract method used by child classes to specify the correct output directory for compiled classes.- Returns:
- the directories containing compiled classes.
-
getOutputDirectory
The directory where compiled classes go.- Returns:
- the outputDirectory
-
getGeneratedSourcesDirectory
The directory for sources generated by annotation processing.- Returns:
- the generatedSourcesDirectory
-
getSourceDirectories
Abstract method used by child classes to specify the correct source directory for classes.- Returns:
- where sources may be found.
-
getJavaSources
protected abstract org.codehaus.plexus.util.Scanner[] getJavaSources() -
getAdditionalAspectPaths
Abstract method used by child classes to specify additional aspect paths.- Returns:
- the additional aspect paths
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionExceptionDo the AspectJ compiling.- Throws:
org.apache.maven.plugin.MojoExecutionException
- if arguments file cannot be written
-
assembleArguments
protected void assembleArguments() throws org.apache.maven.plugin.MojoExecutionExceptionAssembles a complete ajc compiler arguments list.- Throws:
org.apache.maven.plugin.MojoExecutionException
- error in configuration
-
getIncludedSources
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
isBuildNeeded
protected boolean isBuildNeeded() throws org.apache.maven.plugin.MojoExecutionExceptionChecks modifications that would make us need a build- Returns:
true
if build is needed, otherwisefalse
- Throws:
org.apache.maven.plugin.MojoExecutionException
- if an unexpected error occurs, e.g. weave directories cannot be resolved
-
setComplianceLevel
Setters which when called sets compiler arguments- Parameters:
complianceLevel
- the complianceLevel
-
setDeprecation
public void setDeprecation(boolean deprecation) -
setEmacssym
public void setEmacssym(boolean emacssym) -
setParameters
public void setParameters(boolean parameters) -
setCrossrefs
public void setCrossrefs(boolean crossrefs) -
setEncoding
-
setNoImportError
public void setNoImportError(boolean noImportError) -
setOutxml
public void setOutxml(boolean outxml) -
setOutxmlfile
-
setPreserveAllLocals
public void setPreserveAllLocals(boolean preserveAllLocals) -
setProceedOnError
public void setProceedOnError(boolean proceedOnError) -
setReferenceInfo
public void setReferenceInfo(boolean referenceInfo) -
setRepeat
public void setRepeat(int repeat) -
setShowWeaveInfo
public void setShowWeaveInfo(boolean showWeaveInfo) -
setTarget
-
setSource
-
setVerbose
public void setVerbose(boolean verbose) -
setXhasMember
public void setXhasMember(boolean xhasMember) -
setXlint
-
setXset
-
setXlintfile
-
setXnoInline
public void setXnoInline(boolean xnoInline) -
setXreweavable
public void setXreweavable(boolean xreweavable) -
setXnotReweavable
public void setXnotReweavable(boolean xnotReweavable) -
setXserializableAspects
public void setXserializableAspects(boolean xserializableAspects) -
setXaddSerialVersionUID
public void setXaddSerialVersionUID(boolean xaddSerialVersionUID) -
setXterminateAfterCompilation
public void setXterminateAfterCompilation(boolean xterminateAfterCompilation) -
setXajruntimetarget
-
setBootClassPath
-
setXjoinpoints
-
setWarn
-
setArgumentFileName
-