Package org.codehaus.mojo.idlj
Class AbstractIDLJMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.codehaus.mojo.idlj.AbstractIDLJMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
IDLJMojo
,TestIDLJMojo
public abstract class AbstractIDLJMojo
extends org.apache.maven.plugin.AbstractMojo
This is abstract class used to decrease the code needed to the creation of the compiler MOJO.
- Version:
- $Id$
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interface
(package private) static class
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
The compiler to use.private boolean
Activate more detailed debug messages.The interface between this class and the rest of the world - unit tests replace the default implementation.private static final AbstractIDLJMojo.DependenciesFacade
The default implementation of the dependencies.private boolean
Should the plugin fail the build if there's an error while generating sources from IDLs.private org.apache.maven.project.MavenProject
private org.apache.maven.project.MavenProjectHelper
The maven project helper class for adding resources.AList
ofSource
configurations to compile.private int
The granularity in milliseconds of the last modification date for testing whether a source needs recompilation.private File
The directory to store the processed grammars.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Creates the abstract class using a production implementation of the dependencies.(package private)
AbstractIDLJMojo
(AbstractIDLJMojo.DependenciesFacade dependencies) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
addCompileSourceRoot
(File directory) Add generated sources in compile source rootcomputeStaleGrammars
(Source source) Determine which idl files need to be compiled.private void
copyToTimestampDirectory
(File idlFile) private org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner
createIdlScanner
(Source source) private void
createIfAbsent
(File directory) private CompilerTranslator
void
execute()
Execute the goal of the MOJO that is: compiling the IDL filesprivate void
failIfNotWriteable
(File directory) protected abstract File[]
getNonNullSet
(String comment, Set<String> set, String... defaultValues) protected abstract File
protected org.apache.maven.project.MavenProject
protected org.apache.maven.project.MavenProjectHelper
protected abstract File
getStaleSources
(org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner scanner, File sourceDir) private boolean
isExistingDirectory
(File sourceDir) private boolean
private void
prepareGeneratedSourceDirectory
(File directory) private void
processIdlFile
(Source source, CompilerTranslator translator, File idlFile) private void
processSource
(Source source, CompilerTranslator translator) Compile the IDL files located in the given source path.private void
reportProcessingNeeded
(Set<File> staleGrammars) private void
translateIdlFile
(File idlFile, Source source, CompilerTranslator translator) private void
translateInferredSource
(CompilerTranslator translator) private void
translateSources
(CompilerTranslator translator, List<Source> sourceList) tryToGetStaleSources
(org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner scanner, File sourceDir) Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
sources
AList
ofSource
configurations to compile. -
debug
@Parameter private boolean debugActivate more detailed debug messages. -
failOnError
@Parameter(defaultValue="true") private boolean failOnErrorShould the plugin fail the build if there's an error while generating sources from IDLs. -
project
@Parameter(property="project", required=true, readonly=true) private org.apache.maven.project.MavenProject project -
staleMillis
@Parameter(property="lastModGranularityMs", defaultValue="0") private int staleMillisThe granularity in milliseconds of the last modification date for testing whether a source needs recompilation. -
projectHelper
@Component(role=org.apache.maven.project.MavenProjectHelper.class) private org.apache.maven.project.MavenProjectHelper projectHelperThe maven project helper class for adding resources. -
timestampDirectory
@Parameter(defaultValue="${project.build.directory}/idlj-timestamp") private File timestampDirectoryThe directory to store the processed grammars. Used so that grammars are not constantly regenerated. -
compiler
The compiler to use. Current options are the JDK idlj compiler, Glassfish and JacORB. Should be either "idlj", "glassfish", or "jacorb". If not specified, will select idlj or glassfish, based on Java version -
dependencies
The interface between this class and the rest of the world - unit tests replace the default implementation. -
DEPENDENCIES_FACADE
The default implementation of the dependencies.
-
-
Constructor Details
-
AbstractIDLJMojo
protected AbstractIDLJMojo()Creates the abstract class using a production implementation of the dependencies. -
AbstractIDLJMojo
AbstractIDLJMojo(AbstractIDLJMojo.DependenciesFacade dependencies)
-
-
Method Details
-
getSourceDirectory
- Returns:
- the source directory that contains the IDL files
-
getIncludeDirs
- Returns:
- the
File[]
of the directories to use as include directories for the compilation
-
getOutputDirectory
- Returns:
- the path of the directory that will contains the results of the compilation
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionExceptionExecute the goal of the MOJO that is: compiling the IDL files- Throws:
org.apache.maven.plugin.MojoExecutionException
- if the compilation fails or the compiler crashes
-
prepareGeneratedSourceDirectory
private void prepareGeneratedSourceDirectory(File directory) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
isSourceSpecified
private boolean isSourceSpecified() -
translateInferredSource
private void translateInferredSource(CompilerTranslator translator) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
translateSources
private void translateSources(CompilerTranslator translator, List<Source> sourceList) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
createTranslator
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
failIfNotWriteable
private void failIfNotWriteable(File directory) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
createIfAbsent
-
processSource
private void processSource(Source source, CompilerTranslator translator) throws org.apache.maven.plugin.MojoExecutionException Compile the IDL files located in the given source path.- Parameters:
source
- theSource
that specify which file compile with arguments to use for the sourcetranslator
- theCompilerTranslator
that raprresents idl compiler backend that will be used- Throws:
org.apache.maven.plugin.MojoExecutionException
- if the compilation fails or the compiler crashes
-
processIdlFile
private void processIdlFile(Source source, CompilerTranslator translator, File idlFile) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
translateIdlFile
private void translateIdlFile(File idlFile, Source source, CompilerTranslator translator) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
copyToTimestampDirectory
private void copyToTimestampDirectory(File idlFile) throws org.apache.maven.plugin.MojoExecutionException, IOException - Throws:
org.apache.maven.plugin.MojoExecutionException
IOException
-
reportProcessingNeeded
private void reportProcessingNeeded(Set<File> staleGrammars) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
computeStaleGrammars
private Set<File> computeStaleGrammars(Source source) throws org.apache.maven.plugin.MojoExecutionException Determine which idl files need to be compiled.- Parameters:
source
- theSource
that represents which files to compile- Returns:
- a set of files that need to be compiled
- Throws:
org.apache.maven.plugin.MojoExecutionException
- if the selection of the files to compile fails
-
getStaleSources
private Set<File> getStaleSources(org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner scanner, File sourceDir) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
tryToGetStaleSources
private Set<File> tryToGetStaleSources(org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner scanner, File sourceDir) throws org.codehaus.plexus.compiler.util.scan.InclusionScanException - Throws:
org.codehaus.plexus.compiler.util.scan.InclusionScanException
-
isExistingDirectory
-
createIdlScanner
private org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner createIdlScanner(Source source) -
getNonNullSet
-
addCompileSourceRoot
Add generated sources in compile source root- Parameters:
directory
- a directory containing generated java files to be compiled.
-
getProject
protected org.apache.maven.project.MavenProject getProject()- Returns:
- the current
MavenProject
instance
-
getProjectHelper
protected org.apache.maven.project.MavenProjectHelper getProjectHelper()- Returns:
- the current
MavenProjectHelper
instance
-