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 Details

    • XAJRUNTIMETARGET_SUPPORTED_VALUES

      public static final List<String> XAJRUNTIMETARGET_SUPPORTED_VALUES
      List holding all accepted values for the Xajruntimetarget parameter.
    • aspectDirectory

      @Parameter(defaultValue="src/main/aspect") protected String aspectDirectory
      The source directory for the aspects.
    • testAspectDirectory

      @Parameter(defaultValue="src/test/aspect") protected String testAspectDirectory
      The source directory for the test aspects.
    • includes

      @Parameter 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.
    • excludes

      @Parameter 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.
    • ajdtBuildDefFile

      @Parameter protected 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 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 String proc
      Set the compiler "proc" argument. Aspectj supports Annotation processing since 1.8.2, it can been disabled by proc:none.
      See Also:
    • parameters

      @Parameter protected boolean parameters
      Set the compiler "parameters" argument.
    • Xset

      @Parameter protected Map<String,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 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 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 String target
      Specify bytecode target setting (1.3 to 1.9, 10 to 17). See 'complianceLevel' for details.
      See Also:
    • source

      @Parameter(defaultValue="${mojo.java.target}") protected String source
      Specify source code language level (1.3 to 1.9, 10 to 17). See 'complianceLevel' for details.
      See Also:
    • complianceLevel

      @Parameter(defaultValue="1.4") protected 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, 17, 17.0
      See Also:
    • 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 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 aspects Serializable. This option removes that restriction.
    • XaddSerialVersionUID

      @Parameter 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.
    • XterminateAfterCompilation

      @Parameter protected boolean XterminateAfterCompilation
      Causes compiler to terminate before weaving
    • Xajruntimetarget

      @Parameter(defaultValue="1.5") protected 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 String Xjoinpoints
      supply a comma separated list of new joinpoints that can be identified by pointcuts. Values are: arrayconstruction, synchronization
    • bootclasspath

      @Parameter 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.
    • warn

      @Parameter protected 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:
    • argumentFileName

      @Parameter(defaultValue="builddef.lst") protected 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 List<String> additionalCompilerArgs
      Sets additional compiler arguments, e.g.
      
       <compilerArgs>
         <arg>-Xmaxerrs=1000</arg>
         <arg>-Xlint</arg>
         <arg>-J-Duser.language=en_us</arg> 
       </compilerArgs>
       
      This option can be used in case you want to use AJC options not (yet) supported by this plugin.

      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 List<String> ajcOptions
      Holder for ajc compiler options
    • resolvedIncludes

      protected Set<String> resolvedIncludes
      Holds all files found using the includes, excludes parameters.
  • Constructor Details

    • AbstractAjcCompiler

      public AbstractAjcCompiler()
  • Method Details

    • getClasspathDirectories

      protected abstract List<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 File getOutputDirectory()
      The directory where compiled classes go.
      Returns:
      the outputDirectory
    • getGeneratedSourcesDirectory

      protected abstract File getGeneratedSourcesDirectory()
      The directory for sources generated by annotation processing.
      Returns:
      the generatedSourcesDirectory
    • getSourceDirectories

      protected abstract List<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 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 Set<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, otherwise false
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if an unexpected error occurs, e.g. weave directories cannot be resolved
    • 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)
    • setParameters

      public void setParameters(boolean parameters)
    • setCrossrefs

      public void setCrossrefs(boolean crossrefs)
    • 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)
    • setXset

      public void setXset(Map<String,String> xset)
    • setXlintfile

      public void setXlintfile(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(String xajruntimetarget)
    • setBootClassPath

      public void setBootClassPath(String bootclasspath)
    • setXjoinpoints

      public void setXjoinpoints(String xjoinpoints)
    • setWarn

      public void setWarn(String warn)
    • setArgumentFileName

      public void setArgumentFileName(String argumentFileName)