1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 08:27:12 -07:00

Pull a few functions up in BaseJvmPlugin.

This commit is contained in:
Cedric Beust 2017-02-14 11:15:48 -08:00
parent 23360b6077
commit 86dec889f2
4 changed files with 4 additions and 8 deletions

View file

@ -24,12 +24,14 @@ abstract class BaseJvmPlugin<T>(open val configActor: ConfigActor<T>) :
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<String>
}

View file

@ -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<String>,
suffixesBeingCompiled: List<String>) =

View file

@ -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 {

View file

@ -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()