org.nuiton.eugene.plugin
Class SmartGenerateMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.nuiton.plugin.AbstractPlugin
          extended by org.nuiton.eugene.plugin.SmartGenerateMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo, ChainedFileWriterConfiguration, org.nuiton.plugin.Plugin, org.nuiton.plugin.PluginWithEncoding

public class SmartGenerateMojo
extends org.nuiton.plugin.AbstractPlugin
implements ChainedFileWriterConfiguration, org.nuiton.plugin.PluginWithEncoding

Smart file generator.

Fill inputs and mojo will chained needed writer.

User: chemit Date: 24 nov. 2009 Time: 00:22:37

Is defined by the goal name:
smart-generate
Requires the dependencies in this specified scope:
compile
Requires a Maven project to run:
true

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.nuiton.plugin.Plugin
org.nuiton.plugin.Plugin.InitState, org.nuiton.plugin.Plugin.Packaging
 
Field Summary
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  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  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
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
SmartGenerateMojo()
           
 
Method Summary
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.
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()
           
 boolean isOffline()
           
 boolean isOverwrite()
           
 boolean isTestPhase()
           
 boolean isVerbose()
           
 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)
           
 
Methods inherited from class org.nuiton.plugin.AbstractPlugin
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, rejectPackaging, removeCompileSourceRoots, removeTestCompileSourceRoots, renameFile, writeFile
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.maven.plugin.Mojo
execute, getLog, setLog
 

Field Detail

inputs

protected String[] inputs
Inputs files to used to generate the required model files.

An include has the following pattern :
  writer:
 
when you want to use a specific writer with his default io values.

Can also write :

  [writer:]directory:includes
 
where 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>
 

Since:
2.0.0
Is defined by:
expression:
${eugene.inputs}
Is required.

skipInputs

protected String skipInputs
List of input (protocol) not to treate separated by comma.

Example :

 <skipInputs>xmi</skipInputs>
 <skipInputs>xmi,model</skipInputs>
 

Since:
2.0.0
Is defined by:
expression:
${eugene.skipInputs}

outputDirectory

protected File outputDirectory
Where to generate files.

Since:
2.0.0
Is defined by:
expression:
${eugene.outputDirectory}
default-value:
target/generated-sources
Is required.

extractDirectory

protected File extractDirectory
Where to copy extracted files (when using class-path data).

Since:
2.1.3
Is defined by:
expression:
${eugene.extractDirectory}
default-value:
target/extracted-sources
Is required.

overwrite

protected boolean overwrite
Ecrase les fichiers générés.

Since:
2.0.0
Is defined by:
expression:
${eugene.overwrite}
default-value:
false

verbose

protected boolean verbose
Pour activer le mode verbeux.

Since:
2.0.0
Is defined by:
expression:
${eugene.verbose}
default-value:
${maven.verbose}

encoding

protected String encoding
Encoding to be used for generation of files.

Note: If nothing is filled here, we will use the system property file.encoding.

Since:
2.0.0
Is defined by:
expression:
${eugene.encoding}
default-value:
${project.build.sourceEncoding}

testPhase

protected boolean testPhase
A flag to mark the mojo to be used in a test phase. This will permits to add generated sources in test compile roots.

Since:
2.0.0
Is defined by:
expression:
${eugene.testPhase}
default-value:
false

modelType

protected String modelType
The type of model to be used.

By default, use an objectmodel.

Since:
2.0.0
Is defined by:
expression:
${eugene.modelType}
default-value:
objectmodel
Is required.

properties

protected Map<String,Object> properties
Properties to pass to writer.

Since:
2.0.0
Is defined by:

dryRun

protected boolean dryRun
Ne génère rien, analyse juste la configuration.

Since:
2.0.0
Is defined by:
expression:
${eugene.dryRun}
default-value:
false

fullPackagePath

protected String fullPackagePath
Nom du paquetage pour les fichiers générés (xmi input sepcific).

Since:
2.0.0
Is defined by:
expression:
${generator.fullPackagePath}
default-value:
${project.groupId}.${project.artifactId}

resolver

protected String resolver
Nom du resolver a utiliser pour les transformations xmi vers model (xmi input sepcific).

Since:
2.0.0
Is defined by:
expression:
${generator.resolver}
default-value:
org.nuiton.util.ResourceResolver

templates

protected String templates
Templates à utiliser, séparés par des virgules pour les transformations depuis les models (model input sepcific).

Since:
0.50
Is defined by:
expression:
${eugene.templates}

excludeTemplates

protected String[] excludeTemplates
Templates à ne pas utiliser lors de la transformations des models (model input sepcific).

Since:
0.63
Is defined by:
expression:
${eugene.excludeTemplates}

defaultPackage

protected String defaultPackage
Nom par défaut du paquetage généré (model input specific).

Since:
0.50
Is defined by:
expression:
${eugene.defaultPackage}
default-value:
${project.groupId}.${project.artifactId}

generatedPackages

protected String generatedPackages
List of packages to generate (comma separated). (model input specific).

If the parameter is not filled, will generate all packages.

Since:
1.0.0-rc-8
Is defined by:
expression:
${eugene.generatedPackages}

extractedPackages

protected String extractedPackages
List of package to extract from xmi to models. (model input specific).

If the parameter is not filled, will extract all packages.

Since:
1.0.0-rc-8
Is defined by:
expression:
${eugene.extractedPackages}
default-value:
${project.groupId}.${project.artifactId}

project

protected org.apache.maven.project.MavenProject project
Maven project.

Since:
2.0.0
Is defined by:
default-value:
${project}
Is readonly.

settings

protected org.apache.maven.settings.Settings settings
Le settings (pour obtenir le mode offline).

