mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Add "name" property to CompilerDescription.
This commit is contained in:
parent
1cea9e7fad
commit
94e2e7081c
4 changed files with 18 additions and 18 deletions
|
@ -4,6 +4,11 @@ import com.beust.kobalt.TaskResult
|
|||
import com.beust.kobalt.misc.warn
|
||||
|
||||
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").
|
||||
*/
|
||||
|
@ -44,17 +49,17 @@ interface ICompiler {
|
|||
fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo): TaskResult
|
||||
}
|
||||
|
||||
class CompilerDescription(override val sourceSuffixes: List<String>, 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<String>, 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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -47,7 +47,7 @@ class JavaPlugin @Inject constructor(val javaCompiler: JavaCompiler, override va
|
|||
configurationFor(project)?.compilerArgs ?: listOf<String>())
|
||||
|
||||
// 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)
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue