Class GenerateMojo

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

@Mojo(name="generate", requiresDependencyResolution=COMPILE) public class GenerateMojo extends org.nuiton.plugin.AbstractPlugin implements org.nuiton.eugene.writer.ChainedFileWriterConfiguration, org.nuiton.plugin.PluginWithEncoding
Eugene generator plugin (a.k.a generate mojo) Fill inputs and mojo will chained needed writer.
Since:
2.5
Author:
Tony Chemit - chemit@codelutin.com
  • 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

    Fields
    Modifier and Type
    Field
    Description
    protected Map<String, org.nuiton.eugene.models.Model>
    All available models (obtain by plexus, keys are plexus roles, values are a instance of corresponding model).
    protected String
    Nom par défaut du paquetage généré (model input specific).
    protected boolean
    Ne génère rien, analyse juste la configuration.
    protected String
    Encoding to be used for generation of files.
    protected org.nuiton.eugene.writer.ChainedWriterEngine
    The engine to compute ChainedFileWriter from inputs entries.
    protected String[]
    Templates à ne pas utiliser lors de la transformations des models (model input sepcific).
    protected File
    Where to copy extracted files (when using class-path data).
    protected String
    List of package to extract from xmi to models.
    protected boolean
    A flag to fail if model properties is not safe (means some tagValues or stereotypes are not correct).
    protected ClassLoader
    fixed classloader
    protected String
    Nom du paquetage pour les fichiers générés (xmi input sepcific).
    protected String
    List of packages to generate (comma separated).
    protected String[]
    Inputs files to used to generate the required model files.
    protected File
    To use a new object model extension file.
    protected org.nuiton.eugene.ModelHelper
     
    protected Map<String, org.nuiton.eugene.ModelReader<?>>
    All available writers introspects via plexus.
    protected Map<String, org.nuiton.eugene.Template<?>>
    All available templates introspects via plexus.
    protected String
    The type of model to be used.
    protected File
    Where to generate files.
    protected boolean
    Ecrase les fichiers générés.
    protected org.apache.maven.project.MavenProject
    Maven project.
    protected Map<String,Object>
    Properties to pass to writer.
    protected String
    Nom du resolver a utiliser pour les transformations xmi vers model (xmi input sepcific).
    protected org.apache.maven.settings.Settings
    Le settings (pour obtenir le mode offline).
    protected String
    List of input (protocol) not to treate separated by comma.
    protected List<org.nuiton.eugene.Template<org.nuiton.eugene.models.Model>>
     
    protected String
    Templates à utiliser, séparés par des virgules pour les transformations depuis les models (model input sepcific).
    protected boolean
    A flag to mark the mojo to be used in a test phase.
    protected boolean
    Pour activer le mode verbeux.
    protected Map<String, org.nuiton.eugene.writer.ChainedFileWriter>
    All available writers introspects via plexus.

    Fields inherited from interface org.apache.maven.plugin.Mojo

    ROLE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    applyTemplates(org.nuiton.eugene.models.Model model, Long lastModifiedSource, File outputDirectory, List<org.nuiton.eugene.Template<org.nuiton.eugene.models.Model>> templateList, org.nuiton.eugene.writer.WriterReport writerReport)
     
    protected boolean
     
    protected void
     
    protected void
    permet d'ajout le répertoire de génération des fichiers java dans les répertoires de compilation du projet Maven.
     
     
     
    protected String
     
     
    Prepare le classLoader a utiliser dans le generateur.
     
    org.nuiton.eugene.ModelHelper
     
     
     
    org.apache.maven.project.MavenProject
     
     
    Map<String, org.nuiton.eugene.writer.ChainedFileWriter>
     
    protected void
     
    protected List<org.nuiton.eugene.Template<org.nuiton.eugene.models.Model>>
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    protected org.nuiton.eugene.writer.WriterReport
     
    protected String
    reportCopiedResources(org.nuiton.eugene.writer.WriterReport writerReport)
     
    protected String
    reportGeneratedFiles(org.nuiton.eugene.writer.WriterReport writerReport, 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, needInvoke, needInvoke, rejectPackaging, removeCompileSourceRoots, removeTestCompileSourceRoots, renameFile, writeFile

    Methods inherited from class org.apache.maven.plugin.AbstractMojo

    getLog, getPluginContext, setLog, setPluginContext

    Methods inherited from class 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 Details

    • inputs

      @Parameter(property="eugene.inputs", required=true) 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
    • skipInputs

      @Parameter(property="eugene.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
    • outputDirectory

      @Parameter(property="eugene.outputDirectory", defaultValue="target/generated-sources", required=true) protected File outputDirectory
      Where to generate files.
      Since:
      2.0.0
    • extractDirectory

      @Parameter(property="eugene.extractDirectory", defaultValue="target/extracted-sources", required=true) protected File extractDirectory
      Where to copy extracted files (when using class-path data).
      Since:
      2.1.3
    • overwrite

      @Parameter(property="eugene.overwrite", defaultValue="false") protected boolean overwrite
      Ecrase les fichiers générés.
      Since:
      2.0.0
    • verbose

      @Parameter(property="eugene.verbose", defaultValue="${maven.verbose}") protected boolean verbose
      Pour activer le mode verbeux.
      Since:
      2.0.0
    • encoding

      @Parameter(property="eugene.encoding", defaultValue="${project.build.sourceEncoding}") 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
    • testPhase

      @Parameter(property="eugene.testPhase", defaultValue="false") 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
    • modelType

      @Parameter(property="eugene.modelType", defaultValue="objectmodel", required=true) protected String modelType
      The type of model to be used. By default, use an objectmodel.
      Since:
      2.0.0
    • properties

      @Parameter protected Map<String,Object> properties
      Properties to pass to writer.
      Since:
      2.0.0
    • dryRun

      @Parameter(property="eugene.dryRun", defaultValue="false") protected boolean dryRun
      Ne génère rien, analyse juste la configuration.
      Since:
      2.0.0
    • fullPackagePath

      @Parameter(property="generator.fullPackagePath", defaultValue="${project.groupId}.${project.artifactId}") protected String fullPackagePath
      Nom du paquetage pour les fichiers générés (xmi input sepcific).
      Since:
      2.0.0
    • resolver

      @Parameter(property="generator.resolver", defaultValue="org.nuiton.util.ResourceResolver") protected String resolver
      Nom du resolver a utiliser pour les transformations xmi vers model (xmi input sepcific).
      Since:
      2.0.0
    • templates

      @Parameter(property="eugene.templates") protected String templates
      Templates à utiliser, séparés par des virgules pour les transformations depuis les models (model input sepcific).
      Since:
      0.50
    • excludeTemplates

      @Parameter(property="eugene.excludeTemplates") protected String[] excludeTemplates
      Templates à ne pas utiliser lors de la transformations des models (model input sepcific).
      Since:
      0.63
    • defaultPackage

      @Parameter(property="eugene.defaultPackage", defaultValue="${project.groupId}.${project.artifactId}") protected String defaultPackage
      Nom par défaut du paquetage généré (model input specific).
      Since:
      0.50
    • generatedPackages

      @Parameter(property="eugene.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
    • extractedPackages

      @Parameter(property="eugene.extractedPackages", defaultValue="${project.groupId}.${project.artifactId}") 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
    • failIfUnsafe

      @Parameter(property="eugene.failIfUnsafe", defaultValue="true") protected boolean failIfUnsafe
      A flag to fail if model properties is not safe (means some tagValues or stereotypes are not correct). Note: since version 3.0, the default value is true.
      Since:
      2.9
    • modelExtensionFile

      @Parameter(property="eugene.modelExtensionFile") protected File modelExtensionFile
      To use a new object model extension file.
      Since:
      3.0
    • project

      @Parameter(defaultValue="${project}", readonly=true) protected org.apache.maven.project.MavenProject project
      Maven project.
      Since:
      2.0.0
    • settings

      @Parameter(defaultValue="${settings}", readonly=true) protected org.apache.maven.settings.Settings settings
      Le settings (pour obtenir le mode offline).
      Since:
      2.0.0
    • _models

      @Component(role=org.nuiton.eugene.models.Model.class) protected Map<String, org.nuiton.eugene.models.Model> _models
      All available models (obtain by plexus, keys are plexus roles, values are a instance of corresponding model).
    • writers

      @Component(role=org.nuiton.eugene.writer.ChainedFileWriter.class) protected Map<String, org.nuiton.eugene.writer.ChainedFileWriter> writers
      All available writers introspects via plexus.
    • modelReaders

      @Component(role=org.nuiton.eugene.ModelReader.class) protected Map<String, org.nuiton.eugene.ModelReader<?>> modelReaders
      All available writers introspects via plexus.
    • modelTemplates

      @Component(role=org.nuiton.eugene.Template.class) protected Map<String, org.nuiton.eugene.Template<?>> modelTemplates
      All available templates introspects via plexus.
    • engine

      @Component(role=org.nuiton.eugene.writer.ChainedWriterEngine.class) protected org.nuiton.eugene.writer.ChainedWriterEngine engine
      The engine to compute ChainedFileWriter from inputs entries.
    • modelHelper

      protected org.nuiton.eugene.ModelHelper modelHelper
    • fixedClassLoader

      protected ClassLoader fixedClassLoader
      fixed classloader
    • templateList

      protected List<org.nuiton.eugene.Template<org.nuiton.eugene.models.Model>> templateList
  • Constructor Details

    • GenerateMojo

      public GenerateMojo()
  • Method Details

    • newWriterReport

      protected org.nuiton.eugene.writer.WriterReport newWriterReport()
    • 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
    • applyTemplates

      protected void applyTemplates(org.nuiton.eugene.models.Model model, Long lastModifiedSource, File outputDirectory, List<org.nuiton.eugene.Template<org.nuiton.eugene.models.Model>> templateList, org.nuiton.eugene.writer.WriterReport writerReport) throws IOException
      Throws:
      IOException
    • 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 org.nuiton.eugene.writer.ChainedFileWriterConfiguration
    • getExtractDirectory

      public File getExtractDirectory()
      Specified by:
      getExtractDirectory in interface org.nuiton.eugene.writer.ChainedFileWriterConfiguration
    • getProperties

      public Map<String,Object> getProperties()
      Specified by:
      getProperties in interface org.nuiton.eugene.writer.ChainedFileWriterConfiguration
    • getClassLoader

      public ClassLoader getClassLoader()
      Specified by:
      getClassLoader in interface org.nuiton.eugene.writer.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 org.nuiton.eugene.writer.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 org.nuiton.eugene.writer.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 org.nuiton.eugene.writer.ChainedFileWriterConfiguration
    • isOffline

      public boolean isOffline()
      Specified by:
      isOffline in interface org.nuiton.eugene.writer.ChainedFileWriterConfiguration
    • isTestPhase

      public boolean isTestPhase()
      Specified by:
      isTestPhase in interface org.nuiton.eugene.writer.ChainedFileWriterConfiguration
    • getModelType

      public String getModelType()
      Specified by:
      getModelType in interface org.nuiton.eugene.writer.ChainedFileWriterConfiguration
    • getWriters

      public Map<String, org.nuiton.eugene.writer.ChainedFileWriter> getWriters()
      Specified by:
      getWriters in interface org.nuiton.eugene.writer.ChainedFileWriterConfiguration
    • getModelHelper

      public org.nuiton.eugene.ModelHelper getModelHelper()
      Specified by:
      getModelHelper in interface org.nuiton.eugene.writer.ChainedFileWriterConfiguration
    • getBasedir

      public File getBasedir()
      Specified by:
      getBasedir in interface org.nuiton.eugene.writer.ChainedFileWriterConfiguration
    • getModelExtensionFile

      public File getModelExtensionFile()
      Specified by:
      getModelExtensionFile in interface org.nuiton.eugene.writer.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
    • initTemplates

      protected List<org.nuiton.eugene.Template<org.nuiton.eugene.models.Model>> initTemplates()
    • reportGeneratedFiles

      protected String reportGeneratedFiles(org.nuiton.eugene.writer.WriterReport writerReport, long t0)
    • reportCopiedResources

      protected String reportCopiedResources(org.nuiton.eugene.writer.WriterReport writerReport)