aboutsummaryrefslogtreecommitdiff
path: root/runners/gradle-plugin/src/main
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2019-08-23 12:11:37 +0200
committerKamil Doległo <kamilok1965@interia.pl>2019-08-23 12:11:37 +0200
commit64f12cca55573ca40d682e1976d9f437233cc613 (patch)
treee548a4584cd9404a573db7a3d609e97418893a8e /runners/gradle-plugin/src/main
parent1c4a3c6b21846271bcdba3818ba323d1b0bb096f (diff)
downloaddokka-64f12cca55573ca40d682e1976d9f437233cc613.tar.gz
dokka-64f12cca55573ca40d682e1976d9f437233cc613.tar.bz2
dokka-64f12cca55573ca40d682e1976d9f437233cc613.zip
Add diagnostic info to Gradle platforms and create a top-level config
Diffstat (limited to 'runners/gradle-plugin/src/main')
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt27
1 files changed, 24 insertions, 3 deletions
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 8878103c..063efa24 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
@@ -22,6 +22,7 @@ import java.util.function.BiConsumer
open class DokkaTask : DefaultTask() {
private val ANDROID_REFERENCE_URL = Builder("https://developer.android.com/reference/").build()
+ private val GLOBAL_PLATFORM_NAME = "global" // Used for copying perPackageOptions to other platforms
@Suppress("MemberVisibilityCanBePrivate")
fun defaultKotlinTasks(): List<Task> = with(ReflectDsl) {
@@ -83,6 +84,8 @@ open class DokkaTask : DefaultTask() {
@Input
var disableAutoconfiguration: Boolean = false
+ private var outputDiagnosticInfo: Boolean = false // Workaround for Gradle, which fires some methods (like collectConfigurations()) multiple times in its lifecycle
+
private fun tryResolveFatJar(configuration: Configuration?): Set<File> {
return try {
configuration!!.resolve()
@@ -137,6 +140,7 @@ open class DokkaTask : DefaultTask() {
@TaskAction
fun generate() {
+ outputDiagnosticInfo = true
val kotlinColorsEnabledBefore = System.getProperty(COLORS_ENABLED_PROPERTY) ?: "false"
System.setProperty(COLORS_ENABLED_PROPERTY, "false")
try {
@@ -149,8 +153,9 @@ open class DokkaTask : DefaultTask() {
val gson = GsonBuilder().setPrettyPrinting().create()
+ val globalConfig = multiplatform.toList().find { it.name.toLowerCase() == GLOBAL_PLATFORM_NAME }
val passConfigurationList = collectConfigurations()
- .map { defaultPassConfiguration(it) }
+ .map { defaultPassConfiguration(globalConfig, it) }
val configuration = GradleDokkaConfigurationImpl()
configuration.outputDir = outputDirectory
@@ -237,7 +242,17 @@ open class DokkaTask : DefaultTask() {
merged.addAll(
userConfigurations.map { userConfig ->
val autoConfig = autoConfigurations.find { autoConfig -> autoConfig.name == userConfig.name }
- if (autoConfig != null) mergeUserConfigurationAndPlatformData(userConfig, autoConfig) else userConfig
+ if (autoConfig != null) {
+ mergeUserConfigurationAndPlatformData(userConfig, autoConfig)
+ } else {
+ if(outputDiagnosticInfo && userConfig.name.toLowerCase() != GLOBAL_PLATFORM_NAME) {
+ logger.warn(
+ "Could not find platform with name: ${userConfig.name} in Kotlin Gradle Plugin, " +
+ "using only user provided configuration for this platform"
+ )
+ }
+ userConfig
+ }
}
)
return merged.toList()
@@ -255,7 +270,7 @@ open class DokkaTask : DefaultTask() {
return merged
}
- private fun defaultPassConfiguration(config: GradlePassConfigurationImpl): GradlePassConfigurationImpl {
+ private fun defaultPassConfiguration(globalConfig: GradlePassConfigurationImpl?, config: GradlePassConfigurationImpl): GradlePassConfigurationImpl {
if (config.moduleName == "") {
config.moduleName = project.name
}
@@ -274,6 +289,12 @@ open class DokkaTask : DefaultTask() {
if (config.platform != null && config.platform.toString().isNotEmpty()) {
config.analysisPlatform = Platform.fromString(config.platform.toString())
}
+
+ if (globalConfig != null) {
+ config.perPackageOptions.addAll(globalConfig.perPackageOptions)
+ config.externalDocumentationLinks.addAll(globalConfig.externalDocumentationLinks)
+ config.sourceLinks.addAll(globalConfig.sourceLinks)
+ }
return config
}