javadoc {
    excludes = ['**/*.html', 'META-INF/**', '**/*.groovy']

    options.use         = true
    options.splitIndex  = true
    options.encoding    = 'UTF-8'
    options.author      = true
    options.version     = true
    options.windowTitle = "$project.name $project.version API"
    options.docTitle    = "$project.name $project.version API"
    options.links 'https://www.slf4j.org/apidocs/'
    options.links 'https://junit.org/junit4/javadoc/latest/'
    options.links 'https://aalmiray.github.io/jsr-305/apidocs/'
    options.links 'https://javax-inject.github.io/javax-inject/api/'
    options.links 'https://docs.oracle.com/javase/8/docs/api/'
    options.links 'https://docs.oracle.com/javase/8/javafx/api/'
    options.links 'https://aalmiray.github.io/jipsy/apidocs/'
    options.links 'https://aalmiray.github.io/gipsy/apidocs/'
    options.links 'http://griffon-framework.org/guide/latest/api/'

    doLast { task ->
        copy {
            into task.destinationDir
            from rootProject.file('src/javadoc/resources/img/griffon.ico'),
                rootProject.file('src/javadoc/resources/css/stylesheet.css')
        }
        copy {
            into file("${task.destinationDir}/resources")
            from rootProject.file('src/javadoc/resources/img/')
        }
    }
}

project.plugins.withId('groovy') {
    groovydoc {
        use = true
        source = project.sourceSets.main.allSource
        classpath = javadoc.classpath
        windowTitle = "$project.name $project.version API"
        docTitle = "$project.name $project.version API"
        header = "$project.name $project.version API"
        includePrivate = false

        link 'https://www.slf4j.org/apidocs/', 'org.slf4j.'
        link 'https://junit.org/junit4/javadoc/latest/', 'org.junit.', 'junit.'
        link 'https://aalmiray.github.io/jsr-305/apidocs/', 'javax.annotation.'
        link 'https://javax-inject.github.io/javax-inject/api/', 'javax.inject.'
        link 'https://docs.oracle.com/javase/8/docs/api/', 'java.', 'org.xml.', 'javax.', 'org.w3c.'
        link 'https://docs.oracle.com/javase/8/javafx/api/', 'javafx'
        link 'https://aalmiray.github.io/jipsy/apidocs/', 'org.kordamp.jipsy'
        link 'https://aalmiray.github.io/gipsy/apidocs/', 'org.kordamp.gipsy'
        link 'http://griffon-framework.org/guide/latest/api/', 'griffon.', 'org.codehaus.griffon.'

        doLast { task ->
            copy {
                into task.destinationDir
                from rootProject.file('src/javadoc/resources/img/griffon.ico')
                rename 'griffon.ico', 'groovy.ico'
            }
        }
    }
}