aboutsummaryrefslogtreecommitdiff
path: root/runners/gradle-plugin/src
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2019-09-15 21:31:34 +0200
committerKamil Doległo <kamilok1965@interia.pl>2019-09-15 21:31:34 +0200
commitf8cf88068368e5ae9a2b2aa90b0bc38e3238fac1 (patch)
tree57f8f0381f1a4c1bdfb1f6538433d7d85e26e96c /runners/gradle-plugin/src
parent9095656c27fb1095d99c3f9ff72c44f9265b9996 (diff)
downloaddokka-f8cf88068368e5ae9a2b2aa90b0bc38e3238fac1.tar.gz
dokka-f8cf88068368e5ae9a2b2aa90b0bc38e3238fac1.tar.bz2
dokka-f8cf88068368e5ae9a2b2aa90b0bc38e3238fac1.zip
Fix a bug with non-native Android
Diffstat (limited to 'runners/gradle-plugin/src')
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt5
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt9
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt3
3 files changed, 12 insertions, 5 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 96cd0824..9f8dfc33 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
@@ -13,7 +13,6 @@ import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.tasks.SourceSet
import org.gradle.api.tasks.compile.AbstractCompile
import org.jetbrains.dokka.ReflectDsl
-import org.jetbrains.kotlin.android.synthetic.diagnostic.AndroidExtensionPropertiesCallChecker
import org.jetbrains.kotlin.gradle.dsl.KotlinCommonOptions
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinSingleTargetExtension
@@ -156,9 +155,9 @@ class ConfigurationExtractor(private val project: Project) {
.orEmpty()
private fun getMainCompilation(target: KotlinTarget?): KotlinCompilation<KotlinCommonOptions>? =
- target?.compilations?.getByName(getMainCompilationName())
+ target?.compilations?.getByName(getMainCompilationName(target))
- private fun getMainCompilationName() = if (project.isAndroidProject())
+ private fun getMainCompilationName(target: KotlinTarget?) = if (target?.isAndroidTarget() == true)
getVariants(project).filter { it.name == BuilderConstants.RELEASE }.map { it.name }.first()
else
KotlinCompilation.MAIN_COMPILATION_NAME
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 f20b6651..4dc23b4b 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
@@ -301,12 +301,12 @@ open class DokkaTask : DefaultTask() {
config.samples = config.samples.map { project.file(it).absolutePath }
config.includes = config.includes.map { project.file(it).absolutePath }
config.suppressedFiles += collectSuppressedFiles(config.sourceRoots)
- if (project.isAndroidProject() && !config.noAndroidSdkLink) {
+ if (project.isAndroidProject() && !config.noAndroidSdkLink) { // TODO: introduce Android as a separate Dokka platform?
config.externalDocumentationLinks.add(ANDROID_REFERENCE_URL)
}
config.externalDocumentationLinks.addAll(externalDocumentationLinks)
if (config.platform != null && config.platform.toString().isNotEmpty()) {
- config.analysisPlatform = Platform.fromString(config.platform.toString())
+ config.analysisPlatform = dokkaPlatformFromString(config.platform.toString())
}
if (globalConfig != null) {
config.perPackageOptions.addAll(globalConfig.perPackageOptions)
@@ -316,6 +316,11 @@ open class DokkaTask : DefaultTask() {
return config
}
+ private fun dokkaPlatformFromString(platform: String) = when (platform.toLowerCase()) {
+ "androidjvm", "android" -> Platform.jvm
+ else -> Platform.fromString(platform)
+ }
+
// Needed for Gradle incremental build
@OutputDirectory
fun getOutputDirectoryAsFile(): File = project.file(outputDirectory)
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt
index 90dcde7b..d70b0499 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/utils.kt
@@ -2,6 +2,8 @@ package org.jetbrains.dokka.gradle
import org.gradle.api.Project
import org.gradle.api.UnknownDomainObjectException
+import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
+import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
fun Project.isAndroidProject() = try {
@@ -13,4 +15,5 @@ fun Project.isAndroidProject() = try {
false
}
+fun KotlinTarget.isAndroidTarget() = this.platformType == KotlinPlatformType.androidJvm
fun DokkaTask.isMultiplatformProject() = this.multiplatform.isNotEmpty() \ No newline at end of file