org.codehaus.mojo.aspectj
Class AbstractAjcCompiler

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.codehaus.mojo.aspectj.AbstractAjcMojo
          extended by org.codehaus.mojo.aspectj.AbstractAjcCompiler
All Implemented Interfaces:
ContextEnabled, Mojo
Direct Known Subclasses:
AjcCompileMojo, AjcTestCompileMojo

public abstract class AbstractAjcCompiler
extends AbstractAjcMojo

Base class for the two aspectJ compiletime weaving mojos. For all available options see http://www.eclipse.org/aspectj/doc/released/devguide/ajc-ref.html

Author:
Kaare Nilsen

Field Summary
protected  List ajcOptions
          Holder for ajc compiler options
protected  String ajdtBuildDefFile
          Where to find the ajdt build definition file.
protected  String argumentFileName
          The filename to store build configuration in.
protected  String aspectDirectory
          The source directory for the aspects.
protected  String bootclasspath
          Override location of VM's bootclasspath for purposes of evaluating types when compiling.
protected  String complianceLevel
          Specify compiler compliance setting (1.3 to 1.6) default is 1.4
protected  boolean deprecation
          Toggle warningmessages on deprecations
protected  boolean emacssym
          Generate .ajesym symbol files for emacs support.
protected  String encoding
          Specify default source encoding format.
protected  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  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  String outxmlfile
          Generate aop.xml file for load-time weaving with custom name.
protected  boolean preserveAllLocals
          Preserve all local variables during code generation (to facilitate debugging).
protected  boolean proceedOnError
          Keep compiling after error, dumping class files with problem methods
protected  boolean referenceInfo
          Compute reference information.
protected  int repeat
          Repeat compilation process N times (typically to do performance analysis).
protected  Set resolvedIncludes
          Holds all files found using the includes, excludes parameters.
protected  boolean showWeaveInfo
          Emit messages about weaving
protected  String source
          Toggle assertions (1.3, 1.4, or 1.6 - default is 1.4).
protected  String target
          Specify classfile target setting (1.1 to 1.6) default is 1.2
protected  String testAspectDirectory
          The source directory for the test aspects.
protected  boolean verbose
          Emit messages about accessed/processed compilation units
protected  String warn
          Emit warnings for any instances of the comma-delimited list of questionable code (e.g.
protected  boolean XaddSerialVersionUID
          Causes the compiler to calculate and add the SerialVersionUID field to any type implementing Serializable that is affected by an aspect.
protected  boolean XhasMember
          Enables the compiler to support hasmethod(method_pattern) and hasfield(field_pattern) type patterns, but only within declare statements.
protected  String Xlint
          Set default level for messages about potential programming mistakes in crosscutting code.
protected  boolean XnoInline
          (Experimental) do not inline around advice
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 aspects Serializable.
protected  boolean XterminateAfterCompilation
          Causes compiler to terminate before weaving
 
Fields inherited from class org.codehaus.mojo.aspectj.AbstractAjcMojo
aspectLibraries, basedir, project, weaveDependencies, weaveDirectories
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractAjcCompiler()
           
 
Method Summary
protected  void assembleArguments()
          Assembles a complete ajc compiler arguments list.
 void execute()
          Do the AspectJ compiling.
protected abstract  String getAdditionalAspectPaths()
          Abstract method used by child classes to specify additional aspect paths.
protected abstract  List getClasspathDirectories()
          Abstract method used by child classes to specify the correct output directory for compiled classes.
protected  Set getIncludedSources()
           
protected abstract  org.codehaus.plexus.util.Scanner[] getJavaSources()
           
protected abstract  File getOutputDirectory()
          The directory where compiled classes go.
protected abstract  List 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 build
 void setArgumentFileName(String argumentFileName)
           
 void setBootClassPath(String bootclasspath)
           
 void setComplianceLevel(String complianceLevel)
          Setters which when called sets compiler arguments
 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 setPreserveAllLocals(boolean preserveAllLocals)
           
 void setProceedOnError(boolean proceedOnError)
           
 void setReferenceInfo(boolean referenceInfo)
           
 void setRepeat(int repeat)
           
 void setShowWeaveInfo(boolean showWeaveInfo)
           
 void setSource(String source)
           
 void setTarget(String target)
           
 void setVerbose(boolean verbose)
           
 void setWarn(String warn)
           
 void setXaddSerialVersionUID(boolean xaddSerialVersionUID)
           
 void setXhasMember(boolean xhasMember)
           
 void setXlint(String xlint)
           
 void setXnoInline(boolean xnoInline)
           
 void setXreweavable(boolean xreweavable)
           
 void setXserializableAspects(boolean xserializableAspects)
           
 void setXterminateAfterCompilation(boolean xterminateAfterCompilation)
           
 
Methods inherited from class org.codehaus.mojo.aspectj.AbstractAjcMojo
isSkip
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

aspectDirectory

protected String aspectDirectory
The source directory for the aspects.

Is defined by:
default-value:
src/main/aspect

testAspectDirectory

protected String testAspectDirectory
The source directory for the test aspects.

Is defined by:
default-value:
src/test/aspect

includes

protected 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.

Is defined by:

excludes

protected 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.

Is defined by:

ajdtBuildDefFile

protected String ajdtBuildDefFile
Where to find the ajdt build definition file. If set this will override the use of project sourcedirs.

Is defined by:

outxml

protected boolean outxml
Generate aop.xml file for load-time weaving with default name (/META-INF/aop.xml).

Is defined by:

outxmlfile

protected String outxmlfile
Generate aop.xml file for load-time weaving with custom name.

Is defined by:

emacssym

protected boolean emacssym
Generate .ajesym symbol files for emacs support.

Is defined by:

Xlint

protected 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.

Is defined by:

XhasMember

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
Is defined by:

target

protected String target
Specify classfile target setting (1.1 to 1.6) default is 1.2

Is defined by:
default-value:
${project.build.java.target}

source

protected String source
Toggle assertions (1.3, 1.4, or 1.6 - default is 1.4). When using -source 1.3, an assert() statement valid under Java 1.4 will result in a compiler error. When using -source 1.4, treat assert as a keyword and implement assertions according to the 1.4 language spec. When using -source 1.5 or higher, Java 5 language features are permitted.

Is defined by:
default-value:
${mojo.java.target}

complianceLevel

protected String complianceLevel
Specify compiler compliance setting (1.3 to 1.6) default is 1.4

Is defined by:

deprecation

protected boolean deprecation
Toggle warningmessages on deprecations

Is defined by:

noImportError

protected boolean noImportError
Emit no errors for unresolved imports;

Is defined by:

proceedOnError

protected boolean proceedOnError
Keep compiling after error, dumping class files with problem methods

Is defined by:

preserveAllLocals

protected boolean preserveAllLocals
Preserve all local variables during code generation (to facilitate debugging).

Is defined by:

referenceInfo

protected boolean referenceInfo
Compute reference information.

Is defined by:

encoding

protected String encoding
Specify default source encoding format.

Is defined by:
expression:
${project.build.sourceEncoding}

verbose

protected boolean verbose
Emit messages about accessed/processed compilation units

Is defined by:

showWeaveInfo

protected boolean showWeaveInfo
Emit messages about weaving

Is defined by:

repeat

protected int repeat
Repeat compilation process N times (typically to do performance analysis).

Is defined by:

Xreweavable

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.

Is defined by:

XnoInline

protected boolean XnoInline
(Experimental) do not inline around advice

Is defined by:

XserializableAspects

protected boolean XserializableAspects
(Experimental) Normally it is an error to declare aspects Serializable. This option removes that restriction.

Is defined by:

XaddSerialVersionUID

protected boolean XaddSerialVersionUID
Causes the compiler to calculate and add the SerialVersionUID field to any type implementing Serializable that is affected by an aspect. The field is calculated based on the class before weaving has taken place.

Is defined by:

XterminateAfterCompilation

protected boolean XterminateAfterCompilation
Causes compiler to terminate before weaving

Is defined by:

bootclasspath

protected 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.

Is defined by:

warn

protected String warn
Emit warnings for any instances of the comma-delimited list of questionable code (e.g. 'unusedLocals,deprecation'): see http://www.eclipse.org/aspectj/doc/released/devguide/ajc-ref.html#ajc for available settings

Is defined by:

argumentFileName

protected String argumentFileName
The filename to store build configuration in. This file will be placed in the project build output directory, and will contain all the arguments passed to the compiler in the last run, and also all the filenames included in the build. Aspects as well as java files.

Is defined by:
default-value:
builddef.lst

forceAjcCompile

protected boolean forceAjcCompile
Forces re-compilation, regardless of whether the compiler arguments or the sources have changed.

Is defined by:

ajcOptions

protected List ajcOptions
Holder for ajc compiler options


resolvedIncludes

protected Set resolvedIncludes
Holds all files found using the includes, excludes parameters.

Constructor Detail

AbstractAjcCompiler

public AbstractAjcCompiler()
Method Detail

getClasspathDirectories

protected abstract List 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 File getOutputDirectory()
The directory where compiled classes go.

Returns:
the outputDirectory

getSourceDirectories

protected abstract List 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 String getAdditionalAspectPaths()
Abstract method used by child classes to specify additional aspect paths.

Returns:
the additional aspect paths

execute

public void execute()
             throws MojoExecutionException
Do the AspectJ compiling.

Throws:
MojoExecutionException

assembleArguments

protected void assembleArguments()
                          throws MojoExecutionException
Assembles a complete ajc compiler arguments list.

Throws:
MojoExecutionException - error in configuration

getIncludedSources

protected Set getIncludedSources()
                          throws MojoExecutionException
Throws:
MojoExecutionException

isBuildNeeded

protected boolean isBuildNeeded()
                         throws MojoExecutionException
Checks modifications that would make us need a build

Returns:
true if build is needed, otherwise false
Throws:
MojoExecutionException

setComplianceLevel

public void setComplianceLevel(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)

setEncoding

public void setEncoding(String encoding)

setNoImportError

public void setNoImportError(boolean noImportError)

setOutxml

public void setOutxml(boolean outxml)

setOutxmlfile

public void setOutxmlfile(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(String target)

setSource

public void setSource(String source)

setVerbose

public void setVerbose(boolean verbose)

setXhasMember

public void setXhasMember(boolean xhasMember)

setXlint

public void setXlint(String xlint)

setXnoInline

public void setXnoInline(boolean xnoInline)

setXreweavable

public void setXreweavable(boolean xreweavable)

setXserializableAspects

public void setXserializableAspects(boolean xserializableAspects)

setXaddSerialVersionUID

public void setXaddSerialVersionUID(boolean xaddSerialVersionUID)

setXterminateAfterCompilation

public void setXterminateAfterCompilation(boolean xterminateAfterCompilation)

setBootClassPath

public void setBootClassPath(String bootclasspath)

setWarn

public void setWarn(String warn)

setArgumentFileName

public void setArgumentFileName(String argumentFileName)


Copyright © 2005-2012 Codehaus. All Rights Reserved.