branch develop updated (0683356 -> 547c033)
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 discards 0683356 Add failsIfWarning on gen mojo new 547c033 Add failsIfWarning on gen mojo (Fixes #4002) This update added new revisions after undoing existing revisions. That is to say, some revisions that were in the old version of the branch are not in the new version. This situation occurs when a user --force pushes a change and generates a repository containing something like this: * -- * -- B -- O -- O -- O (0683356) \ N -- N -- N refs/heads/develop (547c033) You should already have received notification emails for all of the O revisions, and so the following emails describe only the N revisions from the common base, B. Any revisions marked "omits" are not gone; other references still refer to them. Any revisions marked "discards" are gone forever. 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 547c033d27f0915e6c8e55e4c864a1efbb412766 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Aug 28 12:10:37 2016 +0200 Add failsIfWarning on gen mojo (Fixes #4002) Summary of changes: -- 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 547c033d27f0915e6c8e55e4c864a1efbb412766 Author: Tony CHEMIT <chemit@codelutin.com> Date: Sun Aug 28 12:10:37 2016 +0200 Add failsIfWarning on gen mojo (Fixes #4002) --- .../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