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