@Mojo(name="generate",
requiresProject=true,
requiresDirectInvocation=false,
requiresDependencyResolution=COMPILE)
public class GenerateMojo
extends org.nuiton.plugin.AbstractPlugin
implements ChainedFileWriterConfiguration, org.nuiton.plugin.PluginWithEncoding
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,Model> |
_models
All available models (obtain by plexus, keys are plexus roles,
values are a instance of corresponding model).
|
protected String |
defaultPackage
Nom par défaut du paquetage généré (model input specific).
|
protected boolean |
dryRun
Ne génère rien, analyse juste la configuration.
|
protected String |
encoding
Encoding to be used for generation of files.
|
protected ChainedWriterEngine |
engine
The engine to compute
ChainedFileWriter from inputs entries. |
protected String[] |
excludeTemplates
Templates à ne pas utiliser lors de la transformations des models
(model input sepcific).
|
protected File |
extractDirectory
Where to copy extracted files (when using class-path data).
|
protected String |
extractedPackages
List of package to extract from xmi to models.
|
protected ClassLoader |
fixedClassLoader
fixed classloader
|
protected String |
fullPackagePath
Nom du paquetage pour les fichiers générés (xmi input sepcific).
|
protected String |
generatedPackages
List of packages to generate (comma separated).
|
protected String[] |
inputs
Inputs files to used to generate the required model files.
|
protected ModelHelper |
modelHelper |
protected Map<String,ModelPropertiesUtil.ModelPropertiesProvider> |
modelPropertiesProviders
All available model properties providers introspects via plexus.
|
protected Map<String,ModelReader<?>> |
modelReaders
All available writers introspects via plexus.
|
protected Map<String,Template<?>> |
modelTemplates
All available templates introspects via plexus.
|
protected String |
modelType
The type of model to be used.
|
protected File |
outputDirectory
Where to generate files.
|
protected boolean |
overwrite
Ecrase les fichiers générés.
|
protected org.apache.maven.project.MavenProject |
project
Maven project.
|
protected Map<String,Object> |
properties
Properties to pass to writer.
|
protected String |
resolver
Nom du resolver a utiliser pour les transformations xmi vers model
(xmi input sepcific).
|
protected org.apache.maven.settings.Settings |
settings
Le settings (pour obtenir le mode offline).
|
protected String |
skipInputs
List of input (protocol) not to treate separated by comma.
|
protected List<Template<Model>> |
templateList |
protected String |
templates
Templates à utiliser, séparés par des virgules pour les transformations
depuis les models (model input sepcific).
|
protected boolean |
testPhase
A flag to mark the mojo to be used in a test phase.
|
protected boolean |
verbose
Pour activer le mode verbeux.
|
protected Map<String,ChainedFileWriter> |
writers
All available writers introspects via plexus.
|
| Constructor and Description |
|---|
GenerateMojo() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
applyTemplates(Model model,
Long lastModifiedSource,
File outputDirectory,
List<Template<Model>> templateList,
WriterReport writerReport) |
protected boolean |
checkSkip() |
protected void |
doAction() |
protected void |
fixCompileSourceRoots(File destDirGen)
permet d'ajout le répertoire de génération des fichiers java dans
les répertoires de compilation du projet Maven.
|
File |
getBasedir() |
ClassLoader |
getClassLoader() |
String |
getEncoding() |
protected String |
getExcludeTemplatesAsString() |
File |
getExtractDirectory() |
ClassLoader |
getFixedClassLoader()
Prepare le classLoader a utiliser dans le generateur.
|
ModelHelper |
getModelHelper() |
protected ModelPropertiesUtil.ModelPropertiesProvider |
getModelPropertiesProvider() |
Map<String,ModelReader<?>> |
getModelReaders() |
Map<String,Template<?>> |
getModelTemplates() |
String |
getModelType() |
File |
getOutputDirectory() |
org.apache.maven.project.MavenProject |
getProject() |
Map<String,Object> |
getProperties() |
Map<String,ChainedFileWriter> |
getWriters() |
protected void |
init() |
protected List<Template<Model>> |
initTemplates() |
boolean |
isOffline() |
boolean |
isOverwrite() |
boolean |
isTestPhase() |
boolean |
isVerbose() |
protected WriterReport |
newWriterReport() |
String |
reportGeneratedFiles(ChainedFileWriter writer,
long t0) |
void |
setEncoding(String encoding) |
void |
setInputs(String inputs)
Add a single input to the
inputs property. |
void |
setProject(org.apache.maven.project.MavenProject project) |
void |
setVerbose(boolean verbose) |
acceptPackaging, addCompileSourceRoots, addDirectoryToUrlsList, addResourceDir, addTestCompileSourceRoots, addTestResourceDir, addUrlToUrlsList, afterExecute, backupFile, checkEncoding, checkPackaging, checkResource, checkRunOnceDone, copyFile, createDirectoryIfNecessary, createNewFile, deleteFile, execute, getBackupFile, getFileFromBasedir, getFilesToTreate, getFilesToTreateForRoots, getRootProject, getTemplate, hasClassPath, initClassLoader, isExecutionRoot, isFileNewerThanPomFile, needInvoke, needInvoke, rejectPackaging, removeCompileSourceRoots, removeTestCompileSourceRoots, renameFile, writeFilegetLog, getPluginContext, setLog, setPluginContext@Parameter(property="eugene.inputs",
required=true)
protected String[] inputs
writer:when you want to use a specific writer with his default io values. Can also write :
[writer:]directory:includeswhere
includes is the pattern to find files from the directory
given and must be terminated by the extension of files.
Specifying the writer can be usefull when you want to use a
writer for an unknown extension by any writer.
Example :
<inputs>
<input>zargo:</input>
<input>src/main/xmi2:**\/*.zargo</input>
<input>zargo:src/main/xmi:**\/*.zargo2</input>
</inputs>
Note: If your using a single input, you can just write :
<inputs>zargo</inputs>
@Parameter(property="eugene.skipInputs") protected String skipInputs
<skipInputs>xmi</skipInputs> <skipInputs>xmi,model</skipInputs>
@Parameter(property="eugene.outputDirectory",
defaultValue="target/generated-sources",
required=true)
protected File outputDirectory
@Parameter(property="eugene.extractDirectory",
defaultValue="target/extracted-sources",
required=true)
protected File extractDirectory
@Parameter(property="eugene.overwrite",
defaultValue="false")
protected boolean overwrite
@Parameter(property="eugene.verbose",
defaultValue="${maven.verbose}")
protected boolean verbose
@Parameter(property="eugene.encoding",
defaultValue="${project.build.sourceEncoding}")
protected String encoding
file.encoding.@Parameter(property="eugene.testPhase",
defaultValue="false")
protected boolean testPhase
@Parameter(property="eugene.modelType",
defaultValue="objectmodel",
required=true)
protected String modelType
objectmodel.@Parameter protected Map<String,Object> properties
@Parameter(property="eugene.dryRun",
defaultValue="false")
protected boolean dryRun
@Parameter(property="generator.fullPackagePath",
defaultValue="${project.groupId}.${project.artifactId}")
protected String fullPackagePath
@Parameter(property="generator.resolver",
defaultValue="org.nuiton.util.ResourceResolver")
protected String resolver
@Parameter(property="eugene.templates") protected String templates
@Parameter(property="eugene.excludeTemplates") protected String[] excludeTemplates
@Parameter(property="eugene.defaultPackage",
defaultValue="${project.groupId}.${project.artifactId}")
protected String defaultPackage
@Parameter(property="eugene.generatedPackages") protected String generatedPackages
@Parameter(property="eugene.extractedPackages",
defaultValue="${project.groupId}.${project.artifactId}")
protected String extractedPackages
@Component protected org.apache.maven.project.MavenProject project
@Component protected org.apache.maven.settings.Settings settings
@Component(role=org.nuiton.eugene.models.Model.class) protected Map<String,Model> _models
@Component(role=org.nuiton.eugene.writer.ChainedFileWriter.class) protected Map<String,ChainedFileWriter> writers
@Component(role=org.nuiton.eugene.ModelReader.class) protected Map<String,ModelReader<?>> modelReaders
@Component(role=org.nuiton.eugene.Template.class) protected Map<String,Template<?>> modelTemplates
@Component(role=org.nuiton.eugene.ModelPropertiesUtil.ModelPropertiesProvider.class) protected Map<String,ModelPropertiesUtil.ModelPropertiesProvider> modelPropertiesProviders
@Component(role=org.nuiton.eugene.writer.ChainedWriterEngine.class) protected ChainedWriterEngine engine
ChainedFileWriter from inputs entries.protected ModelHelper modelHelper
protected ClassLoader fixedClassLoader
protected WriterReport newWriterReport()
protected void init()
throws Exception
init in class org.nuiton.plugin.AbstractPluginExceptionprotected boolean checkSkip()
checkSkip in class org.nuiton.plugin.AbstractPluginprotected void doAction()
throws Exception
doAction in class org.nuiton.plugin.AbstractPluginExceptionprotected void applyTemplates(Model model, Long lastModifiedSource, File outputDirectory, List<Template<Model>> templateList, WriterReport writerReport) throws IOException
IOExceptionpublic String reportGeneratedFiles(ChainedFileWriter writer, long t0)
public void setInputs(String inputs)
inputs property.
Note: This is a convinient way to allow in pom to write
<inputs>zargo</inputs>in stead of array notation :
<inputs>
<input>zargo:</input>
</inputs>
inputs - unique input to addpublic File getOutputDirectory()
getOutputDirectory in interface ChainedFileWriterConfigurationpublic File getExtractDirectory()
getExtractDirectory in interface ChainedFileWriterConfigurationpublic Map<String,Object> getProperties()
getProperties in interface ChainedFileWriterConfigurationpublic ClassLoader getClassLoader()
getClassLoader in interface ChainedFileWriterConfigurationpublic org.apache.maven.project.MavenProject getProject()
getProject in interface org.nuiton.plugin.Pluginpublic void setProject(org.apache.maven.project.MavenProject project)
setProject in interface org.nuiton.plugin.Pluginpublic boolean isVerbose()
isVerbose in interface ChainedFileWriterConfigurationisVerbose in interface org.nuiton.plugin.Pluginpublic void setVerbose(boolean verbose)
setVerbose in interface org.nuiton.plugin.Pluginpublic String getEncoding()
getEncoding in interface ChainedFileWriterConfigurationgetEncoding in interface org.nuiton.plugin.PluginWithEncodingpublic void setEncoding(String encoding)
setEncoding in interface org.nuiton.plugin.PluginWithEncodingpublic boolean isOverwrite()
isOverwrite in interface ChainedFileWriterConfigurationpublic boolean isOffline()
isOffline in interface ChainedFileWriterConfigurationpublic boolean isTestPhase()
isTestPhase in interface ChainedFileWriterConfigurationpublic String getModelType()
getModelType in interface ChainedFileWriterConfigurationpublic Map<String,ChainedFileWriter> getWriters()
getWriters in interface ChainedFileWriterConfigurationpublic Map<String,ModelReader<?>> getModelReaders()
getModelReaders in interface ChainedFileWriterConfigurationpublic Map<String,Template<?>> getModelTemplates()
getModelTemplates in interface ChainedFileWriterConfigurationpublic ModelHelper getModelHelper()
getModelHelper in interface ChainedFileWriterConfigurationpublic File getBasedir()
getBasedir in interface ChainedFileWriterConfigurationprotected String getExcludeTemplatesAsString()
public ClassLoader getFixedClassLoader() throws org.apache.maven.plugin.MojoExecutionException
testPhase a été renseigné,
target/classes est rajouté.
Si des références à des sibling modules, ils seront rajoutés aussi.org.apache.maven.plugin.MojoExecutionException - if any pbprotected void fixCompileSourceRoots(File destDirGen)
destDirGen - le repertoire a traiterprotected ModelPropertiesUtil.ModelPropertiesProvider getModelPropertiesProvider() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionExceptionCopyright © 2006–2013 CodeLutin. All rights reserved.