From a6a96e0316fc754c47118fd61b2eac5d4cad1998 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Wed, 10 Apr 2019 17:31:13 +0200 Subject: Add automatic sourceDirs resolving when not using multiproject --- runners/gradle-plugin/src/main/kotlin/dokkaTask.kt | 40 ++++++++-------------- 1 file changed, 14 insertions(+), 26 deletions(-) (limited to 'runners') diff --git a/runners/gradle-plugin/src/main/kotlin/dokkaTask.kt b/runners/gradle-plugin/src/main/kotlin/dokkaTask.kt index ed16a909..ef9cfd19 100644 --- a/runners/gradle-plugin/src/main/kotlin/dokkaTask.kt +++ b/runners/gradle-plugin/src/main/kotlin/dokkaTask.kt @@ -54,10 +54,10 @@ open class DokkaTask : DefaultTask() { @InputFiles var classpath: Iterable = arrayListOf() -// @Input -// var sourceDirs: Iterable = emptyList() -// @Input -// var sourceRoots: MutableList = arrayListOf() + @Input + var sourceDirs: Iterable = emptyList() + @Input + var sourceRoots: MutableList = arrayListOf() @Input var dokkaFatJar: Any = "org.jetbrains.dokka:dokka-fatjar:${DokkaVersion.version}" @Input @@ -83,18 +83,6 @@ open class DokkaTask : DefaultTask() { kotlinTasksConfigurator = { closure.call() as? List } } -// fun sourceRoot(action: Action) { -// val sourceRoot = GradleSourceRootImpl() -// action.execute(sourceRoot) -// sourceRoots.add(sourceRoot) -// } -// -// fun sourceRoot(closure: Closure) { -// sourceRoot(Action { sourceRoot -> -// closure.delegate = sourceRoot -// closure.call() -// }) -// } fun tryResolveFatJar(project: Project): Set { return try { @@ -185,13 +173,9 @@ open class DokkaTask : DefaultTask() { try { loadFatJar() // TODO: implement extracting source roots from kotlin tasks -// val (tasksClasspath, tasksSourceRoots) = kotlinCompileBasedClasspathAndSourceRoots + val (_, tasksSourceRoots) = kotlinCompileBasedClasspathAndSourceRoots -// val sourceRoots = collectSourceRoots(sourceDirs, sourceRoots) + tasksSourceRoots.toSourceRoots() -// if (sourceRoots.isEmpty()) { -// logger.warn("No source directories found: skipping dokka generation") -// return -// } + val sourceRoots = collectSourceRoots(sourceDirs, sourceRoots) + tasksSourceRoots.toSourceRoots() val bootstrapClass = ClassloaderContainer.fatJarClassLoader!!.loadClass("org.jetbrains.dokka.DokkaBootstrapImpl") val bootstrapInstance = bootstrapClass.constructors.first().newInstance() @@ -199,11 +183,15 @@ open class DokkaTask : DefaultTask() { val gson = GsonBuilder().setPrettyPrinting().create() + val passConfigurationExtension: GradlePassConfigurationImpl? = this.extensions.findByName("passConfiguration") as GradlePassConfigurationImpl + val passConfigurationsContainer by lazy { + (this.extensions.getByName("passConfigurations") as Iterable).toList() + } + passConfigurationExtension?.sourceRoots?.addAll(sourceRoots) + val passConfigurationList = - ((this.extensions.getByName("passConfigurations") as Iterable) + - (this.extensions.getByName("passConfiguration") as GradlePassConfigurationImpl)) - .toList() - .map { defaultPassConfiguration(it) } + (passConfigurationExtension?.let {passConfigurationsContainer + it } ?: passConfigurationsContainer) + .map { defaultPassConfiguration(it) } val configuration = GradleDokkaConfigurationImpl() configuration.outputDir = outputDirectory -- cgit