#35: Ant attributes to specify the encoding of XML and HTML files.
diff --git a/org.jacoco.ant/src/org/jacoco/ant/ReportTask.java b/org.jacoco.ant/src/org/jacoco/ant/ReportTask.java
index f056164..99b5cae 100644
--- a/org.jacoco.ant/src/org/jacoco/ant/ReportTask.java
+++ b/org.jacoco.ant/src/org/jacoco/ant/ReportTask.java
@@ -152,6 +152,8 @@
private String footer = "";
+ private String encoding = "UTF-8";
+
/**
* Sets the output directory for the report.
*
@@ -173,10 +175,21 @@
this.footer = text;
}
+ /**
+ * Sets the output encoding for generated HTML files. Default is UTF-8.
+ *
+ * @param encoding
+ * output encoding
+ */
+ public void setEncoding(final String encoding) {
+ this.encoding = encoding;
+ }
+
public IReportFormatter createFormatter() {
final HTMLFormatter formatter = new HTMLFormatter();
formatter.setReportOutput(new FileReportOutput(destdir));
formatter.setFooterText(footer);
+ formatter.setOutputEncoding(encoding);
return formatter;
}
@@ -214,6 +227,8 @@
private File destdir;
+ private String encoding = "UTF-8";
+
/**
* Sets the output directory for the report.
*
@@ -224,10 +239,20 @@
this.destdir = destdir;
}
+ /**
+ * Sets the output encoding for generated XML file. Default is UTF-8.
+ *
+ * @param encoding
+ * output encoding
+ */
+ public void setEncoding(final String encoding) {
+ this.encoding = encoding;
+ }
+
public IReportFormatter createFormatter() {
final XMLFormatter formatter = new XMLFormatter();
formatter.setReportOutput(new FileReportOutput(destdir));
-
+ formatter.setOutputEncoding(encoding);
return formatter;
}
}
diff --git a/org.jacoco.doc/docroot/doc/ant.html b/org.jacoco.doc/docroot/doc/ant.html
index 170e1b3..470ba07 100644
--- a/org.jacoco.doc/docroot/doc/ant.html
+++ b/org.jacoco.doc/docroot/doc/ant.html
@@ -327,13 +327,46 @@
<td>Footer text for each report page.</td>
<td><i>No footer</i></td>
</tr>
+ <tr>
+ <td><code>encoding</code></td>
+ <td>Encoding of the generated HTML pages.</td>
+ <td><code>UTF-8</code></td>
+ </tr>
+ </tbody>
+</table>
+
+<h3>Element <code>xml</code></h3>
+
+<p>
+ Create a single-file report in XML format.
+</p>
+
+<table class="coverage">
+ <thead>
+ <tr>
+ <td>Attribute</td>
+ <td>Description</td>
+ <td>Default</td>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>destdir</code></td>
+ <td>Directory to create the report in.</td>
+ <td><i>none (required)</i></td>
+ </tr>
+ <tr>
+ <td><code>encoding</code></td>
+ <td>Encoding of the generated XML document.</td>
+ <td><code>UTF-8</code></td>
+ </tr>
</tbody>
</table>
<h3>Element <code>csv</code></h3>
<p>
- Create a multi-page report in CSV format.
+ Create single-file report in CSV format.
</p>
<table class="coverage">