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

Fix tests.

This commit is contained in:
Cedric Beust 2016-04-12 23:43:27 -08:00
parent 4db516a3fb
commit a38889e94f
7 changed files with 22 additions and 14 deletions

View file

@ -10,7 +10,8 @@ import com.google.inject.Inject
* Plug-ins that are ITaskContributor can use this class to manage their collection of tasks and * Plug-ins that are ITaskContributor can use this class to manage their collection of tasks and
* implement the interface by delegating to an instance of this class (if injection permits). * implement the interface by delegating to an instance of this class (if injection permits).
*/ */
class TaskContributor @Inject constructor(val incrementalManager: IncrementalManager) : ITaskContributor { class TaskContributor @Inject constructor(val incrementalManagerFactory: IncrementalManager.IFactory)
: ITaskContributor {
val dynamicTasks = arrayListOf<DynamicTask>() val dynamicTasks = arrayListOf<DynamicTask>()
/** /**
@ -50,7 +51,7 @@ class TaskContributor @Inject constructor(val incrementalManager: IncrementalMan
runBefore = runBefore.map { variant.toTask(it) }, runBefore = runBefore.map { variant.toTask(it) },
runAfter = runAfter.map { variant.toTask(it) }, runAfter = runAfter.map { variant.toTask(it) },
alwaysRunAfter = alwaysRunAfter.map { variant.toTask(it) }, alwaysRunAfter = alwaysRunAfter.map { variant.toTask(it) },
closure = incrementalManager.toIncrementalTaskClosure(taskName, runTask, variant))) closure = incrementalManagerFactory.create().toIncrementalTaskClosure(taskName, runTask, variant)))
} }
} }

View file

@ -11,7 +11,7 @@ import com.beust.kobalt.misc.log
import com.google.gson.Gson import com.google.gson.Gson
import com.google.gson.GsonBuilder import com.google.gson.GsonBuilder
import com.google.inject.Inject import com.google.inject.Inject
import com.google.inject.Singleton import com.google.inject.assistedinject.Assisted
import java.io.File import java.io.File
import java.io.FileReader import java.io.FileReader
import java.nio.charset.Charset import java.nio.charset.Charset
@ -27,9 +27,11 @@ class BuildInfo(var tasks: List<TaskInfo>)
* Manage the file .kobalt/buildInfo.json, which keeps track of input and output checksums to manage * Manage the file .kobalt/buildInfo.json, which keeps track of input and output checksums to manage
* incremental builds. * incremental builds.
*/ */
@Singleton class IncrementalManager @Inject constructor(val args: Args, @Assisted val fileName : String) {
class IncrementalManager @Inject constructor(val args: Args) {
val fileName = IncrementalManager.BUILD_INFO_FILE interface IFactory {
fun create(@Assisted fileName: String = IncrementalManager.BUILD_INFO_FILE) : IncrementalManager
}
companion object { companion object {
val BUILD_INFO_FILE = KFiles.joinDir(KFiles.KOBALT_DOT_DIR, "buildInfo.json") val BUILD_INFO_FILE = KFiles.joinDir(KFiles.KOBALT_DOT_DIR, "buildInfo.json")

View file

@ -21,7 +21,8 @@ import javax.inject.Inject
import javax.inject.Singleton import javax.inject.Singleton
@Singleton @Singleton
public class TaskManager @Inject constructor(val args: Args, val incrementalManager: IncrementalManager) { public class TaskManager @Inject constructor(val args: Args,
val incrementalManagerFactory: IncrementalManager.IFactory) {
private val runBefore = TreeMultimap.create<String, String>() private val runBefore = TreeMultimap.create<String, String>()
private val alwaysRunAfter = TreeMultimap.create<String, String>() private val alwaysRunAfter = TreeMultimap.create<String, String>()
@ -280,7 +281,7 @@ public class TaskManager @Inject constructor(val args: Args, val incrementalMana
*/ */
fun toTaskAnnotation(method: Method, plugin: IPlugin, ta: IncrementalTask) fun toTaskAnnotation(method: Method, plugin: IPlugin, ta: IncrementalTask)
= TaskAnnotation(method, plugin, ta.name, ta.description, ta.runBefore, ta.runAfter, ta.alwaysRunAfter, = TaskAnnotation(method, plugin, ta.name, ta.description, ta.runBefore, ta.runAfter, ta.alwaysRunAfter,
incrementalManager.toIncrementalTaskClosure(ta.name, { project -> incrementalManagerFactory.create().toIncrementalTaskClosure(ta.name, { project ->
method.invoke(plugin, project) as IncrementalTaskInfo method.invoke(plugin, project) as IncrementalTaskInfo
})) }))

View file

@ -33,7 +33,9 @@ class DependencyManager @Inject constructor(val executors: KobaltExecutors, val
} }
return createFile(path.path) return createFile(path.path)
} else { } else {
return createMaven(id) // Convert to a Kobalt id first (so that if it doesn't have a version, it gets translated to
// an Aether ranged id "[0,)")
return createMaven(MavenId.create(id).toId)
} }
} }

View file

@ -1,6 +1,7 @@
package com.beust.kobalt.app package com.beust.kobalt.app
import com.beust.kobalt.Args import com.beust.kobalt.Args
import com.beust.kobalt.internal.IncrementalManager
import com.beust.kobalt.internal.KobaltSettings import com.beust.kobalt.internal.KobaltSettings
import com.beust.kobalt.internal.PluginInfo import com.beust.kobalt.internal.PluginInfo
import com.beust.kobalt.maven.LocalRepo import com.beust.kobalt.maven.LocalRepo
@ -32,7 +33,8 @@ public open class MainModule(val args: Args, val settings: KobaltSettings) : Abs
PomGenerator.IFactory::class.java, PomGenerator.IFactory::class.java,
BintrayApi.IFactory::class.java, BintrayApi.IFactory::class.java,
Pom.IFactory::class.java, Pom.IFactory::class.java,
BuildFileCompiler.IFactory::class.java) BuildFileCompiler.IFactory::class.java,
IncrementalManager.IFactory::class.java)
.forEach { .forEach {
install(builder.build(it)) install(builder.build(it))
} }

View file

@ -20,7 +20,7 @@ import javax.inject.Singleton
@Singleton @Singleton
class PackagingPlugin @Inject constructor(val dependencyManager : DependencyManager, class PackagingPlugin @Inject constructor(val dependencyManager : DependencyManager,
val incrementalManager: IncrementalManager, val incrementalManagerFactory: IncrementalManager.IFactory,
val executors: KobaltExecutors, val jarGenerator: JarGenerator, val warGenerator: WarGenerator, val executors: KobaltExecutors, val jarGenerator: JarGenerator, val warGenerator: WarGenerator,
val zipGenerator: ZipGenerator, val taskContributor: TaskContributor, val zipGenerator: ZipGenerator, val taskContributor: TaskContributor,
val pomFactory: PomGenerator.IFactory, val configActor: ConfigActor<InstallConfig>) val pomFactory: PomGenerator.IFactory, val configActor: ConfigActor<InstallConfig>)
@ -84,8 +84,8 @@ class PackagingPlugin @Inject constructor(val dependencyManager : DependencyMana
// Incremental assembly contributors // Incremental assembly contributors
context.pluginInfo.incrementalAssemblyContributors.forEach { context.pluginInfo.incrementalAssemblyContributors.forEach {
val taskInfo = it.assemble(project, context) val taskInfo = it.assemble(project, context)
val closure = incrementalManager.toIncrementalTaskClosure(TASK_ASSEMBLE, { p: Project -> taskInfo }, val closure = incrementalManagerFactory.create().toIncrementalTaskClosure(TASK_ASSEMBLE, {
context.variant) p: Project -> taskInfo }, context.variant)
val thisResult = closure.invoke(project) val thisResult = closure.invoke(project)
if (! thisResult.success) { if (! thisResult.success) {
// Abort at the first failure // Abort at the first failure

View file

@ -13,7 +13,7 @@ class IncrementalManagerTest {
fun shouldSave() { fun shouldSave() {
val file = File.createTempFile("kobalt-", "") val file = File.createTempFile("kobalt-", "")
println("File: $file") println("File: $file")
val im = IncrementalManager(Args())//, file.absolutePath) val im = IncrementalManager(Args(), file.absolutePath)
val v = im.inputChecksumFor(TASK) val v = im.inputChecksumFor(TASK)
Assert.assertNull(v) Assert.assertNull(v)
im.saveInputChecksum(TASK, "44") im.saveInputChecksum(TASK, "44")