diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2019-08-05 11:32:14 +0300 |
---|---|---|
committer | Kamil Doległo <kamilok1965@interia.pl> | 2019-08-05 11:32:14 +0300 |
commit | b02a6c8cfbc3b425c3a75b3cffaa073e6527c8cc (patch) | |
tree | 28644200b8f428cb8cc0cd09dc1c154662ceb7ca /runners/gradle-plugin/src/main | |
parent | 44a6ca53ca434f4300e81677a8d6814e30840280 (diff) | |
download | dokka-b02a6c8cfbc3b425c3a75b3cffaa073e6527c8cc.tar.gz dokka-b02a6c8cfbc3b425c3a75b3cffaa073e6527c8cc.tar.bz2 dokka-b02a6c8cfbc3b425c3a75b3cffaa073e6527c8cc.zip |
Cleanup, update README
Diffstat (limited to 'runners/gradle-plugin/src/main')
3 files changed, 19 insertions, 13 deletions
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt index ba931313..0ad1d1d3 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt @@ -120,7 +120,7 @@ object ConfigurationExtractor { .orEmpty() private fun getMainCompilation(target: KotlinTarget?): KotlinCompilation<KotlinCommonOptions>? = - target?.compilations?.getByName("main") + target?.compilations?.getByName(KotlinCompilation.MAIN_COMPILATION_NAME) private fun getPlatformName(platform: KotlinPlatformType): String = if (platform == KotlinPlatformType.androidJvm) "jvm" else platform.toString() diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt index 6bad548a..84bbaf78 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt @@ -41,9 +41,6 @@ open class DokkaTask : DefaultTask() { } @Input - var moduleName: String = "" - - @Input var outputFormat: String = "html" @Input @@ -65,9 +62,9 @@ open class DokkaTask : DefaultTask() { @Input var cacheRoot: String? = null - var multiplatform: Set<GradlePassConfigurationImpl> + var multiplatform: NamedDomainObjectContainer<GradlePassConfigurationImpl> @Suppress("UNCHECKED_CAST") - @Nested get() = (DslObject(this).extensions.getByName(MULTIPLATFORM_EXTENSION_NAME) as NamedDomainObjectContainer<GradlePassConfigurationImpl>).toSet() + @Nested get() = (DslObject(this).extensions.getByName(MULTIPLATFORM_EXTENSION_NAME) as NamedDomainObjectContainer<GradlePassConfigurationImpl>) internal set(value) = DslObject(this).extensions.add(MULTIPLATFORM_EXTENSION_NAME, value) var configuration: GradlePassConfigurationImpl @@ -96,6 +93,9 @@ open class DokkaTask : DefaultTask() { @Input var subProjects: List<String> = emptyList() + @Input + var disableAutoconfiguration: Boolean = false + fun tryResolveFatJar(configuration: Configuration?): Set<File> { return try { configuration!!.resolve() @@ -183,18 +183,23 @@ open class DokkaTask : DefaultTask() { if (multiplatform.toList().isNotEmpty()) collectFromMultiPlatform() else collectFromSinglePlatform() private fun collectFromMultiPlatform(): List<GradlePassConfigurationImpl> { + if (disableAutoconfiguration) return multiplatform.toList() + val baseConfig = mergeUserAndAutoConfigurations( multiplatform.toList(), ConfigurationExtractor.extractFromMultiPlatform(project).orEmpty() ) return if (subProjects.isNotEmpty()) - subProjects.toProjects().fold(baseConfig, { list, project -> - mergeUserAndAutoConfigurations(list, ConfigurationExtractor.extractFromMultiPlatform(project).orEmpty())}) + subProjects.toProjects().fold(baseConfig) { list, project -> + mergeUserAndAutoConfigurations(list, ConfigurationExtractor.extractFromMultiPlatform(project).orEmpty()) + } else baseConfig } private fun collectFromSinglePlatform(): List<GradlePassConfigurationImpl> { + if (disableAutoconfiguration) return listOf(configuration) + val autoConfig = ConfigurationExtractor.extractFromSinglePlatform(project) val baseConfig = if (autoConfig != null) listOf(mergeUserConfigurationAndPlatformData(configuration, autoConfig)) @@ -203,9 +208,9 @@ open class DokkaTask : DefaultTask() { return if (subProjects.isNotEmpty()) { try { - subProjects.toProjects().fold(baseConfig, { list, project -> + subProjects.toProjects().fold(baseConfig) { list, project -> listOf(mergeUserConfigurationAndPlatformData(list.first(), ConfigurationExtractor.extractFromSinglePlatform(project)!!)) - }) + } } catch(e: NullPointerException) { logger.warn("Cannot extract sources from subProjects. Do you have the Kotlin plugin in version 1.3.30+ " + "and the Kotlin plugin applied in the root project?") @@ -253,7 +258,10 @@ open class DokkaTask : DefaultTask() { private fun defaultPassConfiguration(config: GradlePassConfigurationImpl): GradlePassConfigurationImpl { if (config.moduleName == "") { - config.moduleName = moduleName + config.moduleName = project.name + } + if (config.targets.isEmpty() && multiplatform.isNotEmpty()){ + config.targets = listOf(config.platform.toString()) } config.classpath = (config.classpath as List<Any>).map { it.toString() }.distinct() // Workaround for Groovy's GStringImpl config.sourceRoots = config.sourceRoots.distinct().toMutableList() diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt index 24fe9df1..66020c5c 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt @@ -23,12 +23,10 @@ open class DokkaPlugin : Plugin<Project> { if(GradleVersion.current() >= GradleVersion.version("4.10")) { project.tasks.register(taskName, DokkaTask::class.java).configure { - it.moduleName = project.name it.outputDirectory = File(project.buildDir, taskName).absolutePath } } else { project.tasks.create(taskName, DokkaTask::class.java).apply { - moduleName = project.name outputDirectory = File(project.buildDir, taskName).absolutePath } } |