aboutsummaryrefslogtreecommitdiff
path: root/runners
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2019-04-10 17:31:13 +0200
committerKamil Doległo <kamilok1965@interia.pl>2019-04-10 17:31:13 +0200
commita6a96e0316fc754c47118fd61b2eac5d4cad1998 (patch)
tree3f4078a851e4544e98c5d4ccca381279f2028ced /runners
parent34e4d760d4928a9d97179652764b8d74f99436d3 (diff)
downloaddokka-a6a96e0316fc754c47118fd61b2eac5d4cad1998.tar.gz
dokka-a6a96e0316fc754c47118fd61b2eac5d4cad1998.tar.bz2
dokka-a6a96e0316fc754c47118fd61b2eac5d4cad1998.zip
Add automatic sourceDirs resolving when not using multiproject
Diffstat (limited to 'runners')
-rw-r--r--runners/gradle-plugin/src/main/kotlin/dokkaTask.kt40
1 files changed, 14 insertions, 26 deletions
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<File> = arrayListOf()
-// @Input
-// var sourceDirs: Iterable<File> = emptyList()
-// @Input
-// var sourceRoots: MutableList<DokkaConfiguration.SourceRoot> = arrayListOf()
+ @Input
+ var sourceDirs: Iterable<File> = emptyList()
+ @Input
+ var sourceRoots: MutableList<DokkaConfiguration.SourceRoot> = 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<Any?> }
}
-// fun sourceRoot(action: Action<GradleSourceRootImpl>) {
-// val sourceRoot = GradleSourceRootImpl()
-// action.execute(sourceRoot)
-// sourceRoots.add(sourceRoot)
-// }
-//
-// fun sourceRoot(closure: Closure<Unit>) {
-// sourceRoot(Action { sourceRoot ->
-// closure.delegate = sourceRoot
-// closure.call()
-// })
-// }
fun tryResolveFatJar(project: Project): Set<File> {
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<GradlePassConfigurationImpl>).toList()
+ }
+ passConfigurationExtension?.sourceRoots?.addAll(sourceRoots)
+
val passConfigurationList =
- ((this.extensions.getByName("passConfigurations") as Iterable<GradlePassConfigurationImpl>) +
- (this.extensions.getByName("passConfiguration") as GradlePassConfigurationImpl))
- .toList()
- .map { defaultPassConfiguration(it) }
+ (passConfigurationExtension?.let {passConfigurationsContainer + it } ?: passConfigurationsContainer)
+ .map { defaultPassConfiguration(it) }
val configuration = GradleDokkaConfigurationImpl()
configuration.outputDir = outputDirectory