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
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 FileDeprecated.since 3.3, prefer use the new mojo generate-csv-bundle insteadprotected StringDeprecated.since 3.3, prefer use the new mojo generate-csv-bundle insteadprotected StringConverter used to change format of bundles.protected Map<String, BundleFormatConverter> Map of all availablesBundleFormatConverter.protected StringEncoding used to load any i18n property files.protected FileRoot directory where to generate aggregated bundles (this directory will be added as resources of the project).protected StringEncoding used to write any i18n property files.protected StringName of the bundle to generate.protected StringPackage name of the generate aggregated bundles.protected BundleValidationContains validation result afterAbstractI18nMojo.checkBundle(Locale, Properties, boolean, BundleValidation).protected booleanA flag to check that bundles are complete (no missing i18n translations).protected BundleFormatConverterFormat converter to apply ifprotected booleanA flag to make the build fails if there is some missing keys.protected booleanA flag to make the build fails if there is some missing key values.protected booleanDeprecated.since 3.6.1, prefer use nowfailsIfAnyKeyMissingValueorfailsIfAnyKeyMissingInBundle.protected booleanDeprecated.since 3.3, prefer use the new mojo generate-csv-bundle insteadprotected booleanA flag to generate a bundle with the first locale defined as a default bundle (with no locale specialization).protected booleanA flag to generate the i18n definition file.protected FileThe definitive directory where to generate the bundles (includes the package of bundle).protected booleanA 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, verboseFields inherited from interface org.apache.maven.plugin.Mojo
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyConversion(Properties properties) Apply conversion overpropertieswith internal converter.protected voiddoAction()protected voidGenerates a csv file with all translations.protected voidGenerates the default bundle, says the bundle with no locale specialized.protected voidgenerateDefinitionFile(String version, Map<Locale, String> bundleDico) protected FilegetBundleFile(File root, String artifactId, Locale locale, boolean create) protected Fileprotected URL[]getCollectI18nResources(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, setPluginContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.maven.plugin.Mojo
execute, getLog, setLog
-
Field Details
-
bundleInputEncoding
Encoding used to load any i18n property files. If not defined, will use theAbstractI18nMojo.encodingparameter.- Since:
- 2.4
-
bundleOutputEncoding
Encoding 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 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 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 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
The 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 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 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
Converter used to change format of bundles.- Since:
- 2.4
-
bundleFormatConverters
@Component(role=BundleFormatConverter.class) protected Map<String,BundleFormatConverter> bundleFormatConvertersMap of all availablesBundleFormatConverter.- Since:
- 2.4
-
converter
Format converter to apply if
-
-
Constructor Details
-
BundleMojo
public BundleMojo()
-
-
Method Details
-
init
- Overrides:
initin classAbstractI18nMojo- Throws:
Exception
-
doAction
- Specified by:
doActionin classorg.nuiton.plugin.AbstractPlugin- Throws:
Exception
-
getBundleFile
protected File getBundleFile(File root, String artifactId, Locale locale, boolean create) throws IOException - Throws:
IOException
-
generateDefinitionFile
protected void generateDefinitionFile(String version, Map<Locale, String> bundleDico) throws IOException- Throws:
IOException
-
getCollectI18nResources
Description 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:
IOException
-
applyConversion
Apply conversion overpropertieswith internal converter.- Parameters:
properties- Properties to walk through- Since:
- 2.4
-
generateCsvFile
Generates a csv file with all translations. First column is key, second is first locale translation, ...- Throws:
IOException- if any IO problem while the copy.- Since:
- 2.5
-
generateDefaultBundle
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
-
getBundleOutputEncoding
-
getBundleInputEncoding
-