diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2019-08-08 14:14:44 +0300 |
---|---|---|
committer | Kamil Doległo <kamilok1965@interia.pl> | 2019-08-08 14:14:44 +0300 |
commit | da9d43e0b3293b36a3a6fd2986b0e6bc2e9b915d (patch) | |
tree | 696632183f0b3e03d032b2e7a24920aa66d93489 /runners/android-gradle-plugin/src | |
parent | bbb14aff014f7d0e7fb4f572084d607abecdbbd9 (diff) | |
download | dokka-da9d43e0b3293b36a3a6fd2986b0e6bc2e9b915d.tar.gz dokka-da9d43e0b3293b36a3a6fd2986b0e6bc2e9b915d.tar.bz2 dokka-da9d43e0b3293b36a3a6fd2986b0e6bc2e9b915d.zip |
Fix Android compilation name
Diffstat (limited to 'runners/android-gradle-plugin/src')
-rw-r--r-- | runners/android-gradle-plugin/src/main/kotlin/AndroidConfigurationExtractor.kt | 32 | ||||
-rw-r--r-- | runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt | 4 |
2 files changed, 34 insertions, 2 deletions
diff --git a/runners/android-gradle-plugin/src/main/kotlin/AndroidConfigurationExtractor.kt b/runners/android-gradle-plugin/src/main/kotlin/AndroidConfigurationExtractor.kt new file mode 100644 index 00000000..8a2a2dff --- /dev/null +++ b/runners/android-gradle-plugin/src/main/kotlin/AndroidConfigurationExtractor.kt @@ -0,0 +1,32 @@ +package org.jetbrains.dokka.gradle + +import com.android.build.gradle.* +import com.android.build.gradle.api.BaseVariant +import com.android.builder.core.BuilderConstants +import org.gradle.api.Project + +class AndroidConfigurationExtractor(private val project: Project): AbstractConfigurationExtractor(project) { + override fun getMainCompilationName(): String = getVariants(project).filter { it.name == BuilderConstants.RELEASE }.map { it.name }.first() + + private fun getVariants(project: Project): Set<BaseVariant> { + val androidExtension = project.extensions.getByName("android") + return when (androidExtension) { + is AppExtension -> androidExtension.applicationVariants.toSet() + is LibraryExtension -> { + androidExtension.libraryVariants.toSet() + + if (androidExtension is FeatureExtension) { + androidExtension.featureVariants.toSet() + } else { + emptySet<BaseVariant>() + } + } + is TestExtension -> androidExtension.applicationVariants.toSet() + else -> emptySet() + } + + if (androidExtension is TestedExtension) { + androidExtension.testVariants.toSet() + androidExtension.unitTestVariants.toSet() + } else { + emptySet<BaseVariant>() + } + } +}
\ No newline at end of file diff --git a/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt b/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt index 8aa76ef8..8e293ed6 100644 --- a/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt +++ b/runners/android-gradle-plugin/src/main/kotlin/mainAndroid.kt @@ -18,8 +18,8 @@ open class DokkaAndroidPlugin : DokkaPlugin() { private val ANDROID_REFERENCE_URL = Builder("https://developer.android.com/reference/").build() open class DokkaAndroidTask : DokkaTask() { - @Input var noAndroidSdkLink: Boolean = false + override val configurationExtractor = AndroidConfigurationExtractor(project) override fun collectSuppressedFiles(sourceRoots: List<SourceRoot>): List<String> { val generatedRoot = project.buildDir.resolve("generated").absoluteFile @@ -35,4 +35,4 @@ open class DokkaAndroidTask : DokkaTask() { if (!noAndroidSdkLink) externalDocumentationLinks.add(ANDROID_REFERENCE_URL) } } -} +}
\ No newline at end of file |