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

kapt work.

This commit is contained in:
Cedric Beust 2016-06-02 23:37:39 -08:00
parent 814eb57396
commit a4a044c6b9
7 changed files with 93 additions and 14 deletions

View file

@ -79,7 +79,9 @@ class Plugins @Inject constructor (val taskManagerProvider : Provider<TaskManage
// Collect all the tasks from the task contributors
context.pluginInfo.taskContributors.forEach {
taskManager.dynamicTasks.addAll(it.tasksFor(context))
projects.forEach { project ->
taskManager.dynamicTasks.addAll(it.tasksFor(project, context))
}
}
// Now that we have collected all static and dynamic tasks, turn them all into plug-in tasks

View file

@ -8,7 +8,7 @@ import com.beust.kobalt.internal.TaskResult2
* to implement this interface.
*/
interface ITaskContributor : IContributor {
fun tasksFor(context: KobaltContext) : List<DynamicTask>
fun tasksFor(project: Project, context: KobaltContext) : List<DynamicTask>
}
class DynamicTask(override val plugin: IPlugin, override val name: String, override val doc: String,

View file

@ -63,5 +63,5 @@ class TaskContributor @Inject constructor(val incrementalManagerFactory: Increme
}
}
override fun tasksFor(context: KobaltContext) : List<DynamicTask> = dynamicTasks
override fun tasksFor(project: Project, context: KobaltContext) : List<DynamicTask> = dynamicTasks
}

View file

@ -34,10 +34,10 @@ class CompilerUtils @Inject constructor(val files: KFiles,
// once and pass them
val info = createCompilerActionInfo(project, context, compiler, isTest,
sourceDirectories, sourceSuffixes = compiler.sourceSuffixes)
val thisResult = compiler.compile(project, context, info)
results.add(thisResult)
if (!thisResult.success && failedResult == null) {
failedResult = thisResult
val thisResult = invokeCompiler(project, context, compiler, info)
results.addAll(thisResult.successResults)
if (failedResult == null) {
failedResult = thisResult.failedResult
}
} else {
log(2, "Compiler $compiler not running on ${project.name} since no source files were found")
@ -46,6 +46,18 @@ class CompilerUtils @Inject constructor(val files: KFiles,
return CompilerResult(results, failedResult)
}
fun invokeCompiler(project: Project, context: KobaltContext, compiler: ICompiler, info: CompilerActionInfo)
: CompilerResult {
val results = arrayListOf<TaskResult>()
var failedResult: TaskResult? = null
val thisResult = compiler.compile(project, context, info)
results.add(thisResult)
if (!thisResult.success && failedResult == null) {
failedResult = thisResult
}
return CompilerResult(results, failedResult)
}
/**
* 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.
@ -55,7 +67,7 @@ class CompilerUtils @Inject constructor(val files: KFiles,
copyResources(project, context, SourceSet.of(isTest))
val fullClasspath = if (isTest) dependencyManager.testDependencies(project, context)
else dependencyManager.dependencies(project, context)
else dependencyManager.dependencies(project, context)
// Remove all the excluded dependencies from the classpath
val classpath = fullClasspath.filter {
@ -66,7 +78,6 @@ class CompilerUtils @Inject constructor(val files: KFiles,
else File(project.classesDir(context))
buildDirectory.mkdirs()
val initialSourceDirectories = ArrayList<File>(sourceDirectories)
// Source directories from the contributors
val contributedSourceDirs =