aboutsummaryrefslogtreecommitdiff
path: root/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2019-09-18 17:15:41 +0200
committerKamil Doległo <kamilok1965@interia.pl>2019-09-18 17:15:41 +0200
commit4560c64d5197a8f82b4c8a3eb1889a031309daa8 (patch)
treee4242e8b2f27c5ffbdc2796ee5316f43cd2f767f /runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka
parent9145b1c0902fef2dba796bf5cc250e493fdaea45 (diff)
downloaddokka-4560c64d5197a8f82b4c8a3eb1889a031309daa8.tar.gz
dokka-4560c64d5197a8f82b4c8a3eb1889a031309daa8.tar.bz2
dokka-4560c64d5197a8f82b4c8a3eb1889a031309daa8.zip
Add androidVariant selection for single-platform
Diffstat (limited to 'runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka')
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/ConfigurationExtractor.kt32
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt2
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt1
3 files changed, 23 insertions, 12 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 b7ae600a..c66998d9 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
@@ -26,7 +26,7 @@ import java.io.Serializable
class ConfigurationExtractor(private val project: Project) {
- fun extractFromSinglePlatform(): PlatformData? {
+ fun extractFromSinglePlatform(variantName: String? = null): PlatformData? {
val target: KotlinTarget
try {
target = project.extensions.getByType(KotlinSingleTargetExtension::class.java).target
@@ -39,7 +39,7 @@ class ConfigurationExtractor(private val project: Project) {
}
return try {
- PlatformData(null, getClasspath(target), getSourceSet(target), getPlatformName(target.platformType))
+ PlatformData(null, getClasspath(target, variantName), getSourceSet(target, variantName), getPlatformName(target.platformType))
} catch(e: NoSuchMethodError){
null
}
@@ -139,10 +139,17 @@ class ConfigurationExtractor(private val project: Project) {
return PlatformData(null, classpath, allSourceRoots.toList(), "")
}
- private fun getSourceSet(target: KotlinTarget): List<File> = getSourceSet(getMainCompilation(target))
-
- private fun getClasspath(target: KotlinTarget): List<File> = if (target.isAndroidTarget()) {
- getClasspathFromAndroidTask(getMainCompilation(target))
+ private fun getSourceSet(target: KotlinTarget, variantName: String? = null): List<File> =
+ if(variantName != null)
+ getSourceSet(getCompilation(target, variantName))
+ else
+ getSourceSet(getMainCompilation(target))
+
+ private fun getClasspath(target: KotlinTarget, variantName: String? = null): List<File> = if (target.isAndroidTarget()) {
+ if(variantName != null)
+ getClasspathFromAndroidTask(getCompilation(target, variantName))
+ else
+ getClasspathFromAndroidTask(getMainCompilation(target))
} else {
getClasspath(getMainCompilation(target))
}
@@ -161,14 +168,17 @@ class ConfigurationExtractor(private val project: Project) {
.orEmpty()
// This is a workaround for KT-33893
- private fun getClasspathFromAndroidTask(compilation: KotlinCompilation<*>?): List<File> = (compilation
- ?.compileKotlinTask as? KotlinCompile)
+ private fun getClasspathFromAndroidTask(compilation: KotlinCompilation<*>): List<File> = (compilation
+ .compileKotlinTask as? KotlinCompile)
?.classpath?.files?.toList() ?: getClasspath(compilation)
- private fun getMainCompilation(target: KotlinTarget?): KotlinCompilation<KotlinCommonOptions>? =
- target?.compilations?.getByName(getMainCompilationName(target))
+ private fun getMainCompilation(target: KotlinTarget) =
+ getCompilation(target, getMainCompilationName(target))
+
+ private fun getCompilation(target: KotlinTarget, name: String) =
+ target.compilations.getByName(name)
- private fun getMainCompilationName(target: KotlinTarget?) = if (target?.isAndroidTarget() == true)
+ private fun getMainCompilationName(target: KotlinTarget) = if (target.isAndroidTarget())
getVariants(project).filter { it.buildType.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 63064b45..5153ae1c 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
@@ -223,7 +223,7 @@ open class DokkaTask : DefaultTask() {
if (disableAutoconfiguration) return listOf(userConfig)
- val extractedConfig = configExtractor.extractFromSinglePlatform()
+ val extractedConfig = configExtractor.extractFromSinglePlatform(userConfig.androidVariant)
val baseConfig = if (extractedConfig != null)
listOf(mergeUserConfigurationAndPlatformData(userConfig, extractedConfig))
else
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt
index f772df3a..767bf4f4 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/configurationImplementations.kt
@@ -51,6 +51,7 @@ open class GradlePassConfigurationImpl(@Transient val name: String = ""): PassCo
@Input override var targets: List<String> = emptyList()
@Input @Optional override var sinceKotlin: String? = null
@Transient var collectKotlinTasks: (() -> List<Any?>?)? = null
+ @Input @Optional @Transient var androidVariant: String? = null
fun kotlinTasks(taskSupplier: Callable<List<Any>>) {
collectKotlinTasks = { taskSupplier.call() }