Class AbstractI18nParserMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.nuiton.plugin.AbstractPlugin
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo, I18nParserConfiguration, org.nuiton.plugin.Plugin, org.nuiton.plugin.PluginWithEncoding
Direct Known Subclasses:
AbstractParserXmlMojo, ParserGWTJavaMojo, ParserJavaMojo, ParserStruts2Mojo

public abstract class AbstractI18nParserMojo
extends AbstractI18nGenerateMojo
implements I18nParserConfiguration
Abstract implementation for parsing goal.
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 java.lang.String acceptKeyFormat
    A regex pattern to accept incoming keys.
    protected java.util.regex.Pattern acceptPattern  
    protected boolean backupGetter
    Flag to save previous getter in a backup before doing parsing.
    protected java.io.File cp
    Build directory (used to know if files in sources are up-to-date).
    protected I18nSourceEntry[] entries
    Source entries (src+includes+excludes) to process.
    protected boolean force
    To force reparse of all sources.
    protected org.nuiton.io.SortedProperties oldLanguage  
    protected org.nuiton.io.SortedProperties oldParser  
    protected boolean showTouchedFiles
    Flag to display touched files while parsing.
    protected java.io.File src
    Directory where to find project i18n files.
    protected boolean strictMode
    Strict mode to only keep in user i18n detected i18n keys and remove obsolete keys.
    protected long t0  
    protected boolean treateDefaultEntry
    To treat default entry offered by the mojo.

    Fields inherited from class org.nuiton.i18n.plugin.AbstractI18nGenerateMojo

    artifactId, out

    Fields inherited from class org.nuiton.i18n.plugin.AbstractI18nMojo

    bundles, encoding, locales, mavenSession, project, silent, verbose

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

    ROLE
  • Constructor Summary

    Constructors 
    Constructor Description
    AbstractI18nParserMojo()  
  • Method Summary

    Modifier and Type Method Description
    protected void addDefaultEntry()
    Add the default entry to entries given in configuration.
    protected void doAction()  
    protected abstract java.io.File getDefaultBasedir()  
    protected abstract java.lang.String[] getDefaultExcludes()  
    protected abstract java.lang.String[] getDefaultIncludes()  
    static java.lang.String getLogEntry​(java.lang.String msg, int nbFiles, long time, long all)
    Construit une chaine de log formatée.
    protected abstract java.lang.String getOutGetter()  
    org.nuiton.io.SortedProperties getResult()  
    void init()  
    boolean isForce()  
    boolean isShowTouchedFiles()  
    boolean isStrictMode()  
    abstract FileParser newFileParser​(java.util.regex.Pattern acceptPattern)  
    abstract org.nuiton.io.FileUpdater newFileUpdater​(SourceEntry entry)  
    protected boolean onEnterEntry​(I18nSourceEntry entry)  
    protected void saveGetterFile()
    Save the result in the getter file.

    Methods inherited from class org.nuiton.i18n.plugin.AbstractI18nGenerateMojo

    addGetter, getGetterFile, needGeneration

    Methods inherited from class org.nuiton.plugin.AbstractPlugin

    acceptPackaging, addCompileSourceRoots, addDirectoryToUrlsList, addResourceDir, addTestCompileSourceRoots, addTestResourceDir, addUrlToUrlsList, afterExecute, checkEncoding, checkResource, checkRunOnceDone, checkSkip, copyFile, createDirectoryIfNecessary, createNewFile, deleteFile, execute, 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 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.nuiton.i18n.plugin.parser.I18nParserConfiguration

    getLog, isSilent, isVerbose

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

    execute, getLog, setLog
  • Field Details

    • src

      @Parameter(property="i18n.src", defaultValue="${basedir}/src/main/resources/i18n", required=true) protected java.io.File src
      Directory where to find project i18n files.
    • strictMode

      @Parameter(property="i18n.strictMode", defaultValue="false") protected boolean strictMode
      Strict mode to only keep in user i18n detected i18n keys and remove obsolete keys. Note : By default not active. Use this with care since it can delete keys. Moreover if this flag is activated, then all files will be parsed.
    • cp

      @Parameter(property="i18n.cp", defaultValue="${basedir}/target/classes") protected java.io.File cp
      Build directory (used to know if files in sources are up-to-date).
    • treateDefaultEntry

      @Parameter(property="i18n.treateDefaultEntry", defaultValue="true") protected boolean treateDefaultEntry
      To treat default entry offered by the mojo.
    • entries

      @Parameter(property="i18n.entries") protected I18nSourceEntry[] entries
      Source entries (src+includes+excludes) to process.
    • showTouchedFiles

      @Parameter(property="i18n.showTouchedFiles", defaultValue="${maven.verbose}") protected boolean showTouchedFiles
      Flag to display touched files while parsing. Note: the value will be always true if AbstractI18nMojo.verbose is set at true.
      Since:
      0.9
    • backupGetter

      @Parameter(property="i18n.backupGetter", defaultValue="false") protected boolean backupGetter
      Flag to save previous getter in a backup before doing parsing. Note: by default, do not perform backup (but it was here originaly so let it possible...)
      Since:
      1.0.2
    • force

      @Parameter(property="i18n.force", defaultValue="false") protected boolean force
      To force reparse of all sources.
      Since:
      1.2
    • acceptKeyFormat

      @Parameter(property="i18n.acceptKeyFormat") protected java.lang.String acceptKeyFormat
      A regex pattern to accept incoming keys. Only incoming keys which match the pattern will be kept.
      Since:
      2.5
    • acceptPattern

      protected java.util.regex.Pattern acceptPattern
    • oldParser

      protected org.nuiton.io.SortedProperties oldParser
    • oldLanguage

      protected org.nuiton.io.SortedProperties oldLanguage
    • t0

      protected long t0
  • Constructor Details

  • Method Details

    • getOutGetter

      protected abstract java.lang.String getOutGetter()
      Returns:
      the outGetter to use for the instance (java.getter,...)
    • getDefaultIncludes

      protected abstract java.lang.String[] getDefaultIncludes()
      Returns:
      the default includes to add to directory scanner
    • getDefaultExcludes

      protected abstract java.lang.String[] getDefaultExcludes()
      Returns:
      the default excludes to add to directory scanner
    • getDefaultBasedir

      protected abstract java.io.File getDefaultBasedir()
      Returns:
      the default src directory to use in directory scanner
    • newFileParser

      public abstract FileParser newFileParser​(java.util.regex.Pattern acceptPattern)
      Parameters:
      acceptPattern - optional pattern to accept incoming keys
      Returns:
      a new file parser to be used in the parser consumer parserExecutor
      Since:
      1.2
    • newFileUpdater

      public abstract org.nuiton.io.FileUpdater newFileUpdater​(SourceEntry entry)
      Parameters:
      entry - the incoming source entry to attach to the file updater
      Returns:
      a new file updater to detects files to treate
    • isForce

      public boolean isForce()
    • init

      public void init() throws java.lang.Exception
      Overrides:
      init in class AbstractI18nMojo
      Throws:
      java.lang.Exception
    • onEnterEntry

      protected boolean onEnterEntry​(I18nSourceEntry entry)
    • doAction

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

      public boolean isShowTouchedFiles()
      Specified by:
      isShowTouchedFiles in interface I18nParserConfiguration
    • getResult

      public org.nuiton.io.SortedProperties getResult()
      Specified by:
      getResult in interface I18nParserConfiguration
    • isStrictMode

      public boolean isStrictMode()
    • addDefaultEntry

      protected void addDefaultEntry()
      Add the default entry to entries given in configuration. This is a convinient method to simplify the configuration of the plugin.
    • saveGetterFile

      protected void saveGetterFile() throws java.io.IOException
      Save the result in the getter file.
      Throws:
      java.io.IOException - if any io pb
    • getLogEntry

      public static java.lang.String getLogEntry​(java.lang.String msg, int nbFiles, long time, long all)
      Construit une chaine de log formatée.
      Parameters:
      msg - le prefix du message
      nbFiles - le nombre de fichiers actuellement traités
      time - le time de traitement de ce fichier
      all - le temps de traitement de tous les fichiers
      Returns:
      la chaine de log formatée