Package org.codehaus.mojo.aspectj
Class AjcHelper
java.lang.Object
org.codehaus.mojo.aspectj.AjcHelper
A helper class for creating classpaths for the compilers and report mojos
- Author:
- Kaare Nilsen
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
createClassPath
(org.apache.maven.project.MavenProject project, List<org.apache.maven.artifact.Artifact> pluginArtifacts, List<String> outDirs) Constructs AspectJ compiler classpath stringprotected static String
Convert a string array to a comma separated listgetBuildFilesForAjdtFile
(String ajdtBuildDefFile, File basedir) 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.getBuildFilesForSourceDirs
(List<String> sourceDirs, String[] includes, String[] excludes) Based on a set of sourcedirs, apply include and exclude statements and returns a set of all the files to be compiled and woven.getWeaveSourceFiles
(String[] weaveDirs) Based on a set of weave directories returns a set of all the files to be woven.static boolean
isValidComplianceLevel
(String complianceLevel) Checks if the given complianceLevel value is valid.readBuildConfigFile
(String fileName, File outputDir) Reads a build config file, and returns the List of all compiler arguments.resolveIncludeExcludeString
(String inExcludeString, File basedir) Helper method to find all .java or .aj files specified by the inExcludeString.static void
writeBuildConfigToFile
(List<String> arguments, String fileName, File outputDir) Creates a file that can be used as input to the ajc compiler using the -argdfile flag.
-
Field Details
-
DEFAULT_INCLUDES
- See Also:
-
DEFAULT_EXCLUDES
- See Also:
-
ACCEPTED_COMPLIANCE_LEVEL_VALUES
List holding all accepted values for thecomplianceLevel
parameter.
-
-
Constructor Details
-
AjcHelper
public AjcHelper()
-
-
Method Details
-
isValidComplianceLevel
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 theACCEPTED_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 ProjectpluginArtifacts
- the plugin ArtifactsoutDirs
- 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 ajdtBuildDefFilebasedir
- 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 directoriesincludes
- file include patternsexcludes
- 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 runfileName
- the filename of the argfileoutputDir
- the build output area.- Throws:
IOException
- if argfile cannot be created or written
-
readBuildConfigFile
Reads a build config file, and returns the List of all compiler arguments.- Parameters:
fileName
- the filename of the argfileoutputDir
- the build output area- Returns:
- the List of all compiler arguments.
- Throws:
IOException
- if any file operation fails
-
getAsCsv
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 listingssrc/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 stringbasedir
- 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
-