diff options
Diffstat (limited to 'runners/ant')
-rw-r--r-- | runners/ant/src/main/kotlin/ant/dokka.kt | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/runners/ant/src/main/kotlin/ant/dokka.kt b/runners/ant/src/main/kotlin/ant/dokka.kt index 38dc543b..e9cb35a2 100644 --- a/runners/ant/src/main/kotlin/ant/dokka.kt +++ b/runners/ant/src/main/kotlin/ant/dokka.kt @@ -5,10 +5,7 @@ import org.apache.tools.ant.Project import org.apache.tools.ant.Task import org.apache.tools.ant.types.Path import org.apache.tools.ant.types.Reference -import org.jetbrains.dokka.DocumentationOptions -import org.jetbrains.dokka.DokkaGenerator -import org.jetbrains.dokka.DokkaLogger -import org.jetbrains.dokka.SourceLinkDefinition +import org.jetbrains.dokka.* import java.io.File class AntLogger(val task: Task): DokkaLogger { @@ -19,10 +16,17 @@ class AntLogger(val task: Task): DokkaLogger { class AntSourceLinkDefinition(var path: String? = null, var url: String? = null, var lineSuffix: String? = null) -class DokkaAntTask(): Task() { +class AntSourceRoot(var path: String? = null, var platforms: String? = null) + +fun AntSourceRoot.toSourceRoot(): SourceRoot? = path?.let { + path -> SourceRoot(path, platforms?.split(',').orEmpty()) +} + +class DokkaAntTask: Task() { var moduleName: String? = null var outputDir: String? = null var outputFormat: String = "html" + var impliedPlatforms: String = "" var jdkVersion: Int = 6 var skipDeprecated: Boolean = false @@ -33,6 +37,7 @@ class DokkaAntTask(): Task() { val includesPath: Path by lazy { Path(getProject()) } val antSourceLinks: MutableList<AntSourceLinkDefinition> = arrayListOf() + val antSourceRoots: MutableList<AntSourceRoot> = arrayListOf() fun setClasspath(classpath: Path) { compileClasspath.append(classpath) @@ -68,8 +73,10 @@ class DokkaAntTask(): Task() { return def } + fun createSourceRoot(): AntSourceRoot = AntSourceRoot().apply { antSourceRoots.add(this) } + override fun execute() { - if (sourcePath.list().size == 0) { + if (sourcePath.list().isEmpty() && antSourceRoots.isEmpty()) { throw BuildException("At least one source path needs to be specified") } if (moduleName == null) { @@ -87,14 +94,15 @@ class DokkaAntTask(): Task() { val generator = DokkaGenerator( AntLogger(this), compileClasspath.list().toList(), - sourcePath.list().toList(), + sourcePath.list().map { SourceRoot(it) } + antSourceRoots.mapNotNull { it.toSourceRoot() }, samplesPath.list().toList(), includesPath.list().toList(), moduleName!!, DocumentationOptions(outputDir!!, outputFormat, skipDeprecated = skipDeprecated, sourceLinks = sourceLinks, - jdkVersion = jdkVersion) + jdkVersion = jdkVersion, + impliedPlatforms = impliedPlatforms.split(',')) ) generator.generate() } |