/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
 */

// make sure Java plugin is applied
apply plugin : 'java'

apply from: rootProject.file( 'gradle/base-information.gradle' )

javadoc {
    exclude( "**/internal/*" )
    exclude( "**/generated-src/**" )

    final int currentYear = new GregorianCalendar().get( Calendar.YEAR )

    configure( options ) {
        // this is the config needed to use asciidoclet for Javadoc rendering.  It relies on a build from John's PR @ https://github.com/asciidoctor/asciidoclet/pull/91
        // however, the PR does not work for me in that Javadocs with `@asciidoclet` are not rendered using asciidoc(tor/let).  Also tried the preferable `@asciidoc`
        // with the same result.  Leaving all this config in place however as the outcome is the same as not enabling it.
        // todo (6.0) : need to find out why the asciidoclet PR does not work
        //
        // Travis CI JDK 11 build did not like this
//		docletpath = configurations.asciidoclet.files.asType(List)
//		doclet = 'org.asciidoctor.Asciidoclet'
        windowTitle = "$project.name JavaDocs"
        docTitle = "$project.name JavaDocs ($project.version)"
        bottom = "Copyright &copy; 2001-$currentYear <a href=\"https://redhat.com\">Red Hat, Inc.</a>  All Rights Reserved."
        use = true
        encoding = 'UTF-8'
        links += [
                'https://docs.oracle.com/en/java/javase/11/docs/api/',
                'https://jakarta.ee/specifications/platform/9/apidocs/'
        ]
        tags = [ "apiNote", 'implSpec', 'implNote', 'todo' ]

        addStringOption( 'Xdoclint:none', '-quiet' )

        tags(
                'todo:X"',
                'apiNote:a:"API Note:"',
                'implSpec:a:"Implementation Specification:"',
                'implNote:a:"Implementation Note:"'
        )
    }
}

task javadocJar(type: Jar) {
    from project.tasks.javadoc.outputs
    manifest {
        attributes(
                // Basic JAR manifest attributes
                'Specification-Title': project.name,
                'Specification-Version': project.version,
                'Specification-Vendor': 'Hibernate.org',
                'Implementation-Title': project.name,
                'Implementation-Version': project.version,
                'Implementation-Vendor': 'Hibernate.org',
                'Implementation-Vendor-Id': 'org.hibernate',
                'Implementation-Url': 'https://hibernate.org/orm',

                // Hibernate-specific JAR manifest attributes
                'Hibernate-VersionFamily': project.ormVersion.family,
                'Hibernate-JpaVersion': project.jakartaJpaVersion.name
        )
    }
    archiveClassifier.set( 'javadoc' )
}