Class AjcHelper

java.lang.Object
org.codehaus.mojo.aspectj.AjcHelper

public class AjcHelper extends Object
A helper class for creating classpaths for the compilers and report mojos
Author:
Kaare Nilsen
  • Field Details

    • DEFAULT_INCLUDES

      public static final String DEFAULT_INCLUDES
      See Also:
    • DEFAULT_EXCLUDES

      public static final String DEFAULT_EXCLUDES
      See Also:
    • ACCEPTED_COMPLIANCE_LEVEL_VALUES

      public static final List<String> ACCEPTED_COMPLIANCE_LEVEL_VALUES
      List holding all accepted values for the complianceLevel parameter.
  • Constructor Details

    • AjcHelper

      public AjcHelper()
  • Method Details

    • isValidComplianceLevel

      public static boolean isValidComplianceLevel(String complianceLevel)
      Checks if the given complianceLevel value is valid.
      Parameters:
      complianceLevel - A complianceLevel
      Returns:
      true if the supplied complianceLevel is valid, implying that it is defined within the ACCEPTED_COMPLIANCE_LEVEL_VALUES List.
      See Also:
    • createClassPath

      public static String createClassPath(org.apache.maven.project.MavenProject project, List<org.apache.maven.artifact.Artifact> pluginArtifacts, List<String> outDirs)
      Constructs AspectJ compiler classpath string
      Parameters:
      project - the Maven Project
      pluginArtifacts - the plugin Artifacts
      outDirs - the outputDirectories
      Returns:
      a os spesific classpath string
    • getBuildFilesForAjdtFile

      public static Set<String> getBuildFilesForAjdtFile(String ajdtBuildDefFile, File basedir) throws org.apache.maven.plugin.MojoExecutionException
      Based on a AJDT build properties file resolves the combination of all include and exclude statements and returns a set of all the files to be compiled and woven.
      Parameters:
      ajdtBuildDefFile - the ajdtBuildDefFile
      basedir - the baseDirectory
      Returns:
      Set of Build Files
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if build properties are not found or cannot be read
    • getBuildFilesForSourceDirs

      public static Set<String> getBuildFilesForSourceDirs(List<String> sourceDirs, String[] includes, String[] excludes) throws org.apache.maven.plugin.MojoExecutionException
      Based on a set of sourcedirs, apply include and exclude statements and returns a set of all the files to be compiled and woven.
      Parameters:
      sourceDirs - source directories
      includes - file include patterns
      excludes - file exclude patterns
      Returns:
      Set of Build Files for Source Dirs
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if sourceDirs cannot be resolved
    • getWeaveSourceFiles

      public static Set<String> getWeaveSourceFiles(String[] weaveDirs) throws org.apache.maven.plugin.MojoExecutionException
      Based on a set of weave directories returns a set of all the files to be woven.
      Parameters:
      weaveDirs - weave directories
      Returns:
      a set of all the files to be woven
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if weave directories cannot be resolved
    • writeBuildConfigToFile

      public static void writeBuildConfigToFile(List<String> arguments, String fileName, File outputDir) throws IOException
      Creates a file that can be used as input to the ajc compiler using the -argdfile flag. Each line in these files should contain one option or filename. Comments, as in Java, start with // and extend to the end of the line.
      Parameters:
      arguments - All arguments passed to ajc in this run
      fileName - the filename of the argfile
      outputDir - the build output area.
      Throws:
      IOException - if argfile cannot be created or written
    • readBuildConfigFile

      public static List<String> readBuildConfigFile(String fileName, File outputDir) throws IOException
      Reads a build config file, and returns the List of all compiler arguments.
      Parameters:
      fileName - the filename of the argfile
      outputDir - the build output area
      Returns:
      the List of all compiler arguments.
      Throws:
      IOException - if any file operation fails
    • getAsCsv

      protected static String getAsCsv(String[] strings)
      Convert a string array to a comma separated list
      Parameters:
      strings - string array to be converted
      Returns:
      A comma separated list of Strings
    • resolveIncludeExcludeString

      protected static Set<String> resolveIncludeExcludeString(String inExcludeString, File basedir) throws org.apache.maven.plugin.MojoExecutionException
      Helper method to find all .java or .aj files specified by the inExcludeString. The includeString is a comma separated list over files, or directories relative to the specified basedir. Examples of correct listings
               src/main/java/
               src/main/java
               src/main/java/com/project/AClass.java
               src/main/java/com/project/AnAspect.aj
               src/main/java/com/project/AnAspect.java
       
      Parameters:
      inExcludeString - in-/exclude string
      basedir - the baseDirectory
      Returns:
      a list over all files in the include string
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if Java or AspectJ source files cannot be resolved