diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-06-19 14:08:49 +0200 |
---|---|---|
committer | Paweł Marks <pmarks@virtuslab.com> | 2020-06-25 20:23:58 +0200 |
commit | 8cb6efc97f8fa321381c95cc5f85a3ce7bc13c3f (patch) | |
tree | fe4e24d9f352199e551bd34ba330c0d2c0acf7af /runners/gradle-plugin/src/main/kotlin/org/jetbrains | |
parent | 08f40e2a13006882e8f8425f111b8527e7bbcb0f (diff) | |
download | dokka-8cb6efc97f8fa321381c95cc5f85a3ce7bc13c3f.tar.gz dokka-8cb6efc97f8fa321381c95cc5f85a3ce7bc13c3f.tar.bz2 dokka-8cb6efc97f8fa321381c95cc5f85a3ce7bc13c3f.zip |
Remove SourceSetDataCache, rename PassConfiguration to DokkaSourceSet and use it instead of SourceSetData
Diffstat (limited to 'runners/gradle-plugin/src/main/kotlin/org/jetbrains')
4 files changed, 77 insertions, 47 deletions
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 cef3695a..8483cd60 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 @@ -38,7 +38,7 @@ open class DokkaCollectorTask : DefaultTask() { configuration = passesConfigurations.fold(initial) { acc, it: GradleDokkaConfigurationImpl -> if(acc.format != it.format || acc.cacheRoot != it.cacheRoot) throw IllegalStateException("Dokka task configurations differ on core arguments (format, cacheRoot)") - acc.passesConfigurations = acc.passesConfigurations + it.passesConfigurations + acc.sourceSets = acc.sourceSets + it.sourceSets acc.pluginsClasspath = (acc.pluginsClasspath + it.pluginsClasspath).distinct() acc } 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 1759b6f3..cc9471a1 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 @@ -69,9 +69,9 @@ open class DokkaTask : DefaultTask(), Configurable { internal var config: GradleDokkaConfigurationImpl? = null - var dokkaSourceSets: NamedDomainObjectContainer<GradlePassConfigurationImpl> + var dokkaSourceSets: NamedDomainObjectContainer<GradleDokkaSourceSet> @Suppress("UNCHECKED_CAST") - @Nested get() = (DslObject(this).extensions.getByName(SOURCE_SETS_EXTENSION_NAME) as NamedDomainObjectContainer<GradlePassConfigurationImpl>) + @Nested get() = (DslObject(this).extensions.getByName(SOURCE_SETS_EXTENSION_NAME) as NamedDomainObjectContainer<GradleDokkaSourceSet>) internal set(value) = DslObject(this).extensions.add(SOURCE_SETS_EXTENSION_NAME, value) private val kotlinTasks: List<Task> by lazy { @@ -184,7 +184,7 @@ open class DokkaTask : DefaultTask(), Configurable { .map { defaultPassConfiguration(it, globalConfig) }.takeIf { it.isNotEmpty() } ?: listOf( defaultPassConfiguration( - collectSinglePassConfiguration(GradlePassConfigurationImpl("main")), + collectSinglePassConfiguration(GradleDokkaSourceSet("main")), null ) ).takeIf { project.isNotMultiplatformProject() } ?: emptyList() @@ -199,7 +199,7 @@ open class DokkaTask : DefaultTask(), Configurable { format = outputFormat cacheRoot = this@DokkaTask.cacheRoot offlineMode = this@DokkaTask.offlineMode - passesConfigurations = defaultModulesConfiguration + sourceSets = passConfigurations pluginsClasspath = pluginsClasspathConfiguration.resolve().toList() pluginsConfiguration = this@DokkaTask.pluginsConfiguration failOnWarning = this@DokkaTask.failOnWarning @@ -207,12 +207,12 @@ open class DokkaTask : DefaultTask(), Configurable { } - protected val passConfigurations: List<GradlePassConfigurationImpl> + protected val passConfigurations: List<GradleDokkaSourceSet> get() = dokkaSourceSets .filterNot { it.name.toLowerCase() == GLOBAL_CONFIGURATION_NAME } .map { collectSinglePassConfiguration(it) } - protected fun collectSinglePassConfiguration(config: GradlePassConfigurationImpl): GradlePassConfigurationImpl { + protected fun collectSinglePassConfiguration(config: GradleDokkaSourceSet): GradleDokkaSourceSet { val userConfig = config .apply { collectKotlinTasks?.let { @@ -259,7 +259,7 @@ open class DokkaTask : DefaultTask(), Configurable { } } - protected fun collectFromSinglePlatformOldPlugin(name: String, userConfig: GradlePassConfigurationImpl) = + protected fun collectFromSinglePlatformOldPlugin(name: String, userConfig: GradleDokkaSourceSet) = kotlinTasks.find { it.name == name } ?.let { configExtractor.extractFromKotlinTasks(listOf(it)) } ?.singleOrNull() @@ -269,7 +269,7 @@ open class DokkaTask : DefaultTask(), Configurable { ?: userConfig protected fun mergeUserConfigurationAndPlatformData( - userConfig: GradlePassConfigurationImpl, + userConfig: GradleDokkaSourceSet, autoConfig: PlatformData ) = userConfig.copy().apply { @@ -281,9 +281,9 @@ open class DokkaTask : DefaultTask(), Configurable { } protected fun defaultPassConfiguration( - config: GradlePassConfigurationImpl, - globalConfig: GradlePassConfigurationImpl? - ): GradlePassConfigurationImpl { + config: GradleDokkaSourceSet, + globalConfig: GradleDokkaSourceSet? + ): GradleDokkaSourceSet { if (config.moduleName.isBlank()) { config.moduleName = project.name } 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 f4e7730e..c5169ef8 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 @@ -16,7 +16,7 @@ import java.util.concurrent.Callable import kotlin.reflect.KMutableProperty import kotlin.reflect.full.memberProperties -class GradleSourceRootImpl: SourceRoot, Serializable { +class GradleSourceRootImpl : SourceRoot, Serializable { override var path: String = "" set(value) { field = File(value).absolutePath @@ -25,33 +25,63 @@ class GradleSourceRootImpl: SourceRoot, Serializable { override fun toString(): String = path } -open class GradlePassConfigurationImpl(@Transient val name: String = ""): PassConfiguration { - @Input @Optional override var classpath: List<String> = emptyList() - @Input override var moduleName: String = "" - @Input override var displayName: String = "" - @Input override var sourceSetID: String = "" - @Input override var sourceRoots: MutableList<SourceRoot> = mutableListOf() - @Input override var dependentSourceSets: MutableList<String> = mutableListOf() - @Input override var samples: List<String> = emptyList() - @Input override var includes: List<String> = emptyList() - @Input override var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic - @Input override var includeRootPackage: Boolean = DokkaDefaults.includeRootPackage - @Input override var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented - @Input override var skipEmptyPackages: Boolean = DokkaDefaults.skipEmptyPackages - @Input override var skipDeprecated: Boolean = DokkaDefaults.skipDeprecated - @Input override var jdkVersion: Int = DokkaDefaults.jdkVersion - @Input override var sourceLinks: MutableList<SourceLinkDefinition> = mutableListOf() - @Input override var perPackageOptions: MutableList<PackageOptions> = mutableListOf() - @Input override var externalDocumentationLinks: MutableList<ExternalDocumentationLink> = mutableListOf() - @Input @Optional override var languageVersion: String? = null - @Input @Optional override var apiVersion: String? = null - @Input override var noStdlibLink: Boolean = DokkaDefaults.noStdlibLink - @Input override var noJdkLink: Boolean = DokkaDefaults.noJdkLink - @Input var noAndroidSdkLink: Boolean = false - @Input override var suppressedFiles: List<String> = emptyList() - @Input override var analysisPlatform: Platform = DokkaDefaults.analysisPlatform - @Input @Optional var platform: String? = null - @Transient var collectKotlinTasks: (() -> List<Any?>?)? = null +open class GradleDokkaSourceSet(@Transient val name: String = "") : DokkaSourceSet { + @Input + @Optional + override var classpath: List<String> = emptyList() + @Input + override var moduleName: String = "" + @Input + override var displayName: String = "" + @Input + override var sourceSetID: String = "" + @Input + override var sourceRoots: MutableList<SourceRoot> = mutableListOf() + @Input + override var dependentSourceSets: MutableList<String> = mutableListOf() + @Input + override var samples: List<String> = emptyList() + @Input + override var includes: List<String> = emptyList() + @Input + override var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic + @Input + override var includeRootPackage: Boolean = DokkaDefaults.includeRootPackage + @Input + override var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented + @Input + override var skipEmptyPackages: Boolean = DokkaDefaults.skipEmptyPackages + @Input + override var skipDeprecated: Boolean = DokkaDefaults.skipDeprecated + @Input + override var jdkVersion: Int = DokkaDefaults.jdkVersion + @Input + override var sourceLinks: MutableList<SourceLinkDefinition> = mutableListOf() + @Input + override var perPackageOptions: MutableList<PackageOptions> = mutableListOf() + @Input + override var externalDocumentationLinks: MutableList<ExternalDocumentationLink> = mutableListOf() + @Input + @Optional + override var languageVersion: String? = null + @Input + @Optional + override var apiVersion: String? = null + @Input + override var noStdlibLink: Boolean = DokkaDefaults.noStdlibLink + @Input + override var noJdkLink: Boolean = DokkaDefaults.noJdkLink + @Input + var noAndroidSdkLink: Boolean = false + @Input + override var suppressedFiles: List<String> = emptyList() + @Input + override var analysisPlatform: Platform = DokkaDefaults.analysisPlatform + @Input + @Optional + var platform: String? = null + @Transient + var collectKotlinTasks: (() -> List<Any?>?)? = null fun kotlinTasks(taskSupplier: Callable<List<Any>>) { collectKotlinTasks = { taskSupplier.call() } @@ -117,25 +147,25 @@ class GradleExternalDocumentationLinkImpl : ExternalDocumentationLink, Serializa override var packageListUrl: URL = URL("http://") } -class GradleDokkaModuleDescription: DokkaModuleDescription { +class GradleDokkaModuleDescription : DokkaModuleDescription { override var name: String = "" override var path: String = "" override var docFile: String = "" } -class GradleDokkaConfigurationImpl: DokkaConfiguration { +class GradleDokkaConfigurationImpl : DokkaConfiguration { override var outputDir: String = "" override var format: String = DokkaDefaults.format override var cacheRoot: String? = DokkaDefaults.cacheRoot override var offlineMode: Boolean = DokkaDefaults.offlineMode override var failOnWarning: Boolean = DokkaDefaults.failOnWarning - override var passesConfigurations: List<GradlePassConfigurationImpl> = emptyList() + override var sourceSets: List<GradleDokkaSourceSet> = emptyList() override var pluginsClasspath: List<File> = emptyList() override var pluginsConfiguration: Map<String, String> = mutableMapOf() override var modules: List<GradleDokkaModuleDescription> = emptyList() } -class GradlePackageOptionsImpl: PackageOptions, Serializable { +class GradlePackageOptionsImpl : PackageOptions, Serializable { override var prefix: String = "" override var includeNonPublic: Boolean = DokkaDefaults.includeNonPublic override var reportUndocumented: Boolean = DokkaDefaults.reportUndocumented @@ -143,8 +173,8 @@ class GradlePackageOptionsImpl: PackageOptions, Serializable { override var suppress: Boolean = DokkaDefaults.suppress } -internal fun GradlePassConfigurationImpl.copy(): GradlePassConfigurationImpl { - val newObj = GradlePassConfigurationImpl(this.name) +internal fun GradleDokkaSourceSet.copy(): GradleDokkaSourceSet { + val newObj = GradleDokkaSourceSet(this.name) this::class.memberProperties.forEach { field -> if (field is KMutableProperty<*>) { val value = field.getter.call(this) diff --git a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt index 41d6e67a..2b076fd0 100644 --- a/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt +++ b/runners/gradle-plugin/src/main/kotlin/org/jetbrains/dokka/gradle/main.kt @@ -57,7 +57,7 @@ open class DokkaPlugin : Plugin<Project> { project.tasks.create(DOKKA_TASK_NAME, taskClass) } project.tasks.withType(taskClass) { task -> - task.dokkaSourceSets = project.container(GradlePassConfigurationImpl::class.java) + task.dokkaSourceSets = project.container(GradleDokkaSourceSet::class.java) task.dokkaRuntime = runtimeConfiguration task.pluginsClasspathConfiguration = pluginsConfiguration task.outputDirectory = File(project.buildDir, DOKKA_TASK_NAME).absolutePath |