Edward Edward - 5 months ago 120
Java Question

How to set an encoding for the JavaDoc in gradle?

I have written Java-Classes with JavaDoc-commands that contain special characters like

äöü
. I generate the JavaDoc using a gradle build-file:

apply plugin: 'java'


and the in the commandline:
gradle javadoc
.

The encoding of the original files is UTF-8. The encoding of the JavaDoc files is also UTF-8. But there is no hint in the HTML-sources, that the files are UTF-8. Thats why my browser always thinks it is
ISO-8859
.

How can I tell javadoc (via gradle) to also add
<meta charset="utf-8"/>
to the source codes, when generating the JavaDoc?

Answer

You'll want to set the javadoc charset option.

javadoc {
    options.charSet = 'UTF-8'
}