Skip to content

Commit

Permalink
Make key methods of plugin and task protected open
Browse files Browse the repository at this point in the history
Addresses #534
  • Loading branch information
kamildoleglo committed Dec 18, 2019
1 parent 2f4d5c5 commit 29a4cc7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ open class DokkaTask : DefaultTask() {
// Configure Dokka with closure in Gradle Kotlin DSL
fun configuration(action: Action<in GradlePassConfigurationImpl>) = action.execute(configuration)


private val kotlinTasks: List<Task> by lazy { extractKotlinCompileTasks(configuration.collectKotlinTasks ?: { defaultKotlinTasks() }) }

private val configExtractor = ConfigurationExtractor(project)
Expand Down Expand Up @@ -126,7 +125,7 @@ open class DokkaTask : DefaultTask() {
private fun Iterable<File>.toSourceRoots(): List<GradleSourceRootImpl> = this.filter { it.exists() }.map { GradleSourceRootImpl().apply { path = it.path } }
private fun Iterable<String>.toProjects(): List<Project> = project.subprojects.toList().filter { this.contains(it.name) }

private fun collectSuppressedFiles(sourceRoots: List<SourceRoot>) =
protected open fun collectSuppressedFiles(sourceRoots: List<SourceRoot>) =
if(project.isAndroidProject()) {
val generatedRoot = project.buildDir.resolve("generated").absoluteFile
sourceRoots
Expand Down Expand Up @@ -188,14 +187,14 @@ open class DokkaTask : DefaultTask() {
}
}

private fun collectConfigurations() =
protected open fun collectConfigurations() =
if (this.isMultiplatformProject()) collectMultiplatform() else listOf(collectSinglePlatform(configuration))

private fun collectMultiplatform() = multiplatform
protected open fun collectMultiplatform() = multiplatform
.filterNot { it.name.toLowerCase() == GLOBAL_PLATFORM_NAME }
.map { collectSinglePlatform(it) }

private fun collectSinglePlatform(config: GradlePassConfigurationImpl): GradlePassConfigurationImpl {
protected open fun collectSinglePlatform(config: GradlePassConfigurationImpl): GradlePassConfigurationImpl {
val userConfig = config.let {
if (it.collectKotlinTasks != null) {
configExtractor.extractFromKotlinTasks(extractKotlinCompileTasks(it.collectKotlinTasks!!))
Expand Down Expand Up @@ -237,22 +236,22 @@ open class DokkaTask : DefaultTask() {
}
}

private fun collectFromSinglePlatformOldPlugin() =
protected open fun collectFromSinglePlatformOldPlugin() =
configExtractor.extractFromKotlinTasks(kotlinTasks)
?.let { mergeUserConfigurationAndPlatformData(configuration, it) }
?: configExtractor.extractFromJavaPlugin()
?.let { mergeUserConfigurationAndPlatformData(configuration, it) }
?: configuration

private fun mergeUserConfigurationAndPlatformData(userConfig: GradlePassConfigurationImpl, autoConfig: PlatformData) =
protected open fun mergeUserConfigurationAndPlatformData(userConfig: GradlePassConfigurationImpl, autoConfig: PlatformData) =
userConfig.copy().apply {
sourceRoots.addAll(userConfig.sourceRoots.union(autoConfig.sourceRoots.toSourceRoots()).distinct())
classpath = userConfig.classpath.union(autoConfig.classpath.map { it.absolutePath }).distinct()
if (userConfig.platform == null && autoConfig.platform != "")
platform = autoConfig.platform
}

private fun defaultPassConfiguration(
protected open fun defaultPassConfiguration(
config: GradlePassConfigurationImpl,
globalConfig: GradlePassConfigurationImpl?
): GradlePassConfigurationImpl {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ open class DokkaPlugin : Plugin<Project> {
defaultDependencies{ dependencies -> dependencies.add(project.dependencies.create("org.jetbrains.dokka:dokka-fatjar:${DokkaVersion.version}")) }
}

private fun addTasks(project: Project, runtimeConfiguration: Configuration, taskClass: Class<out DokkaTask>) {
protected open fun addTasks(project: Project, runtimeConfiguration: Configuration, taskClass: Class<out DokkaTask>) {
if(GradleVersion.current() >= GradleVersion.version("4.10")) {
project.tasks.register(taskName, taskClass)
} else {
Expand Down

0 comments on commit 29a4cc7

Please sign in to comment.