Package org.nuiton.i18n.plugin.parser
Class AbstractI18nParserMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.nuiton.plugin.AbstractPlugin
org.nuiton.i18n.plugin.AbstractI18nMojo
org.nuiton.i18n.plugin.AbstractI18nGenerateMojo
org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo
- 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
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringacceptKeyFormatA regex pattern to accept incoming keys.protected java.util.regex.PatternacceptPatternprotected booleanbackupGetterFlag to save previous getter in a backup before doing parsing.protected java.io.FilecpBuild directory (used to know if files in sources are up-to-date).protected I18nSourceEntry[]entriesSource entries (src+includes+excludes) to process.protected booleanforceTo force reparse of all sources.protected org.nuiton.io.SortedPropertiesoldLanguageprotected org.nuiton.io.SortedPropertiesoldParserprotected booleanshowTouchedFilesFlag to display touched files while parsing.protected java.io.FilesrcDirectory where to find project i18n files.protected booleanstrictModeStrict mode to only keep in user i18n detected i18n keys and remove obsolete keys.protected longt0protected booleantreateDefaultEntryTo treat default entry offered by the mojo.Fields inherited from class org.nuiton.i18n.plugin.AbstractI18nMojo
bundles, encoding, locales, mavenSession, project, silent, verbose -
Constructor Summary
Constructors Constructor Description AbstractI18nParserMojo() -
Method Summary
Modifier and Type Method Description protected voidaddDefaultEntry()Add the default entry to entries given in configuration.protected voiddoAction()protected abstract java.io.FilegetDefaultBasedir()protected abstract java.lang.String[]getDefaultExcludes()protected abstract java.lang.String[]getDefaultIncludes()static java.lang.StringgetLogEntry(java.lang.String msg, int nbFiles, long time, long all)Construit une chaine de log formatée.protected abstract java.lang.StringgetOutGetter()org.nuiton.io.SortedPropertiesgetResult()voidinit()booleanisForce()booleanisShowTouchedFiles()booleanisStrictMode()abstract FileParsernewFileParser(java.util.regex.Pattern acceptPattern)abstract org.nuiton.io.FileUpdaternewFileUpdater(SourceEntry entry)protected booleanonEnterEntry(I18nSourceEntry entry)protected voidsaveGetterFile()Save the result in the getter file.Methods inherited from class org.nuiton.i18n.plugin.AbstractI18nGenerateMojo
addGetter, getGetterFile, needGenerationMethods inherited from class org.nuiton.i18n.plugin.AbstractI18nMojo
backupFile, checkBundle, checkPackaging, failsIfAnyKeyMissingInBundle, failsIfAnyKeyMissingValue, getBackupFile, getEncoding, getProject, isSilent, isVerbose, setEncoding, setProject, setVerboseMethods 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, writeFileMethods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuiton.i18n.plugin.parser.I18nParserConfiguration
getLog, isSilent, isVerbose
-
Field Details
-
src
@Parameter(property="i18n.src", defaultValue="${basedir}/src/main/resources/i18n", required=true) protected java.io.File srcDirectory where to find project i18n files. -
strictMode
@Parameter(property="i18n.strictMode", defaultValue="false") protected boolean strictModeStrict 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 cpBuild directory (used to know if files in sources are up-to-date). -
treateDefaultEntry
@Parameter(property="i18n.treateDefaultEntry", defaultValue="true") protected boolean treateDefaultEntryTo treat default entry offered by the mojo. -
entries
Source entries (src+includes+excludes) to process. -
showTouchedFiles
@Parameter(property="i18n.showTouchedFiles", defaultValue="${maven.verbose}") protected boolean showTouchedFilesFlag to display touched files while parsing. Note: the value will be alwaystrueifAbstractI18nMojo.verboseis set attrue.- Since:
- 0.9
-
backupGetter
@Parameter(property="i18n.backupGetter", defaultValue="false") protected boolean backupGetterFlag 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 forceTo force reparse of all sources.- Since:
- 1.2
-
acceptKeyFormat
@Parameter(property="i18n.acceptKeyFormat") protected java.lang.String acceptKeyFormatA 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
-
AbstractI18nParserMojo
public AbstractI18nParserMojo()
-
-
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
- 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
- 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:
initin classAbstractI18nMojo- Throws:
java.lang.Exception
-
onEnterEntry
-
doAction
protected void doAction() throws java.lang.Exception- Specified by:
doActionin classorg.nuiton.plugin.AbstractPlugin- Throws:
java.lang.Exception
-
isShowTouchedFiles
public boolean isShowTouchedFiles()- Specified by:
isShowTouchedFilesin interfaceI18nParserConfiguration
-
getResult
public org.nuiton.io.SortedProperties getResult()- Specified by:
getResultin interfaceI18nParserConfiguration
-
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.IOExceptionSave 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 messagenbFiles- le nombre de fichiers actuellement traitéstime- le time de traitement de ce fichierall- le temps de traitement de tous les fichiers- Returns:
- la chaine de log formatée
-