diff options
author | Kamil Doległo <kamilok1965@interia.pl> | 2020-06-12 11:35:06 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-06-15 13:15:30 +0200 |
commit | 18d46c118174e0aea8d917b977ff7e8461e0e8c4 (patch) | |
tree | ab1eb9e788bfe35c985b959f18c8fb732bff3a23 /runners/gradle-plugin/src/main/kotlin | |
parent | 0ff8ebe97f540fff0d6fac962749f73b1db689ef (diff) | |
download | dokka-18d46c118174e0aea8d917b977ff7e8461e0e8c4.tar.gz dokka-18d46c118174e0aea8d917b977ff7e8461e0e8c4.tar.bz2 dokka-18d46c118174e0aea8d917b977ff7e8461e0e8c4.zip |
Fix DokkaCollector task
Diffstat (limited to 'runners/gradle-plugin/src/main/kotlin')
3 files changed, 16 insertions, 12 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 8c4e0c4c..cef3695a 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 @@ -20,14 +20,14 @@ open class DokkaCollectorTask : DefaultTask() { @TaskAction fun collect() { - val passesConfigurations = getProjects(project).filter { it.name in modules }.mapNotNull { - val task = try { - it.tasks.getByName(DOKKA_TASK_NAME, DokkaTask::class) + val passesConfigurations = getProjects(project).filter { it.name in modules }.flatMap { + val tasks = try { + it.tasks.withType(DokkaTask::class.java) } catch (e: UnknownTaskException) { throw IllegalStateException("No dokka task declared in module ${it.name}") } - task.getConfiguration() - } + tasks.map { it.getConfiguration() } + }.filterNotNull() val initial = GradleDokkaConfigurationImpl().apply { outputDir = outputDirectory @@ -42,7 +42,7 @@ open class DokkaCollectorTask : DefaultTask() { acc.pluginsClasspath = (acc.pluginsClasspath + it.pluginsClasspath).distinct() acc } - project.tasks.getByName(DOKKA_TASK_NAME).setProperty("config", configuration) + project.tasks.withType(DokkaTask::class.java).configureEach { it.config = configuration } } init { @@ -50,6 +50,6 @@ open class DokkaCollectorTask : DefaultTask() { } private fun getProjects(project: Project): Set<Project> = - project.subprojects + project.subprojects.flatMap { getProjects(it) } + project.subprojects + project.subprojects.flatMap { getProjects(it) } }
\ No newline at end of file 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 82cba6c1..bedbad18 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 @@ -67,6 +67,8 @@ open class DokkaTask : DefaultTask(), Configurable { @Classpath lateinit var pluginsClasspathConfiguration: Configuration + internal var config: GradleDokkaConfigurationImpl? = null + var dokkaSourceSets: NamedDomainObjectContainer<GradlePassConfigurationImpl> @Suppress("UNCHECKED_CAST") @Nested get() = (DslObject(this).extensions.getByName(SOURCE_SETS_EXTENSION_NAME) as NamedDomainObjectContainer<GradlePassConfigurationImpl>) @@ -138,13 +140,12 @@ open class DokkaTask : DefaultTask(), Configurable { } @TaskAction - fun generate() = getConfiguration()?.let { generate(it) } ?: exitProcess(0) + fun generate() = config?.let { generate(it) } ?: getConfiguration()?.let { generate(it) } ?: exitProcess(0) protected open fun generate(configuration: GradleDokkaConfigurationImpl) { outputDiagnosticInfo = true val kotlinColorsEnabledBefore = System.getProperty(COLORS_ENABLED_PROPERTY) ?: "false" System.setProperty(COLORS_ENABLED_PROPERTY, "false") - configuration.passesConfigurations.flatMap { it.sourceRoots }.also(::println) try { loadCore() @@ -286,7 +287,10 @@ open class DokkaTask : DefaultTask(), Configurable { if (config.sourceSetID.isBlank()) { config.sourceSetID = config.name.takeIf(String::isNotBlank) ?: config.analysisPlatform.key } - config.displayName = config.moduleName + config.sourceSetID.substringBeforeLast("Main") + config.dependentSourceSets = config.dependentSourceSets.map { config.moduleName + "/" + it }.toMutableList() + if (config.displayName.isBlank()) { + config.displayName = config.sourceSetID.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() @@ -322,7 +326,7 @@ open class DokkaTask : DefaultTask(), Configurable { // Needed for Gradle incremental build @InputFiles fun getInputFiles(): FileCollection = passConfigurations.let { config -> - project.files(config.flatMap { it.sourceRoots }.map { project.fileTree(File(it.path)) }) + + project.files(config.flatMap { it.sourceRoots }.map { project.fileTree(File(it.path)) }) + project.files(config.flatMap { it.includes }) + project.files(config.flatMap { it.samples }.map { project.fileTree(File(it)) }) } 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 d2a0f043..b62774f8 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 @@ -60,7 +60,7 @@ open class DokkaPlugin : Plugin<Project> { task.dokkaSourceSets = project.container(GradlePassConfigurationImpl::class.java) task.dokkaRuntime = runtimeConfiguration task.pluginsClasspathConfiguration = pluginsConfiguration - task.outputDirectory = File(project.rootProject.buildDir, "$DOKKA_TASK_NAME/${project.name}").absolutePath + task.outputDirectory = File(project.buildDir, DOKKA_TASK_NAME).absolutePath } } |