corda/docs/build.gradle

81 lines
3.0 KiB
Groovy
Raw Permalink Normal View History

2019-01-29 13:21:02 +00:00
import org.apache.tools.ant.taskdefs.condition.Os
2019-01-28 17:32:29 +00:00
import java.nio.file.Files
apply plugin: 'org.jetbrains.dokka'
apply plugin: 'kotlin'
dependencies {
compile rootProject
}
def internalPackagePrefixes(sourceDirs) {
def prefixes = []
// Kotlin allows packages to deviate from the directory structure, but let's assume they don't:
sourceDirs.collect { sourceDir ->
sourceDir.traverse(type: groovy.io.FileType.DIRECTORIES) {
if (it.name == 'internal') {
prefixes.add sourceDir.toPath().relativize(it.toPath()).toString().replace(File.separator, '.')
}
}
}
prefixes
}
ext {
// TODO: Add '../client/jfx/src/main/kotlin' and '../client/mock/src/main/kotlin' if we decide to make them into public API
dokkaSourceDirs = files('../core/src/main/kotlin', '../client/rpc/src/main/kotlin', '../finance/workflows/src/main/kotlin', '../finance/contracts/src/main/kotlin', '../client/jackson/src/main/kotlin',
2019-01-29 13:21:02 +00:00
'../testing/test-utils/src/main/kotlin', '../testing/node-driver/src/main/kotlin')
internalPackagePrefixes = internalPackagePrefixes(dokkaSourceDirs)
}
dokka {
outputDirectory = file("${rootProject.rootDir}/docs/build/html/api/kotlin")
}
task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) {
outputFormat = "javadoc"
outputDirectory = file("${rootProject.rootDir}/docs/build/html/api/javadoc")
}
[dokka, dokkaJavadoc].collect {
it.configure {
moduleName = 'corda'
processConfigurations = ['compile']
sourceDirs = dokkaSourceDirs
includes = ['packages.md']
jdkVersion = 8
externalDocumentationLink {
url = new URL("http://fasterxml.github.io/jackson-core/javadoc/2.9/")
}
externalDocumentationLink {
url = new URL("https://docs.oracle.com/javafx/2/api/")
}
externalDocumentationLink {
url = new URL("http://www.bouncycastle.org/docs/docs1.5on/")
}
internalPackagePrefixes.collect { packagePrefix ->
packageOptions {
prefix = packagePrefix
suppress = true
}
}
}
}
task buildDocs(dependsOn: ['apidocs', 'makeDocs'])
task apidocs(dependsOn: ['dokka', 'dokkaJavadoc'])
2019-01-29 13:21:02 +00:00
task makeDocs(type: Exec) {
2019-02-06 12:49:47 +00:00
// 2 volumes are mounted:
// - the docs project to /opt/docs_builder, where docs building is executed
// - the rest of the projects in /opt, so that code references to other projects are valid
2019-01-29 13:21:02 +00:00
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
2019-02-06 12:49:47 +00:00
commandLine "docker", "run", "--rm", "-v", "${project.projectDir}:/opt/docs_builder", "-v", "${project.projectDir}/..:/opt", "corda/docs-builder:latest", "bash", "-c", "make-docsite.sh"
2019-01-29 13:21:02 +00:00
} else {
2019-02-06 12:49:47 +00:00
commandLine "bash", "-c", "docker run --rm --user \$(id -u):\$(id -g) -v ${project.projectDir}:/opt/docs_builder -v ${project.projectDir}/..:/opt corda/docs-builder:latest bash -c make-docsite.sh"
2019-01-28 17:32:29 +00:00
}
}
apidocs.shouldRunAfter makeDocs