Since:
2.0.0
Is defined by:
default-value:
${settings}
Is readonly.

_models

protected Map<String,Model> _models
All available models (obtain by plexus, keys are plexus roles, values are a instance of corresponding model).

Is a Plexus component defined by:
role:
org.nuiton.eugene.models.Model

writers

protected Map<String,ChainedFileWriter> writers
All available writers introspects via plexus

Is a Plexus component defined by:
role:
org.nuiton.eugene.writer.ChainedFileWriter

modelReaders

protected Map<String,ModelReader<?>> modelReaders
All available writers introspects via plexus

Is a Plexus component defined by:
role:
org.nuiton.eugene.ModelReader

modelTemplates

protected Map<String,Template<?>> modelTemplates
All available templates introspects via plexus

Is a Plexus component defined by:
role:
org.nuiton.eugene.Template

modelPropertiesProviders

protected Map<String,ModelPropertiesUtil.ModelPropertiesProvider> modelPropertiesProviders
All available model properties providers introspects via plexus

Since:
2.3
Is a Plexus component defined by:
role:
org.nuiton.eugene.ModelPropertiesUtil$ModelPropertiesProvider

engine

protected ChainedWriterEngine engine
The engine to compute ChainedFileWriter from inputs entries.

Is a Plexus component defined by:
role:
org.nuiton.eugene.writer.ChainedWriterEngine

fixedClassLoader

protected ClassLoader fixedClassLoader
fixed classloader

Constructor Detail

SmartGenerateMojo

public SmartGenerateMojo()
Method Detail

init

protected void init()
             throws Exception
Specified by:
init in class org.nuiton.plugin.AbstractPlugin
Throws:
Exception

checkSkip

protected boolean checkSkip()
Overrides:
checkSkip in class org.nuiton.plugin.AbstractPlugin

doAction

protected void doAction()
                 throws Exception
Specified by:
doAction in class org.nuiton.plugin.AbstractPlugin
Throws:
Exception

reportGeneratedFiles

public String reportGeneratedFiles(ChainedFileWriter writer,
                                   long t0)

setInputs

public void setInputs(String inputs)
Add a single input to the 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>
 

Parameters:
inputs - unique input to add

getOutputDirectory

public File getOutputDirectory()
Specified by:
getOutputDirectory in interface ChainedFileWriterConfiguration

getExtractDirectory

public File getExtractDirectory()
Specified by:
getExtractDirectory in interface ChainedFileWriterConfiguration

getProperties

public Map<String,Object> getProperties()
Specified by:
getProperties in interface ChainedFileWriterConfiguration

getClassLoader

public ClassLoader getClassLoader()
Specified by:
getClassLoader in interface ChainedFileWriterConfiguration

getProject

public org.apache.maven.project.MavenProject getProject()
Specified by:
getProject in interface org.nuiton.plugin.Plugin

setProject

public void setProject(org.apache.maven.project.MavenProject project)
Specified by:
setProject in interface org.nuiton.plugin.Plugin

isVerbose

public boolean isVerbose()
Specified by:
isVerbose in interface ChainedFileWriterConfiguration
Specified by:
isVerbose in interface org.nuiton.plugin.Plugin

setVerbose

public void setVerbose(boolean verbose)
Specified by:
setVerbose in interface org.nuiton.plugin.Plugin

getEncoding

public String getEncoding()
Specified by:
getEncoding in interface ChainedFileWriterConfiguration
Specified by:
getEncoding in interface org.nuiton.plugin.PluginWithEncoding

setEncoding

public void setEncoding(String encoding)
Specified by:
setEncoding in interface org.nuiton.plugin.PluginWithEncoding

isOverwrite

public boolean isOverwrite()
Specified by:
isOverwrite in interface ChainedFileWriterConfiguration

isOffline

public boolean isOffline()
Specified by:
isOffline in interface ChainedFileWriterConfiguration

isTestPhase

public boolean isTestPhase()
Specified by:
isTestPhase in interface ChainedFileWriterConfiguration

getModelType

public String getModelType()
Specified by:
getModelType in interface ChainedFileWriterConfiguration

getWriters

public Map<String,ChainedFileWriter> getWriters()
Specified by:
getWriters in interface ChainedFileWriterConfiguration

getModelReaders

public Map<String,ModelReader<?>> getModelReaders()
Specified by:
getModelReaders in interface ChainedFileWriterConfiguration

getModelTemplates

public Map<String,Template<?>> getModelTemplates()
Specified by:
getModelTemplates in interface ChainedFileWriterConfiguration

getBasedir

public File getBasedir()
Specified by:
getBasedir in interface ChainedFileWriterConfiguration

getExcludeTemplatesAsString

protected String getExcludeTemplatesAsString()
Returns:
the string representation of excludesTemplates (separated by comma)

getFixedClassLoader

public ClassLoader getFixedClassLoader()
                                throws org.apache.maven.plugin.MojoExecutionException
Prepare le classLoader a utiliser dans le generateur.

Si le mojo est en phase de test testPhase a été renseigné, target/classes est rajouté.

Si des références à des sibling modules, ils seront rajoutés aussi.

Returns:
le class loader modifie
Throws:
org.apache.maven.plugin.MojoExecutionException - if any pb

fixCompileSourceRoots

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.

Parameters:
destDirGen - le repertoire a traiter

getModelPropertiesProvider

protected ModelPropertiesUtil.ModelPropertiesProvider getModelPropertiesProvider()
                                                                          throws org.apache.maven.plugin.MojoExecutionException
Throws:
org.apache.maven.plugin.MojoExecutionException


Copyright © 2006-2011 CodeLutin. All Rights Reserved.