org.nuiton.i18n.plugin
Class AbstractI18nMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.nuiton.plugin.AbstractPlugin
          extended by org.nuiton.i18n.plugin.AbstractI18nMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo, org.nuiton.plugin.Plugin, org.nuiton.plugin.PluginWithEncoding
Direct Known Subclasses:
AbstractI18nBundleMojo, AbstractI18nParserMojo, GenerateMojo, GetterMojo

public abstract class AbstractI18nMojo
extends org.nuiton.plugin.AbstractPlugin
implements org.nuiton.plugin.PluginWithEncoding

Lower level i18n mojo abstraction.

We defines here all commons parameters and shared behaviour.

Author:
tchemit , jruchaud

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  String artifactId
          Name to use as prefix of generated files.
protected  String bundles
          Locales to treate, separated by comma.
protected  String encoding
          Encoding used to load and store files.
protected  boolean genSrc
          To update generated files to user i18n files.
protected  Locale[] locales
          locales to process
protected  File out
          Directory where to generate i18n files.
protected  org.apache.maven.project.MavenProject project
          Dependance du projet.
protected  boolean silent
          Silent flag to see only errors in console.
protected  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  boolean verbose
          Verbose flag.
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractI18nMojo()
           
 
Method Summary
protected  void addGetter()
          Prend en compte qu'un getter a été détecté.
protected  void backupFile(File f)
           
protected  void checkBundle(Locale locale, Properties propertiesOut, boolean showEmpty, Map<Locale,SortedSet<String>> unsafeHolder)
           
protected  boolean checkPackaging()
           
 String getArtifactId()
           
 File getBackupFile(File file)
           
 String getEncoding()
           
 File getGetterFile(File root, String getter, boolean create)
           
 File getI18nFile(File root, String artifactId, Locale locale, boolean create)
           
 org.apache.maven.project.MavenProject getProject()
           
 void init()
           
 boolean isSilent()
           
 boolean isStrictMode()
           
 boolean isVerbose()
           
protected  boolean needGeneration()
           
 void setEncoding(String encoding)
           
 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, checkEncoding, checkResource, checkRunOnceDone, checkSkip, copyFile, createDirectoryIfNecessary, createNewFile, deleteFile, doAction, execute, 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

project

protected org.apache.maven.project.MavenProject project
Dependance du projet.

Since:
1.0.2
Is defined by:
default-value:
${project}
Is required.

artifactId

protected String artifactId
Name to use as prefix of generated files.

Note : By default, use the artifact id.

Is defined by:
expression:
${i18n.artifactId}
default-value:
${project.artifactId}
Is readonly.

bundles

protected String bundles
Locales to treate, separated by comma.

Example :

fr_FR,en_GB

Is defined by:
expression:
${i18n.bundles}
default-value:
fr_FR,en_GB
Is required.

src

protected File src
Directory where to find project i18n files.

Is defined by:
expression:
${i18n.src}
default-value:
${basedir}/src/main/resources/i18n
Is required.

out

protected File out
Directory where to generate i18n files.

Is defined by:
expression:
${i18n.out}
default-value:
${basedir}/target/generated-sources/i18n
Is required.

encoding

protected String encoding
Encoding used to load and store files.

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

Is defined by:
expression:
${i18n.encoding}
default-value:
${project.build.sourceEncoding}
Is required.

genSrc

protected boolean genSrc
To update generated files to user i18n files.

Note : By default, this is active, in order to have a project uptodate with last i18n bundles detected.

Is defined by:
expression:
${i18n.genSrc}
default-value:
true

verbose

protected boolean verbose
Verbose flag.

Note : if not setted, we used the maven.verbose property.

Is defined by:
expression:
${i18n.verbose}
default-value:
${maven.verbose}

silent

protected boolean silent
Silent flag to see only errors in console.

Since:
1.0.0-rc-5
Is defined by:
expression:
${i18n.silent}
default-value:
false

strictMode

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.

Is defined by:
expression:
${i18n.strictMode}
default-value:
false

locales

protected Locale[] locales
locales to process

Constructor Detail

AbstractI18nMojo

public AbstractI18nMojo()
Method Detail

checkPackaging

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

init

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

getArtifactId

public String getArtifactId()

needGeneration

protected boolean needGeneration()
Returns:
true si des getters ont etes enregistres pendant le cycle de vie, false sinon.

addGetter

protected void addGetter()
Prend en compte qu'un getter a été détecté.

Cela veut dire qu'un goal de parser a détecté des clefs. Il faudra donc activer les goal get et gen.


getI18nFile

public File getI18nFile(File root,
                        String artifactId,
                        Locale locale,
                        boolean create)
                 throws IOException
Parameters:
root - le repertoire ou sont stockes les fichiers i18n
artifactId - le nom de l'artifact
locale - le nom du bundle
create - true pour creer le fichier si non present
Returns:
le fichier i18n
Throws:
IOException - si probleme lors de la creation du fichier

getGetterFile

public File getGetterFile(File root,
                          String getter,
                          boolean create)
                   throws IOException
Parameters:
root - le repertoire ou sont stockes les fichiers getter
getter - le nom du getter
create - true pour creer le fichier si non present
Returns:
le fichier i18n
Throws:
IOException - si probleme lors de la creation du fichier

checkBundle

protected void checkBundle(Locale locale,
                           Properties propertiesOut,
                           boolean showEmpty,
                           Map<Locale,SortedSet<String>> unsafeHolder)

getBackupFile

public File getBackupFile(File file)
Overrides:
getBackupFile in class org.nuiton.plugin.AbstractPlugin

backupFile

protected void backupFile(File f)
                   throws IOException
Overrides:
backupFile in class org.nuiton.plugin.AbstractPlugin
Throws:
IOException

getEncoding

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

setEncoding

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

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.plugin.Plugin

setVerbose

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

isSilent

public boolean isSilent()

isStrictMode

public boolean isStrictMode()


Copyright © 2007-2010 CodeLutin. All Rights Reserved.