mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
--dryRun.
This commit is contained in:
parent
fc1779f8fa
commit
33684d6d21
13 changed files with 48 additions and 33 deletions
|
@ -9,6 +9,10 @@ class Args {
|
|||
@Parameter(names = arrayOf("-bf", "--buildFile"), description = "The build file")
|
||||
var buildFile: String? = null
|
||||
|
||||
@Parameter(names = arrayOf("--dryRun"), description = "Display all the tasks that will get run without " +
|
||||
"actually running them")
|
||||
var dryRun: Boolean = false
|
||||
|
||||
@Parameter(names = arrayOf("--tasks"), description = "Display the tasks available for this build")
|
||||
var tasks: Boolean = false
|
||||
|
||||
|
|
|
@ -23,9 +23,9 @@ fun plugins(vararg dependency : IClasspathDependency) {
|
|||
|
||||
@Directive
|
||||
fun plugins(vararg dependencies : String) {
|
||||
val executor = INJECTOR.getInstance(KobaltExecutors::class.java)
|
||||
val executor = Kobalt.INJECTOR.getInstance(KobaltExecutors::class.java)
|
||||
.newExecutor("BuildScript", 5)
|
||||
val factory = INJECTOR.getInstance(DepFactory::class.java)
|
||||
val factory = Kobalt.INJECTOR.getInstance(DepFactory::class.java)
|
||||
dependencies.forEach {
|
||||
Plugins.dynamicPlugins.add(factory.create(it, executor))
|
||||
}
|
||||
|
|
|
@ -13,15 +13,24 @@ import com.beust.kobalt.plugin.publish.JCenterApi
|
|||
import com.beust.kobalt.plugin.publish.UnauthenticatedJCenterApi
|
||||
import com.beust.kobalt.wrapper.Wrapper
|
||||
import com.google.inject.Guice
|
||||
import com.google.inject.Injector
|
||||
import java.io.File
|
||||
import java.nio.file.Paths
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
val INJECTOR = Guice.createInjector(MainModule())
|
||||
private fun parseArgs(argv: Array<String>): Main.RunInfo {
|
||||
val args = Args()
|
||||
val result = JCommander(args)
|
||||
result.parse(*argv)
|
||||
KobaltLogger.LOG_LEVEL = args.log
|
||||
return Main.RunInfo(result, args)
|
||||
}
|
||||
|
||||
public fun main(argv: Array<String>) {
|
||||
INJECTOR.getInstance(Main::class.java).run(argv)
|
||||
val (jc, args) = parseArgs(argv)
|
||||
Kobalt.INJECTOR = Guice.createInjector(MainModule(args))
|
||||
Kobalt.INJECTOR.getInstance(Main::class.java).run(jc, args)
|
||||
}
|
||||
|
||||
private class Main @Inject constructor(
|
||||
|
@ -34,17 +43,15 @@ private class Main @Inject constructor(
|
|||
val localRepo: LocalRepo,
|
||||
val depFactory: DepFactory,
|
||||
val checkVersions: CheckVersions,
|
||||
val jcenter: UnauthenticatedJCenterApi,
|
||||
val github: GithubApi)
|
||||
: KobaltLogger {
|
||||
|
||||
data class RunInfo(val jc: JCommander, val args: Args)
|
||||
|
||||
public fun run(argv: Array<String>) {
|
||||
public fun run(jc: JCommander, args: Args) {
|
||||
benchmark("Build", {
|
||||
println(Banner.get() + Kobalt.version + "\n")
|
||||
// runTest()
|
||||
val (jc, args) = parseArgs(argv)
|
||||
runWithArgs(jc, args)
|
||||
executors.shutdown()
|
||||
debug("All done")
|
||||
|
@ -84,14 +91,6 @@ private class Main @Inject constructor(
|
|||
println("Sorted: ${sorted}")
|
||||
}
|
||||
|
||||
private fun parseArgs(argv: Array<String>): RunInfo {
|
||||
val args = Args()
|
||||
val result = JCommander(args)
|
||||
result.parse(*argv)
|
||||
KobaltLogger.LOG_LEVEL = args.log
|
||||
return RunInfo(result, args)
|
||||
}
|
||||
|
||||
private val SCRIPT_JAR = "buildScript.jar"
|
||||
|
||||
private fun runWithArgs(jc: JCommander, args: Args) {
|
||||
|
|
|
@ -64,7 +64,7 @@ public class Plugins @Inject constructor (val taskManagerProvider : Provider<Tas
|
|||
val defaultPlugin : Plugin get() = getPlugin(DefaultPlugin.NAME)!!
|
||||
|
||||
fun addPlugin(pluginClass : Class<out Plugin>) {
|
||||
addPluginInstance(INJECTOR.getInstance(pluginClass))
|
||||
addPluginInstance(Kobalt.INJECTOR.getInstance(pluginClass))
|
||||
}
|
||||
|
||||
private fun addPluginInstance(plugin: Plugin) {
|
||||
|
@ -80,7 +80,7 @@ public class Plugins @Inject constructor (val taskManagerProvider : Provider<Tas
|
|||
PublishPlugin::class.java
|
||||
// AptPlugin::class.java
|
||||
).map {
|
||||
addPluginInstance(INJECTOR.getInstance(it))
|
||||
addPluginInstance(Kobalt.INJECTOR.getInstance(it))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.beust.kobalt.api
|
|||
|
||||
import com.beust.kobalt.misc.Topological
|
||||
import com.google.common.collect.ArrayListMultimap
|
||||
import com.google.inject.Injector
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
import java.nio.file.Files
|
||||
|
@ -24,6 +25,8 @@ public interface ICompilerInfo {
|
|||
|
||||
public class Kobalt {
|
||||
companion object {
|
||||
lateinit var INJECTOR : Injector
|
||||
|
||||
public val compilers : ArrayList<ICompilerInfo> = arrayListOf()
|
||||
|
||||
public fun registerCompiler(c: ICompilerInfo) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.beust.kobalt.internal
|
||||
|
||||
import com.beust.kobalt.Args
|
||||
import com.beust.kobalt.Plugins
|
||||
import com.beust.kobalt.api.PluginTask
|
||||
import com.beust.kobalt.api.Project
|
||||
|
@ -16,7 +17,7 @@ import javax.inject.Inject
|
|||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
public class TaskManager @Inject constructor(val plugins: Plugins) : KobaltLogger {
|
||||
public class TaskManager @Inject constructor(val plugins: Plugins, val args: Args) : KobaltLogger {
|
||||
private val dependentTaskMap = TreeMultimap.create<String, String>()
|
||||
|
||||
/**
|
||||
|
@ -132,7 +133,7 @@ public class TaskManager @Inject constructor(val plugins: Plugins) : KobaltLogge
|
|||
override public fun createWorkers(nodes: List<PluginTask>): List<IWorker<PluginTask>> {
|
||||
val result = arrayListOf<IWorker<PluginTask>>()
|
||||
nodes.forEach {
|
||||
result.add(TaskWorker(arrayListOf(it)))
|
||||
result.add(TaskWorker(arrayListOf(it), args.dryRun))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
@ -144,7 +145,7 @@ public class TaskManager @Inject constructor(val plugins: Plugins) : KobaltLogge
|
|||
}
|
||||
}
|
||||
|
||||
class TaskWorker(val tasks: List<PluginTask>) : IWorker<PluginTask>, KobaltLogger {
|
||||
class TaskWorker(val tasks: List<PluginTask>, val dryRun: Boolean) : IWorker<PluginTask>, KobaltLogger {
|
||||
// override fun compareTo(other: IWorker2<PluginTask>): Int {
|
||||
// return priority.compareTo(other.priority)
|
||||
// }
|
||||
|
@ -157,7 +158,7 @@ class TaskWorker(val tasks: List<PluginTask>) : IWorker<PluginTask>, KobaltLogge
|
|||
}
|
||||
var success = true
|
||||
tasks.forEach {
|
||||
val tr = it.call()
|
||||
val tr = if (dryRun) TaskResult() else it.call()
|
||||
success = success and tr.success
|
||||
}
|
||||
return TaskResult2(success, tasks.get(0))
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package com.beust.kobalt.maven
|
||||
|
||||
import com.beust.kobalt.INJECTOR
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.misc.*
|
||||
import com.google.common.base.CharMatcher
|
||||
import com.google.inject.Key
|
||||
import com.google.inject.assistedinject.Assisted
|
||||
import java.io.File
|
||||
|
@ -51,8 +50,8 @@ public class MavenDependency @Inject constructor(override @Assisted("groupId") v
|
|||
// }
|
||||
|
||||
companion object {
|
||||
val executor = INJECTOR.getInstance(Key.get(ExecutorService::class.java, DependencyExecutor::class.java))
|
||||
val depFactory = INJECTOR.getInstance(DepFactory::class.java)
|
||||
val executor = Kobalt.INJECTOR.getInstance(Key.get(ExecutorService::class.java, DependencyExecutor::class.java))
|
||||
val depFactory = Kobalt.INJECTOR.getInstance(DepFactory::class.java)
|
||||
|
||||
fun create(id: String, ex: ExecutorService = executor) : IClasspathDependency {
|
||||
return depFactory.create(id, ex)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.beust.kobalt.misc
|
||||
|
||||
import com.beust.kobalt.Args
|
||||
import com.beust.kobalt.kotlin.ScriptCompiler
|
||||
import com.beust.kobalt.maven.ArtifactFetcher
|
||||
import com.beust.kobalt.maven.LocalRepo
|
||||
|
@ -8,6 +9,7 @@ import com.beust.kobalt.maven.PomGenerator
|
|||
import com.beust.kobalt.plugin.publish.JCenterApi
|
||||
import com.google.inject.AbstractModule
|
||||
import com.google.inject.BindingAnnotation
|
||||
import com.google.inject.Provider
|
||||
import com.google.inject.TypeLiteral
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder
|
||||
import java.lang.annotation.RetentionPolicy
|
||||
|
@ -24,7 +26,7 @@ import java.util.concurrent.ExecutorService
|
|||
@Retention(AnnotationRetention.RUNTIME)
|
||||
annotation class DependencyExecutor
|
||||
|
||||
public open class MainModule : AbstractModule() {
|
||||
public open class MainModule(val args: Args) : AbstractModule() {
|
||||
val executors = KobaltExecutors()
|
||||
|
||||
open fun configureTest() {
|
||||
|
@ -49,6 +51,9 @@ public open class MainModule : AbstractModule() {
|
|||
bind(object: TypeLiteral<KobaltExecutors>() {}).toInstance(executors)
|
||||
bind(object: TypeLiteral<ExecutorService>() {}).annotatedWith(DependencyExecutor::class.java)
|
||||
.toInstance(executors.dependencyExecutor)
|
||||
bind(Args::class.java).toProvider(object : Provider<Args> {
|
||||
override fun get(): Args? = args
|
||||
})
|
||||
|
||||
|
||||
// bindListener(Matchers.any(), object: TypeListener {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.beust.kobalt.plugin.kotlin;
|
||||
|
||||
import com.beust.kobalt.INJECTOR
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.internal.JvmCompilerPlugin
|
||||
import com.beust.kobalt.internal.TaskResult
|
||||
import com.beust.kobalt.maven.*
|
||||
|
@ -81,7 +81,7 @@ class KConfiguration @Inject constructor(val compiler: KotlinCompiler){
|
|||
}
|
||||
|
||||
fun kotlinCompilePrivate(ini: KConfiguration.() -> Unit) : KConfiguration {
|
||||
val result = INJECTOR.getInstance(KConfiguration::class.java)
|
||||
val result = Kobalt.INJECTOR.getInstance(KConfiguration::class.java)
|
||||
result.ini()
|
||||
return result
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
kobalt.version=0.146
|
||||
kobalt.version=0.147
|
|
@ -1,13 +1,14 @@
|
|||
package com.beust.kobalt
|
||||
|
||||
import com.beust.kobalt.maven.LocalRepo
|
||||
import com.beust.kobalt.misc.MainModule
|
||||
import com.beust.kobalt.plugin.java.SystemProperties
|
||||
import com.google.inject.Scopes
|
||||
import java.io.File
|
||||
|
||||
class TestLocalRepo: LocalRepo(localRepo = SystemProperties.homeDir + File.separatorChar + ".kobalt-test")
|
||||
|
||||
public class TestModule : com.beust.kobalt.misc.MainModule() {
|
||||
public class TestModule(args: Args) : MainModule(args) {
|
||||
override fun configureTest() {
|
||||
bind(LocalRepo::class.java).to(TestLocalRepo::class.java).`in`(Scopes.SINGLETON)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.beust.kobalt.maven
|
||||
|
||||
import com.beust.kobalt.Args
|
||||
import com.beust.kobalt.TestModule
|
||||
import com.beust.kobalt.misc.DependencyExecutor
|
||||
import com.beust.kobalt.misc.MainModule
|
||||
|
@ -11,9 +12,10 @@ import javax.inject.Inject
|
|||
|
||||
@org.testng.annotations.Guice(modules = arrayOf(TestModule::class))
|
||||
public class RemoteRepoTest @Inject constructor(val repoFinder: RepoFinder,
|
||||
@DependencyExecutor val executor: ExecutorService){
|
||||
@DependencyExecutor val executor: ExecutorService,
|
||||
val args: Args){
|
||||
|
||||
val INJECTOR = Guice.createInjector(MainModule())
|
||||
val INJECTOR = Guice.createInjector(MainModule(args))
|
||||
|
||||
@Test
|
||||
public fun mavenMetadata() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue