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.AbstractMojoThis is abstract class used to decrease the code needed to the creation of the compiler MOJO.- Version:
- $Id$
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static interfaceAbstractIDLJMojo.DependenciesFacade(package private) static classAbstractIDLJMojo.DependenciesFacadeImpl
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringcompilerThe compiler to use.private booleandebugActivate more detailed debug messages.private AbstractIDLJMojo.DependenciesFacadedependenciesThe interface between this class and the rest of the world - unit tests replace the default implementation.private static AbstractIDLJMojo.DependenciesFacadeDEPENDENCIES_FACADEThe default implementation of the dependencies.private booleanfailOnErrorShould the plugin fail the build if there's an error while generating sources from IDLs.private org.apache.maven.project.MavenProjectprojectprivate org.apache.maven.project.MavenProjectHelperprojectHelperThe maven project helper class for adding resources.private java.util.List<Source>sourcesAListofSourceconfigurations to compile.private intstaleMillisThe granularity in milliseconds of the last modification date for testing whether a source needs recompilation.private java.io.FiletimestampDirectoryThe directory to store the processed grammars.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractIDLJMojo()Creates the abstract class using a production implementation of the dependencies.(package private)AbstractIDLJMojo(AbstractIDLJMojo.DependenciesFacade dependencies)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidaddCompileSourceRoot(java.io.File directory)Add generated sources in compile source rootprivate java.util.Set<java.io.File>computeStaleGrammars(Source source)Determine which idl files need to be compiled.private voidcopyToTimestampDirectory(java.io.File idlFile)private org.codehaus.plexus.compiler.util.scan.SourceInclusionScannercreateIdlScanner(Source source)private voidcreateIfAbsent(java.io.File directory)private CompilerTranslatorcreateTranslator()voidexecute()Execute the goal of the MOJO that is: compiling the IDL filesprivate voidfailIfNotWriteable(java.io.File directory)protected abstract java.io.File[]getIncludeDirs()private java.util.Set<java.lang.String>getNonNullSet(java.lang.String comment, java.util.Set<java.lang.String> set, java.lang.String... defaultValues)protected abstract java.io.FilegetOutputDirectory()protected org.apache.maven.project.MavenProjectgetProject()protected org.apache.maven.project.MavenProjectHelpergetProjectHelper()protected abstract java.io.FilegetSourceDirectory()private java.util.Set<java.io.File>getStaleSources(org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner scanner, java.io.File sourceDir)private booleanisExistingDirectory(java.io.File sourceDir)private booleanisSourceSpecified()private voidprepareGeneratedSourceDirectory(java.io.File directory)private voidprocessIdlFile(Source source, CompilerTranslator translator, java.io.File idlFile)private voidprocessSource(Source source, CompilerTranslator translator)Compile the IDL files located in the given source path.private voidreportProcessingNeeded(java.util.Set<java.io.File> staleGrammars)private voidtranslateIdlFile(java.io.File idlFile, Source source, CompilerTranslator translator)private voidtranslateInferredSource(CompilerTranslator translator)private voidtranslateSources(CompilerTranslator translator, java.util.List<Source> sourceList)private java.util.Set<java.io.File>tryToGetStaleSources(org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner scanner, java.io.File sourceDir)
-
-
-
Field Detail
-
sources
@Parameter private java.util.List<Source> sources
AListofSourceconfigurations to compile.
-
debug
@Parameter private boolean debug
Activate more detailed debug messages.
-
failOnError
@Parameter(defaultValue="true") private boolean failOnError
Should 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 projectHelper
The maven project helper class for adding resources.
-
timestampDirectory
@Parameter(defaultValue="${project.build.directory}/idlj-timestamp") private java.io.File timestampDirectoryThe directory to store the processed grammars. Used so that grammars are not constantly regenerated.
-
compiler
@Parameter private java.lang.String 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
private AbstractIDLJMojo.DependenciesFacade dependencies
The interface between this class and the rest of the world - unit tests replace the default implementation.
-
DEPENDENCIES_FACADE
private static final AbstractIDLJMojo.DependenciesFacade DEPENDENCIES_FACADE
The default implementation of the dependencies.
-
-
Constructor Detail
-
AbstractIDLJMojo
protected AbstractIDLJMojo()
Creates the abstract class using a production implementation of the dependencies.
-
AbstractIDLJMojo
AbstractIDLJMojo(AbstractIDLJMojo.DependenciesFacade dependencies)
-
-
Method Detail
-
getSourceDirectory
protected abstract java.io.File getSourceDirectory()
- Returns:
- the source directory that contains the IDL files
-
getIncludeDirs
protected abstract java.io.File[] getIncludeDirs()
- Returns:
- the
File[]of the directories to use as include directories for the compilation
-
getOutputDirectory
protected abstract java.io.File 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(java.io.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, java.util.List<Source> sourceList) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
createTranslator
private CompilerTranslator createTranslator() throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
failIfNotWriteable
private void failIfNotWriteable(java.io.File directory) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
createIfAbsent
private void createIfAbsent(java.io.File directory)
-
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- theSourcethat specify which file compile with arguments to use for the sourcetranslator- theCompilerTranslatorthat 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, java.io.File idlFile) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
translateIdlFile
private void translateIdlFile(java.io.File idlFile, Source source, CompilerTranslator translator) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
copyToTimestampDirectory
private void copyToTimestampDirectory(java.io.File idlFile) throws org.apache.maven.plugin.MojoExecutionException, java.io.IOException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionjava.io.IOException
-
reportProcessingNeeded
private void reportProcessingNeeded(java.util.Set<java.io.File> staleGrammars) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
computeStaleGrammars
private java.util.Set<java.io.File> computeStaleGrammars(Source source) throws org.apache.maven.plugin.MojoExecutionException
Determine which idl files need to be compiled.- Parameters:
source- theSourcethat 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 java.util.Set<java.io.File> getStaleSources(org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner scanner, java.io.File sourceDir) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
tryToGetStaleSources
private java.util.Set<java.io.File> tryToGetStaleSources(org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner scanner, java.io.File sourceDir) throws org.codehaus.plexus.compiler.util.scan.InclusionScanException- Throws:
org.codehaus.plexus.compiler.util.scan.InclusionScanException
-
isExistingDirectory
private boolean isExistingDirectory(java.io.File sourceDir)
-
createIdlScanner
private org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner createIdlScanner(Source source)
-
getNonNullSet
private java.util.Set<java.lang.String> getNonNullSet(java.lang.String comment, java.util.Set<java.lang.String> set, java.lang.String... defaultValues)
-
addCompileSourceRoot
protected abstract void addCompileSourceRoot(java.io.File directory)
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
MavenProjectinstance
-
getProjectHelper
protected org.apache.maven.project.MavenProjectHelper getProjectHelper()
- Returns:
- the current
MavenProjectHelperinstance
-
-