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
public abstract class AbstractAjcCompiler extends AbstractAjcMojo
Base class for the two aspectJ compile-time weaving mojos.For all available options see ajc-ref
- Author:
- Kaare Nilsen
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.String>
additionalCompilerArgs
Sets additional compiler arguments, e.g.protected java.util.List<java.lang.String>
ajcOptions
Holder for ajc compiler optionsprotected java.lang.String
ajdtBuildDefFile
Where to find the ajdt build definition file.protected java.lang.String
argumentFileName
The filename holding AJC build arguments.protected java.lang.String
aspectDirectory
The source directory for the aspects.protected java.lang.String
bootclasspath
Override location of VM's bootclasspath for purposes of evaluating types when compiling.protected java.lang.String
complianceLevel
Specify compiler compliance setting (same as setting 'source' and 'target' to the same level).protected boolean
crossrefs
generate .ajsym file into the output directoryprotected boolean
deprecation
Toggle warning messages on deprecationsprotected boolean
emacssym
Generate .ajesym symbol files for emacs support.protected java.lang.String
encoding
Specify default source encoding format.protected java.lang.String[]
excludes
List of ant-style patterns used to specify the aspects that should be excluded when compiling.protected boolean
forceAjcCompile
Forces re-compilation, regardless of whether the compiler arguments or the sources have changed.protected java.lang.String[]
includes
List of ant-style patterns used to specify the aspects that should be included when compiling.protected boolean
noImportError
Emit no errors for unresolved imports;protected boolean
outxml
Generate aop.xml file for load-time weaving with default name (/META-INF/aop.xml).protected java.lang.String
outxmlfile
Generate aop.xml file for load-time weaving with custom name.protected boolean
parameters
Set the compiler "parameters" argument.protected boolean
preserveAllLocals
Preserve all local variables during code generation (to facilitate debugging).protected java.lang.String
proc
Set the compiler "proc" argument.protected boolean
proceedOnError
Keep compiling after error, dumping class files with problem methodsprotected boolean
referenceInfo
Compute reference information.protected int
repeat
Repeat compilation process N times (typically to do performance analysis).protected java.util.Set<java.lang.String>
resolvedIncludes
Holds all files found using the includes, excludes parameters.protected boolean
showWeaveInfo
Emit messages about weavingprotected java.lang.String
source
Specify source code language level (1.3 to 1.9, 10 to 16).protected java.lang.String
target
Specify bytecode target setting (1.3 to 1.9, 10 to 16).protected java.lang.String
testAspectDirectory
The source directory for the test aspects.protected boolean
verbose
Emit messages about accessed/processed compilation unitsprotected java.lang.String
warn
Emit warnings for any instances of the comma-delimited list of questionable code.protected boolean
XaddSerialVersionUID
Causes the compiler to calculate and add the SerialVersionUID field to any type implementingSerializable
that is affected by an aspect.protected java.lang.String
Xajruntimetarget
(Experimental) Allows code to be generated that targets a 1.2 or a 1.5 level AspectJ runtime (default 1.5)static java.util.List<java.lang.String>
XAJRUNTIMETARGET_SUPPORTED_VALUES
List holding all accepted values for theXajruntimetarget
parameter.protected boolean
XhasMember
Enables the compiler to support hasmethod(method_pattern) and hasfield(field_pattern) type patterns, but only within declare statements.protected java.lang.String
Xjoinpoints
supply a comma separated list of new joinpoints that can be identified by pointcuts.protected java.lang.String
Xlint
Set default level for messages about potential programming mistakes in crosscutting code.protected java.io.File
Xlintfile
Specify properties file to set levels for specific crosscutting messages.protected boolean
XnoInline
(Experimental) do not inline around adviceprotected boolean
XnotReweavable
(Experimental) Create class files that can't be subsequently rewoven by AspectJ.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.protected boolean
XserializableAspects
(Experimental) Normally it is an error to declare aspectsSerializable
.protected java.util.Map<java.lang.String,java.lang.String>
Xset
Allows the caller to provide additional arguments in a Map format.protected boolean
XterminateAfterCompilation
Causes compiler to terminate before weaving-
Fields inherited from class org.codehaus.mojo.aspectj.AbstractAjcMojo
aspectLibraries, basedir, project, weaveDependencies, weaveDirectories, xmlConfigured
-
-
Constructor Summary
Constructors Constructor Description AbstractAjcCompiler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
assembleArguments()
Assembles a complete ajc compiler arguments list.void
execute()
Do the AspectJ compiling.protected abstract java.lang.String
getAdditionalAspectPaths()
Abstract method used by child classes to specify additional aspect paths.protected abstract java.util.List<java.lang.String>
getClasspathDirectories()
Abstract method used by child classes to specify the correct output directory for compiled classes.protected abstract java.io.File
getGeneratedSourcesDirectory()
The directory for sources generated by annotation processing.protected java.util.Set<java.lang.String>
getIncludedSources()
protected abstract org.codehaus.plexus.util.Scanner[]
getJavaSources()
protected abstract java.io.File
getOutputDirectory()
The directory where compiled classes go.protected abstract java.util.List<java.lang.String>
getSourceDirectories()
Abstract method used by child classes to specify the correct source directory for classes.protected boolean
isBuildNeeded()
Checks modifications that would make us need a buildvoid
setArgumentFileName(java.lang.String argumentFileName)
void
setBootClassPath(java.lang.String bootclasspath)
void
setComplianceLevel(java.lang.String complianceLevel)
Setters which when called sets compiler argumentsvoid
setCrossrefs(boolean crossrefs)
void
setDeprecation(boolean deprecation)
void
setEmacssym(boolean emacssym)
void
setEncoding(java.lang.String encoding)
void
setNoImportError(boolean noImportError)
void
setOutxml(boolean outxml)
void
setOutxmlfile(java.lang.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
setSource(java.lang.String source)
void
setTarget(java.lang.String target)
void
setVerbose(boolean verbose)
void
setWarn(java.lang.String warn)
void
setXaddSerialVersionUID(boolean xaddSerialVersionUID)
void
setXajruntimetarget(java.lang.String xajruntimetarget)
void
setXhasMember(boolean xhasMember)
void
setXjoinpoints(java.lang.String xjoinpoints)
void
setXlint(java.lang.String xlint)
void
setXlintfile(java.io.File xlintfile)
void
setXnoInline(boolean xnoInline)
void
setXnotReweavable(boolean xnotReweavable)
void
setXreweavable(boolean xreweavable)
void
setXserializableAspects(boolean xserializableAspects)
void
setXset(java.util.Map<java.lang.String,java.lang.String> xset)
void
setXterminateAfterCompilation(boolean xterminateAfterCompilation)
-
Methods inherited from class org.codehaus.mojo.aspectj.AbstractAjcMojo
isSkip, setXmlConfigured
-
-
-
-
Field Detail
-
XAJRUNTIMETARGET_SUPPORTED_VALUES
public static final java.util.List<java.lang.String> XAJRUNTIMETARGET_SUPPORTED_VALUES
List holding all accepted values for theXajruntimetarget
parameter.
-
aspectDirectory
@Parameter(defaultValue="src/main/aspect") protected java.lang.String aspectDirectory
The source directory for the aspects.
-
testAspectDirectory
@Parameter(defaultValue="src/test/aspect") protected java.lang.String testAspectDirectory
The source directory for the test aspects.
-
includes
@Parameter protected java.lang.String[] 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
@Parameter protected java.lang.String[] 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
@Parameter protected java.lang.String ajdtBuildDefFile
Where to find the ajdt build definition file. If set this will override the use of project sourcedirs.
-
outxml
@Parameter protected boolean outxml
Generate aop.xml file for load-time weaving with default name (/META-INF/aop.xml).
-
outxmlfile
@Parameter protected java.lang.String outxmlfile
Generate aop.xml file for load-time weaving with custom name.
-
emacssym
@Parameter protected boolean emacssym
Generate .ajesym symbol files for emacs support.
-
proc
@Parameter protected java.lang.String proc
Set the compiler "proc" argument. Aspectj supports Annotation processing since 1.8.2, it can been disabled byproc:none
.- See Also:
- AspectJ 1.8.2 Release notes, Annotation Processing
-
parameters
@Parameter protected boolean parameters
Set the compiler "parameters" argument.
-
Xset
@Parameter protected java.util.Map<java.lang.String,java.lang.String> 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 crossrefs
generate .ajsym file into the output directory
-
Xlint
@Parameter protected java.lang.String 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
@Parameter protected java.io.File 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 XhasMember
Enables 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
@Parameter(defaultValue="${project.build.java.target}") protected java.lang.String target
Specify bytecode target setting (1.3 to 1.9, 10 to 16). See 'complianceLevel' for details.
-
source
@Parameter(defaultValue="${mojo.java.target}") protected java.lang.String source
Specify source code language level (1.3 to 1.9, 10 to 16). See 'complianceLevel' for details.
-
complianceLevel
@Parameter(defaultValue="1.4") protected java.lang.String 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.
-
deprecation
@Parameter protected boolean deprecation
Toggle warning messages on deprecations
-
noImportError
@Parameter protected boolean noImportError
Emit no errors for unresolved imports;
-
proceedOnError
@Parameter protected boolean proceedOnError
Keep compiling after error, dumping class files with problem methods
-
preserveAllLocals
@Parameter protected boolean preserveAllLocals
Preserve all local variables during code generation (to facilitate debugging).
-
referenceInfo
@Parameter protected boolean referenceInfo
Compute reference information.
-
encoding
@Parameter(property="project.build.sourceEncoding") protected java.lang.String encoding
Specify default source encoding format.
-
verbose
@Parameter protected boolean verbose
Emit messages about accessed/processed compilation units
-
showWeaveInfo
@Parameter protected boolean showWeaveInfo
Emit messages about weaving
-
repeat
@Parameter protected int repeat
Repeat 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 XaddSerialVersionUID
Causes 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 XterminateAfterCompilation
Causes compiler to terminate before weaving
-
Xajruntimetarget
@Parameter(defaultValue="1.5") protected java.lang.String Xajruntimetarget
(Experimental) Allows code to be generated that targets a 1.2 or a 1.5 level AspectJ runtime (default 1.5)
-
Xjoinpoints
@Parameter protected java.lang.String Xjoinpoints
supply a comma separated list of new joinpoints that can be identified by pointcuts. Values are: arrayconstruction, synchronization
-
bootclasspath
@Parameter protected java.lang.String 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
@Parameter protected java.lang.String 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:
- Eclipse AJC reference
-
argumentFileName
@Parameter(defaultValue="builddef.lst") protected java.lang.String 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 forceAjcCompile
Forces re-compilation, regardless of whether the compiler arguments or the sources have changed.
-
additionalCompilerArgs
@Parameter protected java.util.List<java.lang.String> 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
protected java.util.List<java.lang.String> ajcOptions
Holder for ajc compiler options
-
resolvedIncludes
protected java.util.Set<java.lang.String> resolvedIncludes
Holds all files found using the includes, excludes parameters.
-
-
Method Detail
-
getClasspathDirectories
protected abstract java.util.List<java.lang.String> getClasspathDirectories()
Abstract method used by child classes to specify the correct output directory for compiled classes.- Returns:
- the directories containing compiled classes.
-
getOutputDirectory
protected abstract java.io.File getOutputDirectory()
The directory where compiled classes go.- Returns:
- the outputDirectory
-
getGeneratedSourcesDirectory
protected abstract java.io.File getGeneratedSourcesDirectory()
The directory for sources generated by annotation processing.- Returns:
- the generatedSourcesDirectory
-
getSourceDirectories
protected abstract java.util.List<java.lang.String> 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
protected abstract java.lang.String 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.MojoExecutionException
Do the AspectJ compiling.- Throws:
org.apache.maven.plugin.MojoExecutionException
- if arguments file cannot be written
-
assembleArguments
protected void assembleArguments() throws org.apache.maven.plugin.MojoExecutionException
Assembles a complete ajc compiler arguments list.- Throws:
org.apache.maven.plugin.MojoExecutionException
- error in configuration
-
getIncludedSources
protected java.util.Set<java.lang.String> getIncludedSources() throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
isBuildNeeded
protected boolean isBuildNeeded() throws org.apache.maven.plugin.MojoExecutionException
Checks 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
public void setComplianceLevel(java.lang.String complianceLevel)
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
public void setEncoding(java.lang.String encoding)
-
setNoImportError
public void setNoImportError(boolean noImportError)
-
setOutxml
public void setOutxml(boolean outxml)
-
setOutxmlfile
public void setOutxmlfile(java.lang.String outxmlfile)
-
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
public void setTarget(java.lang.String target)
-
setSource
public void setSource(java.lang.String source)
-
setVerbose
public void setVerbose(boolean verbose)
-
setXhasMember
public void setXhasMember(boolean xhasMember)
-
setXlint
public void setXlint(java.lang.String xlint)
-
setXset
public void setXset(java.util.Map<java.lang.String,java.lang.String> xset)
-
setXlintfile
public void setXlintfile(java.io.File xlintfile)
-
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
public void setXajruntimetarget(java.lang.String xajruntimetarget)
-
setBootClassPath
public void setBootClassPath(java.lang.String bootclasspath)
-
setXjoinpoints
public void setXjoinpoints(java.lang.String xjoinpoints)
-
setWarn
public void setWarn(java.lang.String warn)
-
setArgumentFileName
public void setArgumentFileName(java.lang.String argumentFileName)
-
-