aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.idea/codeStyles/Project.xml15
-rw-r--r--integration-tests/gradle/projects/it-basic/build.gradle.kts8
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt5
-rw-r--r--runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaTask.kt48
4 files changed, 40 insertions, 36 deletions
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 69ebce06..31d977a0 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -3,9 +3,18 @@
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
- <package name="java.util" withSubpackages="false" static="false" />
- <package name="kotlinx.android.synthetic" withSubpackages="true" static="false" />
- <package name="io.ktor" withSubpackages="true" static="false" />
+ <package name="java.util" alias="false" withSubpackages="false" />
+ <package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
+ <package name="io.ktor" alias="false" withSubpackages="true" />
+ </value>
+ </option>
+ <option name="PACKAGES_IMPORT_LAYOUT">
+ <value>
+ <package name="" alias="false" withSubpackages="true" />
+ <package name="java" alias="false" withSubpackages="true" />
+ <package name="javax" alias="false" withSubpackages="true" />
+ <package name="kotlin" alias="false" withSubpackages="true" />
+ <package name="" alias="true" withSubpackages="true" />
</value>
</option>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
diff --git a/integration-tests/gradle/projects/it-basic/build.gradle.kts b/integration-tests/gradle/projects/it-basic/build.gradle.kts
index c6fd29b7..691634b7 100644
--- a/integration-tests/gradle/projects/it-basic/build.gradle.kts
+++ b/integration-tests/gradle/projects/it-basic/build.gradle.kts
@@ -8,3 +8,11 @@ apply(from = "../template.root.gradle.kts")
dependencies {
implementation(kotlin("stdlib"))
}
+
+tasks.dokkaHtml {
+ dokkaSourceSets {
+ register("global") {
+ jdkVersion = 2
+ }
+ }
+}
diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt
index 27d25884..0270dbe2 100644
--- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt
+++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/DokkaCollectorTask.kt
@@ -1,10 +1,7 @@
package org.jetbrains.dokka.gradle
import org.gradle.api.DefaultTask
-import org.gradle.api.Project
-import org.gradle.api.UnknownTaskException
import org.gradle.api.tasks.Input
-import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.TaskAction
import java.lang.IllegalStateException
@@ -43,7 +40,7 @@ open class DokkaCollectorTask : DefaultTask() {
acc.pluginsClasspath = (acc.pluginsClasspath + it.pluginsClasspath).distinct()
acc
}
- project.tasks.withType(DokkaTask::class.java).configureEach { it.config = configuration }
+ project.tasks.withType(DokkaTask::class.java).configureEach { it.enforcedConfiguration = configuration }
}
init {
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 db25fc47..75ca66d1 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
@@ -20,7 +20,6 @@ import java.util.concurrent.Callable
open class DokkaTask : AbstractDokkaTask() {
private val ANDROID_REFERENCE_URL = Builder("https://developer.android.com/reference/").build()
- private val GLOBAL_CONFIGURATION_NAME = "global" // Used for copying perPackageOptions to other platforms
private val configExtractor = ConfigurationExtractor(project)
@Suppress("MemberVisibilityCanBePrivate")
@@ -52,7 +51,7 @@ open class DokkaTask : AbstractDokkaTask() {
@get:Internal
- internal var config: GradleDokkaConfigurationImpl? = null
+ internal var enforcedConfiguration: GradleDokkaConfigurationImpl? = null
@get:Nested
val dokkaSourceSets: NamedDomainObjectContainer<GradleDokkaSourceSet> =
@@ -119,7 +118,7 @@ open class DokkaTask : AbstractDokkaTask() {
}
@TaskAction
- override fun generate() = config?.let { generate(it) } ?: generate(getConfigurationOrThrow())
+ override fun generate() = enforcedConfiguration?.let { generate(it) } ?: generate(getConfigurationOrThrow())
protected open fun generate(configuration: GradleDokkaConfigurationImpl) {
outputDiagnosticInfo = true
@@ -142,11 +141,10 @@ open class DokkaTask : AbstractDokkaTask() {
@Internal
internal fun getConfigurationOrNull(): GradleDokkaConfigurationImpl? {
- val globalConfig = dokkaSourceSets.toList().find { it.name.toLowerCase() == GLOBAL_CONFIGURATION_NAME }
val defaultModulesConfiguration = configuredDokkaSourceSets
- .map { configureDefault(it, globalConfig) }.takeIf { it.isNotEmpty() }
+ .map { configureDefault(it) }.takeIf { it.isNotEmpty() }
?: listOf(
- configureDefault(configureDokkaSourceSet(GradleDokkaSourceSet("main", project)), null)
+ configureDefault(configureDokkaSourceSet(GradleDokkaSourceSet("main", project)))
).takeIf { project.isNotMultiplatformProject() } ?: emptyList()
if (defaultModulesConfiguration.isEmpty()) {
@@ -185,11 +183,9 @@ open class DokkaTask : AbstractDokkaTask() {
@get:Internal
protected val configuredDokkaSourceSets: List<GradleDokkaSourceSet>
- get() = dokkaSourceSets
- .filterNot { it.name.toLowerCase() == GLOBAL_CONFIGURATION_NAME }
- .map { configureDokkaSourceSet(it) }
+ get() = dokkaSourceSets.map { configureDokkaSourceSet(it) }
- protected fun configureDokkaSourceSet(config: GradleDokkaSourceSet): GradleDokkaSourceSet {
+ private fun configureDokkaSourceSet(config: GradleDokkaSourceSet): GradleDokkaSourceSet {
val userConfig = config
.apply {
collectKotlinTasks?.let {
@@ -236,7 +232,7 @@ open class DokkaTask : AbstractDokkaTask() {
}
}
- protected fun collectFromSinglePlatformOldPlugin(name: String, userConfig: GradleDokkaSourceSet) =
+ private fun collectFromSinglePlatformOldPlugin(name: String, userConfig: GradleDokkaSourceSet) =
kotlinTasks.find { it.name == name }
?.let { configExtractor.extractFromKotlinTasks(listOf(it)) }
?.singleOrNull()
@@ -245,7 +241,7 @@ open class DokkaTask : AbstractDokkaTask() {
?.let { mergeUserConfigurationAndPlatformData(userConfig, it) }
?: userConfig
- protected fun mergeUserConfigurationAndPlatformData(
+ private fun mergeUserConfigurationAndPlatformData(
userConfig: GradleDokkaSourceSet,
autoConfig: PlatformData
) = userConfig.copy().apply {
@@ -257,10 +253,7 @@ open class DokkaTask : AbstractDokkaTask() {
platform = autoConfig.platform
}
- protected fun configureDefault(
- config: GradleDokkaSourceSet,
- globalConfig: GradleDokkaSourceSet?
- ): GradleDokkaSourceSet {
+ private fun configureDefault(config: GradleDokkaSourceSet): GradleDokkaSourceSet {
if (config.moduleDisplayName.isBlank()) {
config.moduleDisplayName = project.name
}
@@ -268,25 +261,22 @@ open class DokkaTask : AbstractDokkaTask() {
if (config.displayName.isBlank()) {
config.displayName = config.name.substringBeforeLast("Main", 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()
- 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) {
config.externalDocumentationLinks.add(ANDROID_REFERENCE_URL)
}
+
if (config.platform?.isNotBlank() == true) {
config.analysisPlatform = dokkaPlatformFromString(config.platform.toString())
}
- globalConfig?.let {
- config.perPackageOptions.addAll(globalConfig.perPackageOptions)
- config.externalDocumentationLinks.addAll(globalConfig.externalDocumentationLinks)
- config.sourceLinks.addAll(globalConfig.sourceLinks)
- config.samples += globalConfig.samples.map { project.file(it).absolutePath }
- config.includes += globalConfig.includes.map { project.file(it).absolutePath }
- }
+
+ // Workaround for Groovy's GStringImpl
+ config.classpath = (config.classpath as List<Any>).map { it.toString() }.distinct()
+ config.sourceRoots = config.sourceRoots.distinct().toMutableList()
+ config.samples = config.samples.map { project.file(it).absolutePath }
+ config.includes = config.includes.map { project.file(it).absolutePath }
+ config.suppressedFiles += collectSuppressedFiles(config.sourceRoots)
+
return config
}