Skip to content

Commit

Permalink
Generate kdoc for core vs test, only include kotlin sources (reactor#874
Browse files Browse the repository at this point in the history
)

- the `dokka` tasks are now per project, allowing for separate artifacts
- fixed the sourceDir + classpath issue: only kotlin classes are part of
the output (sourceDir), but links to java classes are valid (classpath)
- kdoc zips are named like javadoc jars (project-version-kdoc.zip)
  • Loading branch information
simonbasle authored Sep 21, 2017
1 parent edcc63b commit 87f6181
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 42 deletions.
94 changes: 84 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ if (project.hasProperty('platformVersion')) {
}
}


project('reactor-core') {
apply plugin: 'idea' //needed to avoid IDEA seeing the jmh folder as source
apply plugin: 'me.champeau.gradle.jmh'
Expand Down Expand Up @@ -250,7 +249,7 @@ project('reactor-core') {

javadoc {
dependsOn jar
group = "Reactor Core Javadoc"
group = "documentation"
description = "Generates aggregated Javadoc API documentation."
title = "Reactor Core $version"

Expand All @@ -267,12 +266,46 @@ project('reactor-core') {

maxMemory = "1024m"
destinationDir = new File(project.buildDir, "docs/javadoc")
source project.sourceSets.main.allJava
}

// Need https://github.com/Kotlin/dokka/issues/184 to be fixed to avoid "Can't find node by signature" log spam
task dokka(type: org.jetbrains.dokka.gradle.DokkaTask) {
dependsOn jar
group = "documentation"
description = "Generates Kotlin API documentation."
moduleName = "reactor-core"
jdkVersion = 8

outputFormat = "html"
outputDirectory = new File(project.buildDir, "docs/kdoc")

//this is needed so that links to java classes are resolved
doFirst {
classpath = files(project.sourceSets.main.compileClasspath)
classpath += project.jar.outputs.files.getFiles()
classpath += project.sourceSets.main.compileClasspath
}
//this is needed so that the kdoc only generates for kotlin classes
//(default kotlinTasks sourceSet also includes java)
kotlinTasks {

}
processConfigurations = []
sourceDirs = files("src/main/kotlin")

externalDocumentationLink {
url = new URL("http://projectreactor.io/docs/core/release/api/")
}
externalDocumentationLink {
url = new URL("http://www.reactive-streams.org/reactive-streams-1.0.1-javadoc/")
}
}

task kdocZip(type: Zip, dependsOn: dokka) {
//ends up similar to javadoc jar: reactor-core-3.1.0.RELEASE-kdoc.zip
classifier = 'kdoc'
from("${project.buildDir}/docs/kdoc")
}

task loops(type: Test) {
exclude '**/*'
include '**/*Loop.*'
Expand Down Expand Up @@ -305,6 +338,7 @@ project('reactor-core') {
archives sourcesJar
archives javadocJar
archives docsZip
archives kdocZip
}

jacocoTestReport.dependsOn testNG
Expand All @@ -328,13 +362,13 @@ project('reactor-test') {

javadoc {
dependsOn jar
group = "Reactor Test Javadoc"
group = "documentation"
description = "Generates aggregated Javadoc API documentation."
title = "Reactor Test $version"

options.addStringOption('charSet', 'UTF-8')

options.memberLevel = org.gradle.external.javadoc.JavadocMemberLevel.PROTECTED
options.memberLevel = JavadocMemberLevel.PROTECTED
options.author = true
options.header = "$project.name"
options.stylesheetFile = file("$rootDir/src/api/stylesheet.css")
Expand All @@ -345,12 +379,52 @@ project('reactor-test') {

maxMemory = "1024m"
destinationDir = new File(project.buildDir, "docs/javadoc")
source project.sourceSets.main.allJava
}

// Need https://github.com/Kotlin/dokka/issues/184 to be fixed to avoid "Can't find node by signature" log spam
task dokka(type: org.jetbrains.dokka.gradle.DokkaTask) {
dependsOn jar
group = "documentation"
description = "Generates Kotlin API documentation."
moduleName = "reactor-test"
jdkVersion = 8

outputFormat = "html"
outputDirectory = new File(project.buildDir, "docs/kdoc")

//this is needed so that links to java classes are resolved
doFirst {
classpath = files(project.sourceSets.main.compileClasspath)
classpath += project.jar.outputs.files.getFiles()
classpath += project.sourceSets.main.compileClasspath
}
//this is needed so that the kdoc only generates for kotlin classes
//(default kotlinTasks sourceSet also includes java)
kotlinTasks {

}
processConfigurations = []
sourceDirs = files("src/main/kotlin")

externalDocumentationLink {
url = new URL("http://projectreactor.io/docs/core/release/api/")
}
externalDocumentationLink {
url = new URL("http://projectreactor.io/docs/test/release/api/")
}
externalDocumentationLink {
url = new URL("http://www.reactive-streams.org/reactive-streams-1.0.1-javadoc/")
}
}

task kdocZip(type: Zip, dependsOn: dokka) {
//ends up similar to javadoc jar: reactor-test-3.1.0.RELEASE-kdoc.zip
classifier = 'kdoc'
from("${project.buildDir}/docs/kdoc")
}

artifacts {
archives kdocZip
}
}

assemble.dependsOn docsZip
assemble.dependsOn kdocZip
assemble.dependsOn docsZip
32 changes: 0 additions & 32 deletions gradle/doc.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,38 +40,6 @@ configure(rootProject) {
}
}

// Need https://github.com/Kotlin/dokka/issues/184 to be fixed to avoid "Can't find node by signature" log spam
dokka {
dependsOn {
subprojects.collect {
it.tasks.getByName("jar")
}
}
doFirst {
classpath = subprojects.collect { project -> project.jar.outputs.files.getFiles() }.flatten()
classpath += files(subprojects.collect { it.sourceSets.main.compileClasspath })
}
moduleName = "reactor-core"
outputFormat = "html"
outputDirectory = "$buildDir/reactor-code/build/kdoc"

processConfigurations = []
sourceDirs = files (subprojects.collect {
p -> return "$rootProject.rootDir/${p.name}/src/main/kotlin"
})
externalDocumentationLink {
url = new URL("http://projectreactor.io/docs/core/release/api/")
}
externalDocumentationLink {
url = new URL("http://www.reactive-streams.org/reactive-streams-1.0.1-javadoc/")
}
}

task kdocZip(type: Zip, dependsOn: dokka) {
baseName = 'reactor-core-kdoc'
from("$buildDir/reactor-code/build/kdoc")
}

task docsZip(type: Zip, dependsOn: asciidoctor) {
baseName = 'reactor-core-docs'
from("$buildDir/reactor-code/build/asciidoc/pdf/reactor-core-reference-guide-${version}.pdf") { into ("docs/") }
Expand Down

0 comments on commit 87f6181

Please sign in to comment.