diff --git a/src/main/java/org/apache/maven/plugins/invoker/InvokerReportRenderer.java b/src/main/java/org/apache/maven/plugins/invoker/InvokerReportRenderer.java index eae9739b..3958a0a2 100644 --- a/src/main/java/org/apache/maven/plugins/invoker/InvokerReportRenderer.java +++ b/src/main/java/org/apache/maven/plugins/invoker/InvokerReportRenderer.java @@ -18,10 +18,6 @@ */ package org.apache.maven.plugins.invoker; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.text.MessageFormat; -import java.text.NumberFormat; import java.util.List; import java.util.Locale; @@ -37,21 +33,6 @@ public class InvokerReportRenderer extends AbstractMavenReportRenderer { private final Log log; private final List buildJobs; - /** - * The number format used to print percent values in the report locale. - */ - private NumberFormat percentFormat; - - /** - * The number format used to print time values in the report locale. - */ - private NumberFormat secondsFormat; - - /** - * The format used to print build name and description. - */ - private MessageFormat nameAndDescriptionFormat; - public InvokerReportRenderer(Sink sink, I18N i18n, Locale locale, Log log, List buildJobs) { super(sink); this.i18n = i18n; @@ -84,11 +65,6 @@ private String formatI18nString(String key, Object... args) { @Override protected void renderBody() { - DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale); - percentFormat = new DecimalFormat(getI18nString("format.percent"), symbols); - secondsFormat = new DecimalFormat(getI18nString("format.seconds"), symbols); - nameAndDescriptionFormat = new MessageFormat(getI18nString("format.name_with_description")); - startSection(getTitle()); paragraph(getI18nString("description")); @@ -139,9 +115,9 @@ private void renderSectionSummary() { Integer.toString(totalFailures), Integer.toString(totalSkipped), (totalSuccess + totalFailures > 0) - ? percentFormat.format(totalSuccess / (float) (totalSuccess + totalFailures)) + ? formatI18nString("value.successrate", (totalSuccess / (float) (totalSuccess + totalFailures))) : "", - secondsFormat.format(totalTime) + formatI18nString("value.time", totalTime) }); endTable(); @@ -175,7 +151,7 @@ private void renderBuildJob(BuildJob buildJob) { getBuildJobReportName(buildJob), // FIXME image buildJob.getResult(), - secondsFormat.format(buildJob.getTime()), + formatI18nString("value.time", buildJob.getTime()), buildJob.getFailureMessage() }); } @@ -187,7 +163,7 @@ private String getBuildJobReportName(BuildJob buildJob) { boolean emptyJobDescription = buildJobDescription == null || buildJobDescription.isEmpty(); boolean isReportJobNameComplete = !emptyJobName && !emptyJobDescription; if (isReportJobNameComplete) { - return getFormattedName(buildJobName, buildJobDescription); + return formatI18nString("text.name_with_description", buildJobName, buildJobDescription); } else { String buildJobProject = buildJob.getProject(); if (!emptyJobName) { @@ -203,8 +179,4 @@ private static String incompleteNameWarning(String missing, String pom) { return "Incomplete job name-description: " + missing + " is missing. POM (" + pom + ") will be used in place of job name!"; } - - private String getFormattedName(String name, String description) { - return nameAndDescriptionFormat.format(new Object[] {name, description}); - } } diff --git a/src/main/resources/invoker-report.properties b/src/main/resources/invoker-report.properties index e746c3ef..9753d833 100644 --- a/src/main/resources/invoker-report.properties +++ b/src/main/resources/invoker-report.properties @@ -30,6 +30,10 @@ report.invoker.detail.name=Name report.invoker.detail.result=Result report.invoker.detail.time=Time report.invoker.detail.message=Message -report.invoker.format.percent=0.0% -report.invoker.format.seconds=0.0\u00A0s -report.invoker.format.name_with_description={0}: {1} +report.invoker.value.successrate={0,choice,0#0%|0.0<{0,number,0.0%}|1#{0,number,0%}} +# Rationale: The idea is to always display four digits for visually consistent output +# Important: +# * Keep in sync with org.apache.maven.plugins.invoker.AbstractInvokerMojo +# * Needs to be copied into other bundles only if non-Latin script is used +report.invoker.value.time={0,choice,0#0|0.0<{0,number,0.000}|10#{0,number,0.00}|100#{0,number,0.0}|1000#{0,number,0}} s +report.invoker.text.name_with_description={0}: {1} diff --git a/src/main/resources/invoker-report_de.properties b/src/main/resources/invoker-report_de.properties index 41e030be..ed617c34 100644 --- a/src/main/resources/invoker-report_de.properties +++ b/src/main/resources/invoker-report_de.properties @@ -29,4 +29,4 @@ report.invoker.detail.name=Name report.invoker.detail.result=Ergebnis report.invoker.detail.time=Zeit report.invoker.detail.message=Meldung -report.invoker.format.percent=0.0\u00A0% +report.invoker.value.successrate={0,choice,0#0 %|0.0<{0,number,0.0 %}|1#{0,number,0 %}} diff --git a/src/main/resources/invoker-report_fr.properties b/src/main/resources/invoker-report_fr.properties index 7da545ad..75b52756 100644 --- a/src/main/resources/invoker-report_fr.properties +++ b/src/main/resources/invoker-report_fr.properties @@ -29,5 +29,5 @@ report.invoker.detail.name=Nom report.invoker.detail.result=R�sultat report.invoker.detail.time=Dur�e report.invoker.detail.message=Message -report.invoker.format.percent=0.0\u00A0% -report.invoker.format.name_with_description={0} : {1} +report.invoker.value.successrate={0,choice,0#0 %|0.0<{0,number,0.0 %}|1#{0,number,0 %}} +report.invoker.text.name_with_description={0} : {1}