Gradle Kotlin DSL: subdirectory for javadoc in jar file

Mathias :

I currently have the following configuration in my build.gradle.kts:

tasks.withType<Jar> {
    manifest {
        attributes["Multi-Release"] = "true"
    }
    from(sourceSets["main"].allSource)
    from(sourceSets["test"].allSource)
    from(tasks["javadoc"])
}

When I run the jar task, the generated javadoc html files are included in the exported jar. However, I want to include the javadoc in a subdirectory called "javadoc". How can I achieve this, i.e. change the output location of the generated javadoc?

Mathias :

I've just solved this as follows:

tasks.withType<Jar> {
    manifest {
        attributes["Multi-Release"] = "true"
    }
    from(sourceSets["main"].allSource)
    from(sourceSets["test"].allSource)
    {
        from(tasks["javadoc"]).into("/javadoc")
    }

}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=157280&siteId=1