Class BundleMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.nuiton.plugin.AbstractPlugin
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
  • Field Details

    • bundleInputEncoding

      @Parameter(property="i18n.bundleInputEncoding") protected java.lang.String bundleInputEncoding
      Encoding used to load any i18n property files. If not defined, will use the AbstractI18nMojo.encoding parameter.
      Since:
      2.4
    • bundleOutputEncoding

      @Parameter(property="i18n.bundleOutputEncoding") protected java.lang.String bundleOutputEncoding
      Encoding used to write any i18n property files. If not defined, will use the AbstractI18nMojo.encoding parameter.
      Since:
      2.4
    • bundleOutputDir

      @Parameter(property="i18n.bundleOutputDir", defaultValue="${basedir}/target/generated-sources/resources", required=true) protected java.io.File bundleOutputDir
      Root 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 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
    • bundleOutputName

      @Parameter(property="i18n.bundleOutputName", defaultValue="${project.artifactId}-i18n", required=true) protected java.lang.String bundleOutputName
      Name of the bundle to generate.
      Since:
      1.0.2
    • generateDefaultLocale

      @Parameter(property="i18n.generateDefaultLocale", defaultValue="false") 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
    • checkBundle

      @Parameter(property="i18n.checkBundle", defaultValue="true") 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
    • showEmpty

      @Parameter(property="i18n.showEmpty", defaultValue="false") protected boolean showEmpty
      A flag to show missing i18n translation. Note : Need the checkBundle to be activated).
      Since:
      1.0.0
    • failsIfWarning

      @Parameter(property="i18n.failsIfWarning", defaultValue="false") @Deprecated protected boolean failsIfWarning
      Deprecated.
      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 failsIfAnyKeyMissingValue
      A 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 failsIfAnyKeyMissingInBundle
      A 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

      protected BundleValidation bundleValidation
      Contains validation result after AbstractI18nMojo.checkBundle(Locale, Properties, boolean, BundleValidation). May be null if validation is disabled.
      Since:
      3.5
    • outputFolder

      protected java.io.File 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 generateDefinitionFile
      A 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 generateCsvFile
      Deprecated.
      since 3.3, prefer use the new mojo generate-csv-bundle instead
      A 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 bundleCsvFile
      Deprecated.
      since 3.3, prefer use the new mojo generate-csv-bundle instead
      Location of the csv file to generate if parameter generateCsvFile is on.
      Since:
      2.5
    • bundleCsvSeparator

      @Parameter(property="i18n.bundleCsvSeparator", defaultValue="\t") @Deprecated protected java.lang.String bundleCsvSeparator
      Deprecated.
      since 3.3, prefer use the new mojo generate-csv-bundle instead
      Char separator used when generating the csv bundle file if parameter generateCsvFile is on.
      Since:
      2.5
    • bundleFormatConverter

      @Parameter(property="i18n.bundleFormatConverter") protected java.lang.String bundleFormatConverter
      Converter used to change format of bundles.
      Since:
      2.4
    • bundleFormatConverters

      @Component(role=BundleFormatConverter.class) protected java.util.Map<java.lang.String,​BundleFormatConverter> bundleFormatConverters
      Map of all availables BundleFormatConverter.
      Since:
      2.4
    • converter

      protected BundleFormatConverter converter
      Format converter to apply if
  • Constructor Details

  • Method Details

    • init

      public void init() throws java.lang.Exception
      Overrides:
      init in class AbstractI18nMojo
      Throws:
      java.lang.Exception
    • doAction

      protected void doAction() throws java.lang.Exception
      Specified by:
      doAction in class org.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.IOException
      Description copied from class: AbstractI18nBundleMojo
      Pour 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:
      getCollectI18nResources in class AbstractI18nBundleMojo
      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 over properties with internal converter.
      Parameters:
      properties - Properties to walk through
      Since:
      2.4
    • generateCsvFile

      protected void generateCsvFile() throws java.io.IOException
      Generates 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.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:
      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()