mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 16:28:12 -07:00
Kotlin compiler should run first.
This commit is contained in:
parent
c23693a4f2
commit
7bea179d69
3 changed files with 36 additions and 24 deletions
|
@ -2,7 +2,7 @@ package com.beust.kobalt.api
|
||||||
|
|
||||||
import com.beust.kobalt.TaskResult
|
import com.beust.kobalt.TaskResult
|
||||||
|
|
||||||
interface ICompiler {
|
interface ICompiler : Comparable<ICompiler> {
|
||||||
/**
|
/**
|
||||||
* 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").
|
||||||
*/
|
*/
|
||||||
|
@ -17,6 +17,17 @@ interface ICompiler {
|
||||||
* Run the compilation based on the info.
|
* Run the compilation based on the info.
|
||||||
*/
|
*/
|
||||||
fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult
|
fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo) : TaskResult
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val DEFAULT_PRIORITY: Int = 5
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The priority of this compiler. Lower priority compilers are run first.
|
||||||
|
*/
|
||||||
|
val priority: Int get() = DEFAULT_PRIORITY
|
||||||
|
|
||||||
|
override fun compareTo(other: ICompiler) = priority.compareTo(other.priority)
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ICompilerContributor : IProjectAffinity {
|
interface ICompilerContributor : IProjectAffinity {
|
||||||
|
|
|
@ -194,8 +194,8 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
if (compilerContributors.isEmpty()) {
|
if (compilerContributors.isEmpty()) {
|
||||||
throw KobaltException("Couldn't find any compiler for project ${project.name}")
|
throw KobaltException("Couldn't find any compiler for project ${project.name}")
|
||||||
} else {
|
} else {
|
||||||
compilerContributors.forEach { contributor ->
|
val allCompilers = compilerContributors.flatMap { it.compilersFor(project, context)}.sorted()
|
||||||
contributor.compilersFor(project, context).forEach { compiler ->
|
allCompilers.forEach { compiler ->
|
||||||
val contributedSourceDirs =
|
val contributedSourceDirs =
|
||||||
if (isTest) {
|
if (isTest) {
|
||||||
context.testSourceDirectories(project)
|
context.testSourceDirectories(project)
|
||||||
|
@ -218,7 +218,6 @@ open class JvmCompilerPlugin @Inject constructor(
|
||||||
log(2, "Compiler $compiler not running on ${project.name} since no source files were found")
|
log(2, "Compiler $compiler not running on ${project.name} since no source files were found")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return if (failedResult != null) failedResult!!
|
return if (failedResult != null) failedResult!!
|
||||||
else if (results.size > 0) results[0]
|
else if (results.size > 0) results[0]
|
||||||
else TaskResult(true)
|
else TaskResult(true)
|
||||||
|
|
|
@ -19,8 +19,7 @@ import javax.inject.Singleton
|
||||||
@Singleton
|
@Singleton
|
||||||
class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val dependencyManager: DependencyManager,
|
class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val dependencyManager: DependencyManager,
|
||||||
override val configActor: ConfigActor<KotlinConfig>)
|
override val configActor: ConfigActor<KotlinConfig>)
|
||||||
: BaseJvmPlugin<KotlinConfig>(configActor), IDocContributor, IClasspathContributor, ICompilerContributor,
|
: BaseJvmPlugin<KotlinConfig>(configActor), IDocContributor, IClasspathContributor, ICompilerContributor, IBuildConfigContributor {
|
||||||
IBuildConfigContributor {
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
const val PLUGIN_NAME = "Kotlin"
|
const val PLUGIN_NAME = "Kotlin"
|
||||||
|
@ -116,6 +115,9 @@ class KotlinPlugin @Inject constructor(val executors: KobaltExecutors, val depen
|
||||||
val compiler = object: ICompiler {
|
val compiler = object: ICompiler {
|
||||||
override val sourceSuffixes = listOf("kt")
|
override val sourceSuffixes = listOf("kt")
|
||||||
|
|
||||||
|
/** The Kotlin compiler should run before the Java one */
|
||||||
|
override val priority: Int get() = ICompiler.DEFAULT_PRIORITY - 1
|
||||||
|
|
||||||
override val sourceDirectory = "kotlin"
|
override val sourceDirectory = "kotlin"
|
||||||
|
|
||||||
override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo): TaskResult {
|
override fun compile(project: Project, context: KobaltContext, info: CompilerActionInfo): TaskResult {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue