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
Nested classes/interfaces inherited from interface org.nuiton.plugin.Plugin
org.nuiton.plugin.Plugin.InitState, org.nuiton.plugin.Plugin.Packaging -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringA regex pattern to accept incoming keys.protected Patternprotected booleanFlag to save previous getter in a backup before doing parsing.protected FileBuild directory (used to know if files in sources are up-to-date).protected I18nSourceEntry[]Source entries (src+includes+excludes) to process.protected booleanTo force reparse of all sources.protected org.nuiton.io.SortedPropertiesprotected org.nuiton.io.SortedPropertiesprotected booleanFlag to display touched files while parsing.protected FileDirectory where to find project i18n files.protected booleanStrict mode to only keep in user i18n detected i18n keys and remove obsolete keys.protected longprotected booleanTo treat default entry offered by the mojo.Fields inherited from class org.nuiton.i18n.plugin.AbstractI18nGenerateMojo
artifactId, outFields inherited from class org.nuiton.i18n.plugin.AbstractI18nMojo
bundles, encoding, locales, mavenSession, project, silent, verboseFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdd the default entry to entries given in configuration.protected voiddoAction()protected abstract Fileprotected abstract String[]protected abstract String[]static StringgetLogEntry(String msg, int nbFiles, long time, long all) Construit une chaine de log formatée.protected abstract Stringorg.nuiton.io.SortedPropertiesvoidinit()booleanisForce()booleanbooleanabstract FileParsernewFileParser(Pattern acceptPattern) abstract org.nuiton.io.FileUpdaternewFileUpdater(SourceEntry entry) protected booleanonEnterEntry(I18nSourceEntry entry) protected voidSave 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, isVerboseMethods 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 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
Build 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
A regex pattern to accept incoming keys. Only incoming keys which match the pattern will be kept.- Since:
- 2.5
-
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
- Returns:
- the outGetter to use for the instance (java.getter,...)
-
getDefaultIncludes
- Returns:
- the default includes to add to directory scanner
-
getDefaultExcludes
- Returns:
- the default excludes to add to directory scanner
-
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
- Overrides:
initin classAbstractI18nMojo- Throws:
Exception
-
onEnterEntry
-
doAction
- Specified by:
doActionin classorg.nuiton.plugin.AbstractPlugin- Throws:
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
Save the result in the getter file.- Throws:
IOException- if any io pb
-
getLogEntry
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
-