nebula-plugins / gradle-aggregate-javadocs-plugin

Provides the ability to aggregate Javadocs across all projects in a multi-project build.
Apache License 2.0
25 stars 9 forks source link

Not emitting -tagletpath option #15

Open davidmichaelkarr opened 7 years ago

davidmichaelkarr commented 7 years ago

I would not be at all surprised that I'm doing something wrong, but here's what's happening.

I've written a custom javadoc taglet that is deployed to a GAV on our nexus server. I've specified the "tagletPath" option for the "javadoc" options block for my subprojects, and I did the same for the top-level "tasks.withType(Javadoc)" block. For now, the subproject javadoc block's "tagletPath" value is a little more complex than the top-level one, but I still can't get the top-level aggregateJavadocs tasks to emit a "-tagletpath" option at all. I verified that it's at least seeing the top-level block, as I gave the various header strings slightly different values, and I can see those resulting strings in the produced "javadoc.options" file.

The following is my entire top-level build.gradle file:

buildscript {
    repositories { jcenter() }

    dependencies {
        classpath 'com.netflix.nebula:gradle-aggregate-javadocs-plugin:2.2.+'
    }
}

apply plugin: 'nebula-aggregate-javadocs'

tasks.withType(Javadoc) {
    options {
        encoding    = "UTF-8"
        addStringOption('Xdoclint:none', '-quiet')
        addStringOption("Dorg.apache.logging.log4j.level=debug")
        taglets "com.att.det.taglet.ValidationConstraintsTaglet", "com.att.det.taglet.ValidationConstraintsCombinedTaglet"
        addStringOption("top").value  = "Unified Service Layer - top"
        bottom "Unified Service Layer - bottomxx"
        windowTitle "Unified Service Layer - windowtitlexx"
        docTitle "Unified Service Layer - titlexx"
        footer "Unified Service Layer - footerxx"
        header "Unified Service Layer - headerxx"
        setMemberLevel JavadocMemberLevel.PUBLIC
        afterEvaluate {
            tagletPath ((configurations.taglet.files) as File[])
        }
    }
}

allprojects  {
    apply plugin: 'maven'

    group = 'com.att.detsusl'
    version = '2.7.0-SNAPSHOT'
}

configurations {
    taglet
}

dependencies {
    taglet "com.att.detsusl.taglets:validationJavadocTaglet:0.0.1-SNAPSHOT"
}

subprojects {
    apply plugin: 'java'

    sourceCompatibility = 1.8
    targetCompatibility = 1.8

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

    repositories {
        mavenLocal()

        maven { url "http://mavencentral.it.att.com:8084/nexus/content/repositories/att-public-group/" }
        maven { url "http://mavencentral.it.att.com:8084/nexus/content/repositories/att-repository-snapshots" }
        maven { url "http://repo.maven.apache.org/maven2" }
    }

    configurations {
        taglet
    }

    dependencies {
        compile "org.apache.commons:commons-lang3:3.5"
        compile "commons-lang:commons-lang:2.6"
        ["jackson-annotations", "jackson-core", "jackson-databind"].each {
            compile "com.fasterxml.jackson.core:$it:2.8.3"
        }
        compile "com.google.code.gson:gson:2.8.0"
        compile "log4j:log4j:1.2.17"
        compile "org.apache.aries.blueprint:org.apache.aries.blueprint.annotation.api:1.0.0"
        compile "org.apache.aries.blueprint:org.apache.aries.blueprint.api:1.0.0"

        compile "com.sun.xml.bind:jaxb-core:2.2.11"
        compile "com.sun.xml.bind:jaxb-impl:2.2.11"

        compile "org.springframework:spring-context:4.2.5.RELEASE"

        taglet "com.att.detsusl.taglets:validationJavadocTaglet:0.0.1-SNAPSHOT"

        ["pax-exam", "pax-exam-container-karaf", "pax-exam-junit4"].each {
            testCompile "org.ops4j.pax.exam:$it:4.9.1"
        }
        testCompile "org.powermock:powermock-api-mockito:1.6.6"
        testCompile "org.assertj:assertj-core:3.6.2"
        testCompile "commons-jxpath:commons-jxpath:1.3"
    }

    test {
        exclude '**/*IT.*'
        exclude '**/*PaxConfigurer.*'
    }

    test {
        testLogging {
            showStandardStreams = true
        }
    }

    if (!(project.name in ["javadoc-aggregate"])) {  
        javadoc {
            options {
                encoding = 'UTF-8'
                addStringOption("top").value  = "Unified Service Layer - top"
                bottom "Unified Service Layer - bottom"
                windowTitle "Unified Service Layer - windowtitle"
                docTitle "Unified Service Layer - title"
                footer "Unified Service Layer - footer"
                header "Unified Service Layer - header"
                setMemberLevel JavadocMemberLevel.PUBLIC
                addStringOption('Xdoclint:none', '-quiet')

                taglets "com.att.det.taglet.ValidationConstraintsTaglet", "com.att.det.taglet.ValidationConstraintsCombinedTaglet"

                afterEvaluate {
                    tagletPath ((configurations.taglet.files + sourceSets.main.output) as File[])
                }
            }
        }
    }
}

When I ran the build, I then inspected the resulting "javadoc.options" files, both in one of the subprojects, and the one in the root.

This is an excerpt of the file from one of the subprojects:

-doctitle 'Unified Service Layer - title'
-encoding 'UTF-8'
-footer 'Unified Service Layer - footer'
-header 'Unified Service Layer - header'
-public 
-quiet 
-taglet 'com.att.det.taglet.ValidationConstraintsTaglet'
-taglet 'com.att.det.taglet.ValidationConstraintsCombinedTaglet'
-tagletpath 'C:\\Users\\...'
-top 'Unified Service Layer - top'

This is a similar excerpt, except from the top-level build, where I ran "aggregateJavadocs":

-doctitle 'Unified Service Layer - titlexx'
-encoding 'UTF-8'
-footer 'Unified Service Layer - footerxx'
-header 'Unified Service Layer - headerxx'
-public 
-quiet 
-taglet 'com.att.det.taglet.ValidationConstraintsTaglet'
-taglet 'com.att.det.taglet.ValidationConstraintsCombinedTaglet'
-top 'Unified Service Layer - top'

Notice the slightly different header values, but the missing "tagletpath" option.

I inspected the code for this plugin, and I don't understand how this could happen.

davidmichaelkarr commented 7 years ago

Anyone home? My effort to convert this Maven build to Gradle is at a standstill until I can solve this.

blindpirate commented 7 years ago

@davidmichaelkarr

This issue is probably due to the usage of

afterEvaluate {
            tagletPath ((configurations.taglet.files) as File[])
        }

You shouldn't use afterEvaluate.

When you apply gradle-aggregate-javadocs-plugin, it will register a clousre with projectsEvaluated here, just like you do with afterEvaluate. This is the interesting part: the closure gradle-aggregate-javadocs-plugin registered would be executed before your closure, so it couldn't see your tagletPath.

I don't know why you are using an afterEvaluate, but it may be the cause.

I've created an example to compare the usage with and without afterEvaluate here: https://github.com/blindpirate/multi-doc

Please let me know if this solves your question.

davidmichaelkarr commented 7 years ago

Thanks for the reply. I replied with more information on the forum. How about we keep the discussion there, and not duplicated, until we come to a conclusion, and then we can summarize here?