From 4d65fc9160a5eaf195723ca51127adb759d2e55c Mon Sep 17 00:00:00 2001 From: "Marc R. Hoffmann" Date: Fri, 16 Apr 2021 10:56:18 +0200 Subject: [PATCH] WIP: Use Enum type instead of strings. --- .../org/jacoco/maven/AbstractReportMojo.java | 12 +++---- .../src/org/jacoco/maven/ReportFormat.java | 35 +++++++++++++++++++ 2 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 jacoco-maven-plugin/src/org/jacoco/maven/ReportFormat.java diff --git a/jacoco-maven-plugin/src/org/jacoco/maven/AbstractReportMojo.java b/jacoco-maven-plugin/src/org/jacoco/maven/AbstractReportMojo.java index ce63ed8903..82e9e3383c 100644 --- a/jacoco-maven-plugin/src/org/jacoco/maven/AbstractReportMojo.java +++ b/jacoco-maven-plugin/src/org/jacoco/maven/AbstractReportMojo.java @@ -34,10 +34,6 @@ public abstract class AbstractReportMojo extends AbstractMojo implements MavenMultiPageReport { - static final String REPORT_XML = "XML"; - static final String REPORT_HTML = "HTML"; - static final String REPORT_CSV = "CSV"; - /** * Encoding of the generated reports. */ @@ -49,7 +45,7 @@ public abstract class AbstractReportMojo extends AbstractMojo * CSV. Defaults to all formats if no values are given */ @Parameter - List formats; + List formats; /** * Name of the root node HTML report pages. @@ -207,17 +203,17 @@ private void addFormatters(final ReportSupport support, final Locale locale) footer, locale); } else { getOutputDirectory().mkdirs(); - if (formats.contains(REPORT_CSV)) { + if (formats.contains(ReportFormat.CSV)) { support.addCsvFormatter( new File(getOutputDirectory(), "jacoco.csv"), outputEncoding); } - if (formats.contains(REPORT_XML)) { + if (formats.contains(ReportFormat.XML)) { support.addXmlFormatter( new File(getOutputDirectory(), "jacoco.xml"), outputEncoding); } - if (formats.contains(REPORT_HTML)) { + if (formats.contains(ReportFormat.HTML)) { support.addHtmlFormatter(getOutputDirectory(), outputEncoding, footer, locale); } diff --git a/jacoco-maven-plugin/src/org/jacoco/maven/ReportFormat.java b/jacoco-maven-plugin/src/org/jacoco/maven/ReportFormat.java new file mode 100644 index 0000000000..538de54dcb --- /dev/null +++ b/jacoco-maven-plugin/src/org/jacoco/maven/ReportFormat.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors + * This program and the accompanying materials are made available under + * the terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Marc R. Hoffmann - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.maven; + +/** + * Configurable output formats for the report goals. + */ +public enum ReportFormat { + + /** + * Multi-page html report. + */ + HTML, + + /** + * Single-file XML report. + */ + XML, + + /** + * Single-file CSV report. + */ + CSV + +}