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

Add "name" property to CompilerDescription.

This commit is contained in:
Cedric Beust 2016-06-29 22:12:10 -08:00
parent 1cea9e7fad
commit 94e2e7081c
4 changed files with 18 additions and 18 deletions

View file

@ -4,6 +4,11 @@ import com.beust.kobalt.TaskResult
import com.beust.kobalt.misc.warn import com.beust.kobalt.misc.warn
interface ICompilerDescription : Comparable<ICompilerDescription> { interface ICompilerDescription : Comparable<ICompilerDescription> {
/**
* 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"). * 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 fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo): TaskResult
} }
class CompilerDescription(override val sourceSuffixes: List<String>, override val sourceDirectory: String, class CompilerDescription(override val name: String, override val sourceDirectory: String,
val compiler: ICompiler, override val priority: Int = ICompilerDescription.DEFAULT_PRIORITY) override val sourceSuffixes: List<String>, val compiler: ICompiler,
: ICompilerDescription { override val priority: Int = ICompilerDescription.DEFAULT_PRIORITY) : ICompilerDescription {
override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo): TaskResult { override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo): TaskResult {
val result = val result =
if (info.sourceFiles.size > 0) { if (info.sourceFiles.size > 0) {
compiler.compile(project, context, info) compiler.compile(project, context, info)
} else { } else {
warn("Couldn't find any source files to compile") warn("Couldn't find any source files to compile")
TaskResult() TaskResult()
} }
return result return result
} }
} }

View file

@ -41,7 +41,7 @@ class CompilerUtils @Inject constructor(val files: KFiles,
failedResult = thisResult.failedResult failedResult = thisResult.failedResult
} }
} else { } 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) return CompilerResult(results, failedResult)

View file

@ -47,7 +47,7 @@ class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler, override va
configurationFor(project)?.compilerArgs ?: listOf<String>()) configurationFor(project)?.compilerArgs ?: listOf<String>())
// ICompilerContributor // 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) override fun compilersFor(project: Project, context: KobaltContext) = listOf(compiler)

View file

@ -11,7 +11,6 @@ import com.beust.kobalt.internal.KotlinJarFiles
import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.maven.DependencyManager
import com.beust.kobalt.maven.dependency.FileDependency import com.beust.kobalt.maven.dependency.FileDependency
import com.beust.kobalt.misc.KobaltExecutors import com.beust.kobalt.misc.KobaltExecutors
import com.beust.kobalt.misc.log
import com.beust.kobalt.misc.warn import com.beust.kobalt.misc.warn
import javax.inject.Inject import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@ -111,7 +110,7 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen
// ICompilerContributor // ICompilerContributor
/** The Kotlin compiler should run before the Java one, hence priority - 5 */ /** 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) ICompilerDescription.DEFAULT_PRIORITY - 5)
override fun compilersFor(project: Project, context: KobaltContext) = arrayListOf(compiler) 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) // dokkaConfigurations.put(project.name, dokkaConfig)
// } // }
protected fun lp(project: Project, s: String) {
log(2, "${project.name}: $s")
}
override val buildConfigSuffix = "kt" override val buildConfigSuffix = "kt"
override fun generateBuildConfig(project: Project, context: KobaltContext, packageName: String, 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 @Directive
fun kotlinProject(vararg projects: Project, init: Project.() -> Unit): Project { fun kotlinProject(vararg projects: Project, init: Project.() -> Unit): Project {