From 86dec889f26a5f705379d3bdfccf659815b10b6f Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Tue, 14 Feb 2017 11:15:48 -0800 Subject: [PATCH] Pull a few functions up in BaseJvmPlugin. --- .../main/kotlin/com/beust/kobalt/internal/BaseJvmPlugin.kt | 4 +++- .../kotlin/com/beust/kobalt/plugin/groovy/GroovyPlugin.kt | 3 --- src/main/kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt | 3 --- .../kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/BaseJvmPlugin.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/BaseJvmPlugin.kt index a079f833..e89fc9aa 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/BaseJvmPlugin.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/BaseJvmPlugin.kt @@ -24,12 +24,14 @@ abstract class BaseJvmPlugin(open val configActor: ConfigActor) : override fun accept(project: Project) = sourceFileCount(project) > 0 // IBuildConfigContributor - protected fun sourceFileCount(project: Project) = KFiles.findSourceFiles(project.directory, project.sourceDirectories, sourceSuffixes()).size + KFiles.findSourceFiles(project.directory, project.sourceDirectoriesTest, sourceSuffixes()).size fun affinity(project: Project) = sourceFileCount(project) + // IDocContributor + open fun affinity(project: Project, context: KobaltContext) = sourceFileCount(project) + abstract fun sourceSuffixes() : List } \ No newline at end of file diff --git a/src/main/kotlin/com/beust/kobalt/plugin/groovy/GroovyPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/groovy/GroovyPlugin.kt index 3cd9e2f7..9f9153b3 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/groovy/GroovyPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/groovy/GroovyPlugin.kt @@ -21,9 +21,6 @@ class GroovyPlugin @Inject constructor(val groovyCompiler: GroovyCompiler, override fun sourceSuffixes() = SOURCE_SUFFIXES - // IDocContributor - override fun affinity(project: Project, context: KobaltContext) = sourceFileCount(project) - // ICompilerFlagsContributor override fun compilerFlagsFor(project: Project, context: KobaltContext, currentFlags: List, suffixesBeingCompiled: List) = diff --git a/src/main/kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt index 62546286..9eb99f47 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt @@ -23,9 +23,6 @@ class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler, override va override val name = PLUGIN_NAME - // IDocContributor - override fun affinity(project: Project, context: KobaltContext) = sourceFileCount(project) - override fun sourceSuffixes() = SOURCE_SUFFIXES override fun generateDoc(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult { diff --git a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt index ae36883a..2a350167 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt @@ -33,7 +33,7 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen // IDocContributor override fun affinity(project: Project, context: KobaltContext) = - if (project.sourceDirectories.any { it.contains("kotlin") }) 2 else 0 + if (sourceFileCount(project) > 0) 2 else 0 override fun generateDoc(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult { return TaskResult()