groovydoc {
    use             = true
    source          = project.sourceSets.main.allSource
    classpath       = javadoc.classpath
    ext.windowtitle = "$project.name $project.version API"
    ext.doctitle    = "$project.name $project.version API"
    header          = "$project.name $project.version API"
    footer          = "Copyright &copy; ${copyrightYear} the original author or authors. All rights reserved."
    includePrivate  = false
    link "https://docs.gradle.org/${gradle.gradleVersion}/javadoc/", 'org.gradle.'
    link 'https://docs.oracle.com/javase/8/docs/api/', 'java.', 'org.xml.', 'javax.', 'org.w3c.'
}

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

task sourcesJar(type: Jar) {
    group 'Build'
    description 'An archive of the source code'
    archiveClassifier.set('sources')
    from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: groovydoc) {
    group 'Build'
    description 'An archive of the javadoc'
    archiveClassifier.set('javadoc')
    from groovydoc.destinationDir
}

jar.finalizedBy sourcesJar
jar.finalizedBy javadocJar

artifacts {
    sourcesJar
    javadocJar
}

