简体   繁体   中英

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?

You'll want to set the javadoc charset option .

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

I'm using gradle 2.13+ and neither Mark's answer nor Arne's comment works for me.

However, I could fix it via addStringOption() :

javadoc {
    options.addStringOption("charset", "UTF-8")
}

See gradles Javadoc docs and the charset option from Javadoc for more details.

I'm using Gradle 2.1,and found the following configuration works for me .

tasks.withType(Javadoc) {
    options.encoding = 'UTF-8'
}

For me works this:

javadoc {
    options.addStringOption('encoding', 'UTF-8')
}

In Gradle 3.3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM