org.nuiton.i18n.plugin.bundle
Class AbstractMakeI18nBundleMojo

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

public abstract class AbstractMakeI18nBundleMojo
extends AbstractI18nBundleMojo

Common mojo to all final bundle maker.

Since:
2.0
Author:
tchemit

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  File bundleOutputDir
          Root directory where to generate aggregated bundles (this directory will be added as resources of the project).
protected  String bundleOutputName
          Name of the bundle to generate.
protected  String bundleOutputPackage
          Package name of the generate aggregated bundles.
protected  boolean checkBundle
          A flag to check that bundles are complete (no missing i18n translations).
protected  boolean failsIfWarning
          A flag to make the build fails if there is some warnings while generating bundle, says when it misses some translations.
protected  boolean generateDefaultLocale
          A flag to generate a bundle with the first locale defined as a default bundle (with no locale specialization).
protected  File outputFolder
          The definitive directory where to generate the bundles (includes the package of bunlde).
protected  boolean showEmpty
          A flag to show missing i18n translation.
protected  Map<Locale,SortedSet<String>> unsafeMapping
          to keep all none translated i18n keys by locale.
 
Fields inherited from class org.nuiton.i18n.plugin.bundle.AbstractI18nBundleMojo
collectOutputDir, collectOutputName
 
Fields inherited from class org.nuiton.i18n.plugin.AbstractI18nMojo
artifactId, bundles, encoding, genSrc, locales, out, project, silent, src, strictMode, verbose
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractMakeI18nBundleMojo()
           
 
Method Summary
protected  void failsIfWarning()
           
protected  void generateDefaultBundle()
          Generates the default bundle, says the bundle with no locale specialized.
protected abstract  File getBundleFile(File root, String artifactId, Locale locale, boolean create)
          Gets the bundle file for the given parameters.
protected  File getBundleOutputFolder()
           
 void init()
           
 
Methods inherited from class org.nuiton.i18n.plugin.bundle.AbstractI18nBundleMojo
getCollectI18nResources, getCollectOutputFile, getLinesAsURL
 
Methods inherited from class org.nuiton.i18n.plugin.AbstractI18nMojo
addGetter, backupFile, checkBundle, checkPackaging, getArtifactId, getBackupFile, getEncoding, getGetterFile, getI18nFile, getProject, isSilent, isStrictMode, isVerbose, needGeneration, setEncoding, setProject, setVerbose
 
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

bundleOutputDir

protected File bundleOutputDir
Root directory where to generate aggregated bundles (this directory will be added as resources of the project).

Since:
1.0.0
Is defined by:
expression:
${i18n.bundleOutputDir}
default-value:
${basedir}/target/generated-sources/resources
Is required.

bundleOutputPackage

protected String bundleOutputPackage
Package name of the generate aggregated bundles.

Note: By default we use the META-INF package since it is the favorite package of I18n runtime initializer.

The package name is dotted as it will be stored as folder like in Java language.

Example :

     package name : foo.bar
     directory    : foo/bar
 

Since:
2.3.2
Is defined by:
expression:
${i18n.bundleOutputPackage}
default-value:
META-INF
Is required.

bundleOutputName

protected String bundleOutputName
Name of the bundle to generate.

Since:
1.0.2
Is defined by:
expression:
${i18n.bundleOutputName}
default-value:
${project.artifactId}-i18n
Is required.

generateDefaultLocale

protected boolean generateDefaultLocale
A flag to generate a bundle with the first locale defined as a default bundle (with no locale specialization).

Since:
2.1
Is defined by:
expression:
${i18n.generateDefaultLocale}
default-value:
false

checkBundle

protected boolean checkBundle
A flag to check that bundles are complete (no missing i18n translations).

Note : This behaviour will be activated is failsIfWarning is on.

Since:
1.0.0
Is defined by:
expression:
${i18n.checkBundle}
default-value:
true

showEmpty

protected boolean showEmpty
A flag to show missing i18n translation.

Note : Need the checkBundle to be activated).

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

failsIfWarning

protected boolean failsIfWarning
A flag to make the build fails if there is some warnings while generating bundle, says when it misses some translations.

Note : This parameter should be used in a release profile to ensure bundles are complete.

Since:
2.0
Is defined by:
expression:
${i18n.failsIfWarning}
default-value:
false

unsafeMapping

protected Map<Locale,SortedSet<String>> unsafeMapping
to keep all none translated i18n keys by locale.


outputFolder

protected File outputFolder
The definitive directory where to generate the bundles (includes the package of bunlde).

Since:
2.3.2
Constructor Detail

AbstractMakeI18nBundleMojo

public AbstractMakeI18nBundleMojo()
Method Detail

init

public void init()
          throws Exception
Overrides:
init in class AbstractI18nMojo
Throws:
Exception

failsIfWarning

protected void failsIfWarning()
                       throws org.apache.maven.plugin.MojoFailureException
Throws:
org.apache.maven.plugin.MojoFailureException

getBundleFile

protected abstract File getBundleFile(File root,
                                      String artifactId,
                                      Locale locale,
                                      boolean create)
                               throws IOException
Gets the bundle file for the given parameters.

Parameters:
root - the root directory where bundles are stored
artifactId - the artifactId (says the prefix of bundle)
locale - the locale used in bundle (null means no locale specialized)
create - a flag to create the file if none existing
Returns:
the bundle file
Throws:
IOException - if any IO problem while creating it (if needed).
Since:
2.1

generateDefaultBundle

protected void generateDefaultBundle()
                              throws IOException
Generates the default bundle, says the bundle with no locale specialized.

This bundle is a copy of the bundle of the first locale (which in fact is considered as the main locale).

Throws:
IOException - if any IO problem while the copy.
Since:
2.1

getBundleOutputFolder

protected File getBundleOutputFolder()


Copyright © 2007-2011 CodeLutin. All Rights Reserved.