branch develop updated (ac83866 -> 0683356)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository i18n. See https://gitlab.nuiton.org/nuiton/i18n.git from ac83866 Mise en conformité de la version SNAPSHOT avec la version prévue dans la forge new 0683356 Add failsIfWarning on gen mojo The 1 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 068335644dcfee4ac5699a0a89a83b9fbd37dbd6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Aug 28 12:10:37 2016 +0200 Add failsIfWarning on gen mojo Summary of changes: .../org/nuiton/i18n/plugin/AbstractI18nMojo.java | 18 ++++++++++++++++ .../java/org/nuiton/i18n/plugin/GenerateMojo.java | 24 +++++++++++++++++++++- .../org/nuiton/i18n/plugin/bundle/BundleMojo.java | 19 +---------------- 3 files changed, 42 insertions(+), 19 deletions(-) -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository i18n. See https://gitlab.nuiton.org/nuiton/i18n.git commit 068335644dcfee4ac5699a0a89a83b9fbd37dbd6 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Aug 28 12:10:37 2016 +0200 Add failsIfWarning on gen mojo --- .../org/nuiton/i18n/plugin/AbstractI18nMojo.java | 18 ++++++++++++++++ .../java/org/nuiton/i18n/plugin/GenerateMojo.java | 24 +++++++++++++++++++++- .../org/nuiton/i18n/plugin/bundle/BundleMojo.java | 19 +---------------- 3 files changed, 42 insertions(+), 19 deletions(-) diff --git a/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java b/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java index 11663c3..8dccd47 100644 --- a/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java +++ b/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/AbstractI18nMojo.java @@ -26,6 +26,7 @@ package org.nuiton.i18n.plugin; import org.apache.maven.execution.MavenSession; +import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.nuiton.i18n.I18nUtil; @@ -214,4 +215,21 @@ public abstract class AbstractI18nMojo extends AbstractPlugin implements PluginW public void setEncoding(String encoding) { this.encoding = encoding; } + + protected void failsIfWarning(boolean failsIfWarning, BundleValidation bundleValidation) throws MojoFailureException { + if (!failsIfWarning) { + + // no check + return; + } + + if (bundleValidation != null && bundleValidation.isFail()) { + + // there is at least one not complete bundle, faisl the build + throw new MojoFailureException( + "Bundles for locale(s) " + bundleValidation.getKeysMissingValues().keySet() + + " are not complete. Use the -Di18n.showEmpty to see " + + "missing translations."); + } + } } diff --git a/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java b/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java index 22c6bd9..93706ed 100644 --- a/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java +++ b/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/GenerateMojo.java @@ -25,10 +25,13 @@ package org.nuiton.i18n.plugin; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Maps; import org.apache.maven.plugins.annotations.Execute; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; +import org.nuiton.i18n.plugin.bundle.BundleValidation; import org.nuiton.io.SortedProperties; import java.io.File; @@ -86,6 +89,18 @@ public class GenerateMojo extends AbstractI18nGenerateMojo { protected boolean showEmpty; /** + * A flag to make the build fails if there is some warnings happens while generating bundle + * (says when it misses some translations). + * + * <b>Note :</b> This parameter should be used in a release profile to + * ensure bundles are complete. + * + * @since 3.5.1 + */ + @Parameter(property = "i18n.failsIfWarning", defaultValue = "false") + protected boolean failsIfWarning; + + /** * To keep a backup of old i18n bundles (suffiex by a {@code ~}). * * <b>Note: </b> By default, this property is not active. @@ -172,7 +187,14 @@ public class GenerateMojo extends AbstractI18nGenerateMojo { } if (checkBundle) { - checkBundle(locale, propertiesOut, showEmpty, null); + + BundleValidation bundleValidation = new BundleValidation(locales); + ImmutableSet<String> keys = Maps.fromProperties(propertiesOut).keySet(); + bundleValidation.getKeysPerLocale().putAll(locale, keys); + + checkBundle(locale, propertiesOut, showEmpty, bundleValidation); + failsIfWarning(failsIfWarning, bundleValidation); + } if (genSrc) { diff --git a/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java b/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java index 7a4e5a8..69c2925 100644 --- a/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java +++ b/i18n-maven-plugin/src/main/java/org/nuiton/i18n/plugin/bundle/BundleMojo.java @@ -443,7 +443,7 @@ public class BundleMojo extends AbstractI18nBundleMojo { } } - failsIfWarning(); + failsIfWarning(failsIfWarning, bundleValidation); if (generateDefaultLocale) { generateDefaultBundle(); @@ -585,23 +585,6 @@ public class BundleMojo extends AbstractI18nBundleMojo { } } - protected void failsIfWarning() throws MojoFailureException { - if (!failsIfWarning) { - - // no check - return; - } - - if (bundleValidation != null && bundleValidation.isFail()) { - - // there is at least one not complete bundle, faisl the build - throw new MojoFailureException( - "Bundles for locale(s) " + bundleValidation.getKeysMissingValues().keySet() + - " are not complete. Use the -Di18n.showEmpty to see " + - "missing translations."); - } - } - /** * Generates the default bundle, says the bundle with no locale specialized. * -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.
participants (1)
-
nuiton.org scm