aboutsummaryrefslogtreecommitdiff
path: root/runners
diff options
context:
space:
mode:
authoraleksZubakov <aleks.zubakov@gmail.com>2018-08-13 21:52:23 +0300
committerZubakov Aleksey <aleks.zubakov@gmail.com>2018-08-17 13:00:32 +0300
commit2ae2363cec43b5300038065c943f9991d91c7b15 (patch)
tree5b5e0c76d2f20cc624393c642d3ec97a449fdf7f /runners
parenta838a096da246babd93dc518dec8d2470d1c14f5 (diff)
downloaddokka-2ae2363cec43b5300038065c943f9991d91c7b15.tar.gz
dokka-2ae2363cec43b5300038065c943f9991d91c7b15.tar.bz2
dokka-2ae2363cec43b5300038065c943f9991d91c7b15.zip
Ant runner mpp change
Diffstat (limited to 'runners')
-rw-r--r--runners/ant/src/main/kotlin/ant/dokka.kt231
-rw-r--r--runners/cli/build.gradle7
2 files changed, 147 insertions, 91 deletions
diff --git a/runners/ant/src/main/kotlin/ant/dokka.kt b/runners/ant/src/main/kotlin/ant/dokka.kt
index 4f629198..e1f85870 100644
--- a/runners/ant/src/main/kotlin/ant/dokka.kt
+++ b/runners/ant/src/main/kotlin/ant/dokka.kt
@@ -8,6 +8,7 @@ import org.apache.tools.ant.types.Reference
import org.jetbrains.dokka.*
import org.jetbrains.dokka.DokkaConfiguration.ExternalDocumentationLink
import java.io.File
+import java.io.IOException
class AntLogger(val task: Task): DokkaLogger {
override fun info(message: String) = task.log(message, Project.MSG_INFO)
@@ -25,47 +26,85 @@ class AntSourceRoot(var path: String? = null, var platforms: String? = null,
}
}
-class AntPackageOptions(
- override var prefix: String = "",
- override var includeNonPublic: Boolean = false,
- override var reportUndocumented: Boolean = true,
- override var skipDeprecated: Boolean = false,
- override var suppress: Boolean = false) : DokkaConfiguration.PackageOptions
-
-
-class DokkaAntTask: Task() {
- var moduleName: String? = null
- var outputDir: String? = null
- var outputFormat: String = "html"
- var impliedPlatforms: String = ""
- var jdkVersion: Int = 6
-
- var noStdlibLink: Boolean = false
- var noJdkLink: Boolean = false
+class BuildTarget(var name: String = "")
+
+class BuildPlatform(var name: String = "")
+
+class AntPassConfig(task: Task) : DokkaConfiguration.PassConfiguration {
+ override var moduleName: String = ""
+ override val classpath: List<String>
+ get() = buildClassPath.list().toList()
+
+ override val sourceRoots: List<DokkaConfiguration.SourceRoot>
+ get() = sourcePath.list().map { SourceRootImpl(it) } + rawSourceRoots
+
+ override val samples: List<String>
+ get() = samplesPath.list().toList()
+ override val includes: List<String>
+ get() = includesPath.list().toList()
+ override var includeNonPublic: Boolean = false
+ override var includeRootPackage: Boolean = false
+ override var reportUndocumented: Boolean = false
+ override var skipEmptyPackages: Boolean = false
+ override var skipDeprecated: Boolean = false
+ override var jdkVersion: Int = 6
+ override val sourceLinks: List<DokkaConfiguration.SourceLinkDefinition>
+ get() = buildAntSourceLinkDefinition.map {
+ val path = it.path ?: throw BuildException("'path' attribute of a <sourceLink> element is required")
+ val url = it.url ?: throw BuildException("'url' attribute of a <sourceLink> element is required")
+ SourceLinkDefinitionImpl(File(path).canonicalFile.absolutePath, url, it.lineSuffix)
+ }
+ override val perPackageOptions: MutableList<DokkaConfiguration.PackageOptions> = mutableListOf()
+ override val externalDocumentationLinks: List<ExternalDocumentationLink>
+ get() = buildExternalLinksBuilders.map { it.build() }
+
+ override var languageVersion: String? = null
+ override var apiVersion: String? = null
+ override var noStdlibLink: Boolean = false
+ override var noJdkLink: Boolean = false
+ override var suppressedFiles: MutableList<String> = mutableListOf()
+ override var collectInheritedExtensionsFromLibraries: Boolean = false
+ override var analysisPlatform: Platform = Platform.DEFAULT
+ override var targets: List<String> = listOf()
+ get() = buildTargets.filter { it.name != "" }
+ .map { it.name }
+
+ private val samplesPath: Path by lazy { Path(task.project) }
+ private val includesPath: Path by lazy { Path(task.project) }
+ private val buildClassPath: Path by lazy { Path(task.project) }
+ private val sourcePath: Path by lazy { Path(task.project) }
+ private val rawSourceRoots: MutableList<SourceRootImpl> = mutableListOf()
+
+ private val buildTargets: MutableList<BuildTarget> = mutableListOf()
+ private val buildExternalLinksBuilders: MutableList<ExternalDocumentationLink.Builder> = mutableListOf()
+ private val buildAntSourceLinkDefinition: MutableList<AntSourceLinkDefinition> = mutableListOf()
+
+ fun setSamples(ref: Reference) {
+ samplesPath.createPath().refid = ref
+ }
- var skipDeprecated: Boolean = false
+ fun setSamplesRef(ref: Reference) {
+ samplesPath.createPath().refid = ref
+ }
- var cacheRoot: String? = null
+ fun setInclude(ref: Reference) {
+ includesPath.createPath().refid = ref
+ }
- var languageVersion: String? = null
- var apiVersion: String? = null
+ fun setClasspath(classpath: Path) {
+ buildClassPath.append(classpath)
+ }
- val compileClasspath: Path by lazy { Path(getProject()) }
- val sourcePath: Path by lazy { Path(getProject()) }
- val samplesPath: Path by lazy { Path(getProject()) }
- val includesPath: Path by lazy { Path(getProject()) }
+ fun createPackageOptions(): AntPackageOptions = AntPackageOptions().apply { perPackageOptions.add(this) }
- val antSourceLinks: MutableList<AntSourceLinkDefinition> = arrayListOf()
- val antSourceRoots: MutableList<AntSourceRoot> = arrayListOf()
- val antPackageOptions: MutableList<AntPackageOptions> = arrayListOf()
- val antExternalDocumentationLinks = mutableListOf<ExternalDocumentationLink.Builder>()
+ fun createSourceRoot(): AntSourceRoot = AntSourceRoot().apply { this.toSourceRoot()?.let { rawSourceRoots.add(it) } }
- fun setClasspath(classpath: Path) {
- compileClasspath.append(classpath)
+ fun createTarget(): BuildTarget = BuildTarget().apply {
+ buildTargets.add(this)
}
fun setClasspathRef(ref: Reference) {
- compileClasspath.createPath().refid = ref
+ buildClassPath.createPath().refid = ref
}
fun setSrc(src: Path) {
@@ -76,74 +115,86 @@ class DokkaAntTask: Task() {
sourcePath.createPath().refid = ref
}
- fun setSamples(samples: Path) {
- samplesPath.append(samples)
- }
-
- fun setSamplesRef(ref: Reference) {
- samplesPath.createPath().refid = ref
- }
-
- fun setInclude(include: Path) {
- includesPath.append(include)
- }
-
fun createSourceLink(): AntSourceLinkDefinition {
val def = AntSourceLinkDefinition()
- antSourceLinks.add(def)
+ buildAntSourceLinkDefinition.add(def)
return def
}
- fun createSourceRoot(): AntSourceRoot = AntSourceRoot().apply { antSourceRoots.add(this) }
+ fun createExternalDocumentationLink() =
+ ExternalDocumentationLink.Builder().apply { buildExternalLinksBuilders.add(this) }
+
+}
+
+class AntPackageOptions(
+ override var prefix: String = "",
+ override var includeNonPublic: Boolean = false,
+ override var reportUndocumented: Boolean = true,
+ override var skipDeprecated: Boolean = false,
+ override var suppress: Boolean = false) : DokkaConfiguration.PackageOptions
+
+class DokkaAntTask: Task(), DokkaConfiguration {
- fun createPackageOptions(): AntPackageOptions = AntPackageOptions().apply { antPackageOptions.add(this) }
+ override var format: String = "html"
+ override var generateIndexPages: Boolean = false
+ override var outputDir: String = ""
+ override var impliedPlatforms: List<String> = listOf()
+ get() = buildImpliedPlatforms.map { it.name }.toList()
+ private val buildImpliedPlatforms: MutableList<BuildPlatform> = mutableListOf()
+
+ override var cacheRoot: String? = null
+ override val passesConfigurations: MutableList<AntPassConfig> = mutableListOf()
+
+ fun createPassConfig() = AntPassConfig(this).apply { passesConfigurations.add(this) }
+ fun createImpliedPlatform(): BuildPlatform = BuildPlatform().apply { buildImpliedPlatforms.add(this) }
- fun createExternalDocumentationLink() = ExternalDocumentationLink.Builder().apply { antExternalDocumentationLinks.add(this) }
override fun execute() {
- if (sourcePath.list().isEmpty() && antSourceRoots.isEmpty()) {
- throw BuildException("At least one source path needs to be specified")
- }
- if (moduleName == null) {
- throw BuildException("Module name needs to be specified")
- }
- if (outputDir == null) {
- throw BuildException("Output directory needs to be specified")
- }
- val sourceLinks = antSourceLinks.map {
- val path = it.path ?: throw BuildException("'path' attribute of a <sourceLink> element is required")
- val url = it.url ?: throw BuildException("'url' attribute of a <sourceLink> element is required")
- SourceLinkDefinitionImpl(File(path).canonicalFile.absolutePath, url, it.lineSuffix)
- }
- val passConfiguration = PassConfigurationImpl(
- classpath = compileClasspath.list().toList(),
- sourceRoots = sourcePath.list().map { SourceRootImpl(it) } + antSourceRoots.mapNotNull { it.toSourceRoot() },
- samples = samplesPath.list().toList(),
- includes = includesPath.list().toList(),
- moduleName = moduleName!!,
- skipDeprecated = skipDeprecated,
- sourceLinks = sourceLinks,
- jdkVersion = jdkVersion,
- perPackageOptions = antPackageOptions,
- externalDocumentationLinks = antExternalDocumentationLinks.map { it.build() },
- noStdlibLink = noStdlibLink,
- noJdkLink = noJdkLink,
- languageVersion = languageVersion,
- apiVersion = apiVersion
- )
-
- val configuration = DokkaConfigurationImpl(
- outputDir = outputDir!!,
- format = outputFormat,
- impliedPlatforms = impliedPlatforms.split(','),
- cacheRoot = cacheRoot,
- passesConfigurations = listOf(
- passConfiguration
- )
- )
-
- val generator = DokkaGenerator(configuration, AntLogger(this))
+ throw IOException(passesConfigurations.flatMap { it.targets }.joinToString())
+// if (sourcePath.list().isEmpty() && antSourceRoots.isEmpty()) {
+// throw BuildException("At least one source path needs to be specified")
+// }
+// if (moduleName == null) {
+// throw BuildException("Module name needs to be specified")
+// }
+// if (outputDir == null) {
+// throw BuildException("Output directory needs to be specified")
+// }
+// val sourceLinks = antSourceLinks.map {
+// val path = it.path ?: throw BuildException("'path' attribute of a <sourceLink> element is required")
+// val url = it.url ?: throw BuildException("'url' attribute of a <sourceLink> element is required")
+// SourceLinkDefinitionImpl(File(path).canonicalFile.absolutePath, url, it.lineSuffix)
+// }
+
+// val passConfiguration = PassConfigurationImpl(
+// classpath = compileClasspath.list().toList(),
+// sourceRoots = sourcePath.list().map { SourceRootImpl(it) } + antSourceRoots.mapNotNull { it.toSourceRoot() },
+// samples = samplesPath.list().toList(),
+// includes = includesPath.list().toList(),
+// moduleName = moduleName!!,
+// skipDeprecated = skipDeprecated,
+// sourceLinks = sourceLinks,
+// jdkVersion = jdkVersion,
+// perPackageOptions = antPackageOptions,
+// externalDocumentationLinks = antExternalDocumentationLinks.map { it.build() },
+// noStdlibLink = noStdlibLink,
+// noJdkLink = noJdkLink,
+// languageVersion = languageVersion,
+// apiVersion = apiVersion
+// )
+//
+// val configuration = DokkaConfigurationImpl(
+// outputDir = outputDir!!,
+// format = outputFormat,
+// impliedPlatforms = impliedPlatforms.split(','),
+// cacheRoot = cacheRoot,
+// passesConfigurations = listOf(
+// passConfiguration
+// )
+// )
+
+ val generator = DokkaGenerator(this, AntLogger(this))
generator.generate()
}
} \ No newline at end of file
diff --git a/runners/cli/build.gradle b/runners/cli/build.gradle
index 7f733140..54f74b03 100644
--- a/runners/cli/build.gradle
+++ b/runners/cli/build.gradle
@@ -10,7 +10,12 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
}
}
+repositories {
+ mavenLocal()
+}
+
dependencies {
compile project(":core")
- compile "com.github.spullara.cli-parser:cli-parser:1.1.1"
+// compile "com.github.spullara.cli-parser:cli-parser:1.1.1"
+ compile "org.jetbrains:kotlinx.cli:0.1"
}