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

Refactor the three compilers.

This commit is contained in:
Cedric Beust 2016-06-24 01:28:52 -08:00
parent a8b693b238
commit c9393cb0ca
8 changed files with 66 additions and 88 deletions

View file

@ -2,7 +2,7 @@ package com.beust.kobalt.api
import com.beust.kobalt.TaskResult
interface ICompiler : Comparable<ICompiler> {
interface ICompilerDescription : Comparable<ICompilerDescription> {
/**
* The suffixes handled by this compiler (without the dot, e.g. "java" or "kt").
*/
@ -27,7 +27,7 @@ interface ICompiler : Comparable<ICompiler> {
*/
val priority: Int get() = DEFAULT_PRIORITY
override fun compareTo(other: ICompiler) = priority.compareTo(other.priority)
override fun compareTo(other: ICompilerDescription) = priority.compareTo(other.priority)
/**
* Can this compiler be passed directories or does it need individual source files?
@ -36,5 +36,5 @@ interface ICompiler : Comparable<ICompiler> {
}
interface ICompilerContributor : IProjectAffinity, IContributor {
fun compilersFor(project: Project, context: KobaltContext): List<ICompiler>
fun compilersFor(project: Project, context: KobaltContext): List<ICompilerDescription>
}

View file

@ -18,7 +18,7 @@ class CompilerUtils @Inject constructor(val files: KFiles,
class CompilerResult(val successResults: List<TaskResult>, val failedResult: TaskResult?)
fun invokeCompiler(project: Project, context: KobaltContext, compiler: ICompiler,
fun invokeCompiler(project: Project, context: KobaltContext, compiler: ICompilerDescription,
sourceDirectories: List<File>, isTest: Boolean): CompilerResult {
val results = arrayListOf<TaskResult>()
var failedResult: TaskResult? = null
@ -47,7 +47,7 @@ class CompilerUtils @Inject constructor(val files: KFiles,
return CompilerResult(results, failedResult)
}
fun invokeCompiler(project: Project, context: KobaltContext, compiler: ICompiler, info: CompilerActionInfo)
fun invokeCompiler(project: Project, context: KobaltContext, compiler: ICompilerDescription, info: CompilerActionInfo)
: CompilerResult {
val results = arrayListOf<TaskResult>()
var failedResult: TaskResult? = null
@ -63,7 +63,7 @@ class CompilerUtils @Inject constructor(val files: KFiles,
* Create a CompilerActionInfo (all the information that a compiler needs to know) for the given parameters.
* Runs all the contributors and interceptors relevant to that task.
*/
fun createCompilerActionInfo(project: Project, context: KobaltContext, compiler: ICompiler,
fun createCompilerActionInfo(project: Project, context: KobaltContext, compiler: ICompilerDescription,
isTest: Boolean, sourceDirectories: List<File>, sourceSuffixes: List<String>): CompilerActionInfo {
copyResources(project, context, SourceSet.of(isTest))

View file

@ -163,7 +163,7 @@ open class JvmCompilerPlugin @Inject constructor(
/**
* Swap the Java and Kotlin compilers from the list.
*/
fun swapJavaAndKotlin(allCompilers: List<ICompiler>): List<ICompiler> {
fun swapJavaAndKotlin(allCompilers: List<ICompilerDescription>): List<ICompilerDescription> {
val result = ArrayList(allCompilers)
var ik = -1
var ij = -1