Skip to content

Commit

Permalink
WIP: Use Enum type instead of strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
marchof committed Apr 16, 2021
1 parent f632c21 commit 4d65fc9
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 8 deletions.
12 changes: 4 additions & 8 deletions jacoco-maven-plugin/src/org/jacoco/maven/AbstractReportMojo.java
Expand Up @@ -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.
*/
Expand All @@ -49,7 +45,7 @@ public abstract class AbstractReportMojo extends AbstractMojo
* CSV. Defaults to all formats if no values are given
*/
@Parameter
List<String> formats;
List<ReportFormat> formats;

/**
* Name of the root node HTML report pages.
Expand Down Expand Up @@ -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);
}
Expand Down
35 changes: 35 additions & 0 deletions 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

}

0 comments on commit 4d65fc9

Please sign in to comment.