Package org.nuiton.i18n.plugin.bundle
Class BundleMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.nuiton.plugin.AbstractPlugin
org.nuiton.i18n.plugin.AbstractI18nMojo
org.nuiton.i18n.plugin.bundle.AbstractI18nBundleMojo
org.nuiton.i18n.plugin.bundle.BundleMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo,org.nuiton.plugin.Plugin,org.nuiton.plugin.PluginWithEncoding
@Mojo(name="bundle",
defaultPhase=GENERATE_RESOURCES,
requiresProject=true,
requiresDependencyResolution=RUNTIME)
@Execute(goal="collect-i18n-artifacts")
public class BundleMojo
extends AbstractI18nBundleMojo
Generate an aggregate i18n bundle for all dependencies of the project.
The main idea is to have a final unique i18n bundle for an application to
launch, this really improve i18n loading time to have a unique named bundle,
no need to seek in all dependencies...
Moreover, this permits also to deal with order of i18n keys, more precisely,
we want to use the higher level i18n key for an application. If the i18n
key is present on a library, we want to be able to override it in
application (or user wants it:)).
This goal permits this using the dependencies graph order of artifacts.
- Since:
- 0.12
- Author:
- Tony Chemit - chemit@codelutin.com
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description protected java.io.FilebundleCsvFileDeprecated.since 3.3, prefer use the new mojo generate-csv-bundle insteadprotected java.lang.StringbundleCsvSeparatorDeprecated.since 3.3, prefer use the new mojo generate-csv-bundle insteadprotected java.lang.StringbundleFormatConverterConverter used to change format of bundles.protected java.util.Map<java.lang.String,BundleFormatConverter>bundleFormatConvertersMap of all availablesBundleFormatConverter.protected java.lang.StringbundleInputEncodingEncoding used to load any i18n property files.protected java.io.FilebundleOutputDirRoot directory where to generate aggregated bundles (this directory will be added as resources of the project).protected java.lang.StringbundleOutputEncodingEncoding used to write any i18n property files.protected java.lang.StringbundleOutputNameName of the bundle to generate.protected java.lang.StringbundleOutputPackagePackage name of the generate aggregated bundles.protected BundleValidationbundleValidationContains validation result afterAbstractI18nMojo.checkBundle(Locale, Properties, boolean, BundleValidation).protected booleancheckBundleA flag to check that bundles are complete (no missing i18n translations).protected BundleFormatConverterconverterFormat converter to apply ifprotected booleanfailsIfAnyKeyMissingInBundleA flag to make the build fails if there is some missing keys.protected booleanfailsIfAnyKeyMissingValueA flag to make the build fails if there is some missing key values.protected booleanfailsIfWarningDeprecated.since 3.6.1, prefer use nowfailsIfAnyKeyMissingValueorfailsIfAnyKeyMissingInBundle.protected booleangenerateCsvFileDeprecated.since 3.3, prefer use the new mojo generate-csv-bundle insteadprotected booleangenerateDefaultLocaleA flag to generate a bundle with the first locale defined as a default bundle (with no locale specialization).protected booleangenerateDefinitionFileA flag to generate the i18n definition file.protected java.io.FileoutputFolderThe definitive directory where to generate the bundles (includes the package of bundle).protected booleanshowEmptyA flag to show missing i18n translation.Fields inherited from class org.nuiton.i18n.plugin.bundle.AbstractI18nBundleMojo
collectOutputDir, collectOutputNameFields inherited from class org.nuiton.i18n.plugin.AbstractI18nMojo
bundles, encoding, locales, mavenSession, project, silent, verbose -
Constructor Summary
Constructors Constructor Description BundleMojo() -
Method Summary
Modifier and Type Method Description protected voidapplyConversion(java.util.Properties properties)Apply conversion overpropertieswith internal converter.protected voiddoAction()protected voidgenerateCsvFile()Generates a csv file with all translations.protected voidgenerateDefaultBundle()Generates the default bundle, says the bundle with no locale specialized.protected voidgenerateDefinitionFile(java.lang.String version, java.util.Map<java.util.Locale,java.lang.String> bundleDico)protected java.io.FilegetBundleFile(java.io.File root, java.lang.String artifactId, java.util.Locale locale, boolean create)java.lang.StringgetBundleInputEncoding()java.lang.StringgetBundleOutputEncoding()protected java.io.FilegetBundleOutputFolder()protected java.net.URL[]getCollectI18nResources(java.util.Locale locale)Pour obtenir les urls des fichiers i18n d'un projet (avec recherche dans ses dépendances).voidinit()Methods inherited from class org.nuiton.i18n.plugin.bundle.AbstractI18nBundleMojo
getCollectOutputFileMethods 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, setPluginContext
-
Field Details
-
bundleInputEncoding
@Parameter(property="i18n.bundleInputEncoding") protected java.lang.String bundleInputEncodingEncoding used to load any i18n property files. If not defined, will use theAbstractI18nMojo.encodingparameter.- Since:
- 2.4
-
bundleOutputEncoding
@Parameter(property="i18n.bundleOutputEncoding") protected java.lang.String bundleOutputEncodingEncoding used to write any i18n property files. If not defined, will use theAbstractI18nMojo.encodingparameter.- Since:
- 2.4
-
bundleOutputDir
@Parameter(property="i18n.bundleOutputDir", defaultValue="${basedir}/target/generated-sources/resources", required=true) protected java.io.File bundleOutputDirRoot directory where to generate aggregated bundles (this directory will be added as resources of the project).- Since:
- 1.0.0
-
bundleOutputPackage
@Parameter(property="i18n.bundleOutputPackage", defaultValue="META-INF", required=true) protected java.lang.String bundleOutputPackagePackage name of the generate aggregated bundles. Note: By default we use theMETA-INFpackage since it is the favorite package ofI18nruntime 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
-
bundleOutputName
@Parameter(property="i18n.bundleOutputName", defaultValue="${project.artifactId}-i18n", required=true) protected java.lang.String bundleOutputNameName of the bundle to generate.- Since:
- 1.0.2
-
generateDefaultLocale
@Parameter(property="i18n.generateDefaultLocale", defaultValue="false") protected boolean generateDefaultLocaleA flag to generate a bundle with the first locale defined as a default bundle (with no locale specialization).- Since:
- 2.1
-
checkBundle
@Parameter(property="i18n.checkBundle", defaultValue="true") protected boolean checkBundleA flag to check that bundles are complete (no missing i18n translations). Note : This behaviour will be activated isfailsIfWarningis on.- Since:
- 1.0.0
-
showEmpty
@Parameter(property="i18n.showEmpty", defaultValue="false") protected boolean showEmptyA flag to show missing i18n translation. Note : Need thecheckBundleto be activated).- Since:
- 1.0.0
-
failsIfWarning
@Parameter(property="i18n.failsIfWarning", defaultValue="false") @Deprecated protected boolean failsIfWarningDeprecated.since 3.6.1, prefer use nowfailsIfAnyKeyMissingValueorfailsIfAnyKeyMissingInBundle.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
-
failsIfAnyKeyMissingValue
@Parameter(property="i18n.failsIfAnyKeyMissingValue", defaultValue="false") protected boolean failsIfAnyKeyMissingValueA flag to make the build fails if there is some missing key values. Note : This parameter should be used in a release profile to ensure bundles are complete.- Since:
- 3.6.1
-
failsIfAnyKeyMissingInBundle
@Parameter(property="i18n.failsIfAnyKeyMissingInBundle", defaultValue="false") protected boolean failsIfAnyKeyMissingInBundleA flag to make the build fails if there is some missing keys. Note : This parameter should be used in a release profile to ensure bundles are complete.- Since:
- 3.6.1
-
bundleValidation
Contains validation result afterAbstractI18nMojo.checkBundle(Locale, Properties, boolean, BundleValidation). May be null if validation is disabled.- Since:
- 3.5
-
outputFolder
protected java.io.File outputFolderThe definitive directory where to generate the bundles (includes the package of bundle).- Since:
- 2.3.2
-
generateDefinitionFile
@Parameter(property="i18n.generateDefinitionFile", defaultValue="true") protected boolean generateDefinitionFileA flag to generate the i18n definition file. This file contains all generated bundles and the paths of all i18n artifacts used to make it.- Since:
- 2.0
-
generateCsvFile
@Parameter(property="i18n.generateCsvFile", defaultValue="false") @Deprecated protected boolean generateCsvFileDeprecated.since 3.3, prefer use the new mojo generate-csv-bundle insteadA flag to generate the i18n csv file wich contains all translation for all locales. Useful to translate from a language to another one.- Since:
- 2.5
-
bundleCsvFile
@Parameter(property="i18n.bundleCsvFile", defaultValue="${basedir}/target/${project.artifactId}-i18n.csv") @Deprecated protected java.io.File bundleCsvFileDeprecated.since 3.3, prefer use the new mojo generate-csv-bundle insteadLocation of the csv file to generate if parametergenerateCsvFileis on.- Since:
- 2.5
-
bundleCsvSeparator
@Parameter(property="i18n.bundleCsvSeparator", defaultValue="\t") @Deprecated protected java.lang.String bundleCsvSeparatorDeprecated.since 3.3, prefer use the new mojo generate-csv-bundle insteadChar separator used when generating the csv bundle file if parametergenerateCsvFileis on.- Since:
- 2.5
-
bundleFormatConverter
@Parameter(property="i18n.bundleFormatConverter") protected java.lang.String bundleFormatConverterConverter used to change format of bundles.- Since:
- 2.4
-
bundleFormatConverters
@Component(role=BundleFormatConverter.class) protected java.util.Map<java.lang.String,BundleFormatConverter> bundleFormatConvertersMap of all availablesBundleFormatConverter.- Since:
- 2.4
-
converter
Format converter to apply if
-
-
Constructor Details
-
BundleMojo
public BundleMojo()
-
-
Method Details
-
init
public void init() throws java.lang.Exception- Overrides:
initin classAbstractI18nMojo- Throws:
java.lang.Exception
-
doAction
protected void doAction() throws java.lang.Exception- Specified by:
doActionin classorg.nuiton.plugin.AbstractPlugin- Throws:
java.lang.Exception
-
getBundleFile
protected java.io.File getBundleFile(java.io.File root, java.lang.String artifactId, java.util.Locale locale, boolean create) throws java.io.IOException- Throws:
java.io.IOException
-
generateDefinitionFile
protected void generateDefinitionFile(java.lang.String version, java.util.Map<java.util.Locale,java.lang.String> bundleDico) throws java.io.IOException- Throws:
java.io.IOException
-
getCollectI18nResources
protected java.net.URL[] getCollectI18nResources(java.util.Locale locale) throws java.io.IOExceptionDescription copied from class:AbstractI18nBundleMojoPour obtenir les urls des fichiers i18n d'un projet (avec recherche dans ses dépendances). Note: L'ordre des urls reflète l'ordre des dépendances.- Specified by:
getCollectI18nResourcesin classAbstractI18nBundleMojo- Parameters:
locale- la locale a traiter- Returns:
- les urls des bundles i18n detectees pour le projet.
- Throws:
java.io.IOException
-
applyConversion
protected void applyConversion(java.util.Properties properties)Apply conversion overpropertieswith internal converter.- Parameters:
properties- Properties to walk through- Since:
- 2.4
-
generateCsvFile
protected void generateCsvFile() throws java.io.IOExceptionGenerates a csv file with all translations. First column is key, second is first locale translation, ...- Throws:
java.io.IOException- if any IO problem while the copy.- Since:
- 2.5
-
generateDefaultBundle
protected void generateDefaultBundle() throws java.io.IOExceptionGenerates 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:
java.io.IOException- if any IO problem while the copy.- Since:
- 2.1
-
getBundleOutputFolder
protected java.io.File getBundleOutputFolder() -
getBundleOutputEncoding
public java.lang.String getBundleOutputEncoding() -
getBundleInputEncoding
public java.lang.String getBundleInputEncoding()
-