From 94e2e7081c03412dbb017a9852477e38de01cb0b Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 29 Jun 2016 22:12:10 -0800 Subject: [PATCH] Add "name" property to CompilerDescription. --- .../beust/kobalt/api/ICompilerContributor.kt | 23 +++++++++++-------- .../beust/kobalt/internal/CompilerUtils.kt | 2 +- .../beust/kobalt/plugin/java/JavaPlugin.kt | 2 +- .../kobalt/plugin/kotlin/KotlinPlugin.kt | 9 ++------ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ICompilerContributor.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ICompilerContributor.kt index 3a852098..4883bf32 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ICompilerContributor.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/api/ICompilerContributor.kt @@ -4,6 +4,11 @@ import com.beust.kobalt.TaskResult import com.beust.kobalt.misc.warn interface ICompilerDescription : Comparable { + /** + * The name of the language compiled by this compiler. + */ + val name: String + /** * The suffixes handled by this compiler (without the dot, e.g. "java" or "kt"). */ @@ -44,17 +49,17 @@ interface ICompiler { fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo): TaskResult } -class CompilerDescription(override val sourceSuffixes: List, override val sourceDirectory: String, - val compiler: ICompiler, override val priority: Int = ICompilerDescription.DEFAULT_PRIORITY) -: ICompilerDescription { +class CompilerDescription(override val name: String, override val sourceDirectory: String, + override val sourceSuffixes: List, val compiler: ICompiler, + override val priority: Int = ICompilerDescription.DEFAULT_PRIORITY) : ICompilerDescription { override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo): TaskResult { val result = - if (info.sourceFiles.size > 0) { - compiler.compile(project, context, info) - } else { - warn("Couldn't find any source files to compile") - TaskResult() - } + if (info.sourceFiles.size > 0) { + compiler.compile(project, context, info) + } else { + warn("Couldn't find any source files to compile") + TaskResult() + } return result } } diff --git a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt index ffd05b1b..a102999a 100644 --- a/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt +++ b/modules/kobalt-plugin-api/src/main/kotlin/com/beust/kobalt/internal/CompilerUtils.kt @@ -41,7 +41,7 @@ class CompilerUtils @Inject constructor(val files: KFiles, failedResult = thisResult.failedResult } } else { - log(2, "Compiler $compiler not running on ${project.name} since no source files were found") + log(2, "${compiler.name} compiler not running on ${project.name} since no source files were found") } return CompilerResult(results, failedResult) 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 59db628f..b6d2cc79 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/java/JavaPlugin.kt @@ -47,7 +47,7 @@ class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler, override va configurationFor(project)?.compilerArgs ?: listOf()) // ICompilerContributor - val compiler = CompilerDescription(SOURCE_SUFFIXES, "java", javaCompiler) + val compiler = CompilerDescription(PLUGIN_NAME, "java", SOURCE_SUFFIXES, javaCompiler) override fun compilersFor(project: Project, context: KobaltContext) = listOf(compiler) 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 48f46cc0..fd62e272 100644 --- a/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt +++ b/src/main/kotlin/com/beust/kobalt/plugin/kotlin/KotlinPlugin.kt @@ -11,7 +11,6 @@ import com.beust.kobalt.internal.KotlinJarFiles import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.maven.dependency.FileDependency import com.beust.kobalt.misc.KobaltExecutors -import com.beust.kobalt.misc.log import com.beust.kobalt.misc.warn import javax.inject.Inject import javax.inject.Singleton @@ -111,7 +110,7 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen // ICompilerContributor /** The Kotlin compiler should run before the Java one, hence priority - 5 */ - val compiler = CompilerDescription(SOURCE_SUFFIXES, "kotlin", KotlinCompiler(), + val compiler = CompilerDescription(PLUGIN_NAME, "kotlin", SOURCE_SUFFIXES, KotlinCompiler(), ICompilerDescription.DEFAULT_PRIORITY - 5) override fun compilersFor(project: Project, context: KobaltContext) = arrayListOf(compiler) @@ -122,10 +121,6 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen // dokkaConfigurations.put(project.name, dokkaConfig) // } - protected fun lp(project: Project, s: String) { - log(2, "${project.name}: $s") - } - override val buildConfigSuffix = "kt" override fun generateBuildConfig(project: Project, context: KobaltContext, packageName: String, @@ -135,7 +130,7 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen } /** - * @param project: the list of projects that need to be built before this one. + * @param projects: the list of projects that need to be built before this one. */ @Directive fun kotlinProject(vararg projects: Project, init: Project.() -> Unit): Project {