Skip to content

Handle javadoc option "--allow-script-in-comments" #1393

@mnlipp

Description

@mnlipp

Context

Java 8 update 121 has introduced a new Javadoc option "--allow-script-in-comments" that must be specified if the HTML to be inserted e.g. as "bottom" contains JavaScript.

It is possible to add this to the javadoc task as options.addBooleanOption("-allow-script-in-comments", true). The problem is that this will only work if the java version used for the build is actually greater than Java 8 update 121. Which leads to this workaround:

    def javaVersionMatcher =
        org.gradle.internal.jvm.Jvm.current() =~
        /(\d+)\.(\d+)\.(\d+)_(\d+) .*/
    if (javaVersionMatcher.matches()) {
        def major = javaVersionMatcher.group(1).toInteger()
        def minor = javaVersionMatcher.group(2).toInteger()
        def patch = javaVersionMatcher.group(3).toInteger()
        def build = javaVersionMatcher.group(4).toInteger()
        if (major > 1
            || major == 1 && minor > 8
            || major == 1 && minor == 8 && patch > 0
            || major == 1 && minor == 8 && patch == 0 && build >= 121) {
            options.addBooleanOption("-allow-script-in-comments", true)
        }
    }

(Note that I love gradle for allowing me to work around the problem!)

(16.2.2017: see simpler solution below.)

Expected Behavior

On the long run, the behavior from above should be implemented as some "special options" for the javadoc task.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions