mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
Inject the Jvm object.
This commit is contained in:
parent
dc1ebfb15d
commit
37709b571c
5 changed files with 23 additions and 14 deletions
|
@ -4,6 +4,7 @@ import com.beust.kobalt.*
|
||||||
import com.beust.kobalt.api.*
|
import com.beust.kobalt.api.*
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
import com.google.common.annotations.VisibleForTesting
|
import com.google.common.annotations.VisibleForTesting
|
||||||
|
import com.google.inject.Inject
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
|
@ -19,6 +20,9 @@ abstract class GenericTestRunner: ITestRunnerContributor {
|
||||||
open var shortMessage: String? = null
|
open var shortMessage: String? = null
|
||||||
open var longMessage: String? = null
|
open var longMessage: String? = null
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private lateinit var jvm: Jvm
|
||||||
|
|
||||||
abstract fun args(project: Project, context: KobaltContext, classpath: List<IClasspathDependency>,
|
abstract fun args(project: Project, context: KobaltContext, classpath: List<IClasspathDependency>,
|
||||||
testConfig: TestConfig) : List<String>
|
testConfig: TestConfig) : List<String>
|
||||||
|
|
||||||
|
@ -116,7 +120,7 @@ abstract class GenericTestRunner: ITestRunnerContributor {
|
||||||
val args = args(project, context, classpath, testConfig)
|
val args = args(project, context, classpath, testConfig)
|
||||||
if (args.size > 0) {
|
if (args.size > 0) {
|
||||||
|
|
||||||
val java = JavaInfo.create(File(SystemProperties.javaBase)).javaExecutable
|
val java = jvm.javaExecutable
|
||||||
val jvmArgs = calculateAllJvmArgs(project, context, testConfig, classpath,
|
val jvmArgs = calculateAllJvmArgs(project, context, testConfig, classpath,
|
||||||
Kobalt.INJECTOR.getInstance (PluginInfo::class.java))
|
Kobalt.INJECTOR.getInstance (PluginInfo::class.java))
|
||||||
val allArgs = arrayListOf<String>().apply {
|
val allArgs = arrayListOf<String>().apply {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.beust.kobalt.app
|
package com.beust.kobalt.app
|
||||||
|
|
||||||
import com.beust.kobalt.Args
|
import com.beust.kobalt.Args
|
||||||
|
import com.beust.kobalt.JavaInfo
|
||||||
|
import com.beust.kobalt.Jvm
|
||||||
import com.beust.kobalt.app.remote.KobaltServer
|
import com.beust.kobalt.app.remote.KobaltServer
|
||||||
import com.beust.kobalt.internal.IncrementalManager
|
import com.beust.kobalt.internal.IncrementalManager
|
||||||
import com.beust.kobalt.internal.KobaltSettings
|
import com.beust.kobalt.internal.KobaltSettings
|
||||||
|
@ -17,6 +19,7 @@ import com.google.inject.Provider
|
||||||
import com.google.inject.Singleton
|
import com.google.inject.Singleton
|
||||||
import com.google.inject.TypeLiteral
|
import com.google.inject.TypeLiteral
|
||||||
import com.google.inject.assistedinject.FactoryModuleBuilder
|
import com.google.inject.assistedinject.FactoryModuleBuilder
|
||||||
|
import java.io.File
|
||||||
import java.util.concurrent.ExecutorService
|
import java.util.concurrent.ExecutorService
|
||||||
|
|
||||||
open class MainModule(val args: Args, val settings: KobaltSettings) : AbstractModule() {
|
open class MainModule(val args: Args, val settings: KobaltSettings) : AbstractModule() {
|
||||||
|
@ -49,15 +52,14 @@ open class MainModule(val args: Args, val settings: KobaltSettings) : AbstractMo
|
||||||
bind(Args::class.java).toProvider(Provider<Args> {
|
bind(Args::class.java).toProvider(Provider<Args> {
|
||||||
args
|
args
|
||||||
})
|
})
|
||||||
EventBus().let { eventBus ->
|
bind(EventBus::class.java).toInstance(EventBus())
|
||||||
bind(EventBus::class.java).toInstance(eventBus)
|
|
||||||
}
|
|
||||||
bind(PluginInfo::class.java).toProvider(Provider<PluginInfo> {
|
bind(PluginInfo::class.java).toProvider(Provider<PluginInfo> {
|
||||||
PluginInfo.readKobaltPluginXml()
|
PluginInfo.readKobaltPluginXml()
|
||||||
}).`in`(Singleton::class.java)
|
}).`in`(Singleton::class.java)
|
||||||
bind(KobaltSettings::class.java).toProvider(Provider<KobaltSettings> {
|
bind(KobaltSettings::class.java).toProvider(Provider<KobaltSettings> {
|
||||||
settings
|
settings
|
||||||
}).`in`(Singleton::class.java)
|
}).`in`(Singleton::class.java)
|
||||||
|
bind(Jvm::class.java).toInstance(JavaInfo.create(File(com.beust.kobalt.SystemProperties.javaBase)))
|
||||||
|
|
||||||
// bindListener(Matchers.any(), object: TypeListener {
|
// bindListener(Matchers.any(), object: TypeListener {
|
||||||
// override fun <I> hear(typeLiteral: TypeLiteral<I>?, typeEncounter: TypeEncounter<I>?) {
|
// override fun <I> hear(typeLiteral: TypeLiteral<I>?, typeEncounter: TypeEncounter<I>?) {
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package com.beust.kobalt.plugin.application
|
package com.beust.kobalt.plugin.application
|
||||||
|
|
||||||
import com.beust.kobalt.*
|
import com.beust.kobalt.Jvm
|
||||||
|
import com.beust.kobalt.KobaltException
|
||||||
|
import com.beust.kobalt.Plugins
|
||||||
|
import com.beust.kobalt.TaskResult
|
||||||
import com.beust.kobalt.api.*
|
import com.beust.kobalt.api.*
|
||||||
import com.beust.kobalt.api.annotation.Directive
|
import com.beust.kobalt.api.annotation.Directive
|
||||||
import com.beust.kobalt.api.annotation.Task
|
import com.beust.kobalt.api.annotation.Task
|
||||||
|
@ -42,7 +45,7 @@ fun Project.application(init: ApplicationConfig.() -> Unit): ApplicationConfig {
|
||||||
@Singleton
|
@Singleton
|
||||||
class ApplicationPlugin @Inject constructor(val configActor: ConfigActor<ApplicationConfig>,
|
class ApplicationPlugin @Inject constructor(val configActor: ConfigActor<ApplicationConfig>,
|
||||||
val executors: KobaltExecutors, val nativeManager: NativeManager,
|
val executors: KobaltExecutors, val nativeManager: NativeManager,
|
||||||
val dependencyManager: DependencyManager, val taskContributor : TaskContributor)
|
val dependencyManager: DependencyManager, val taskContributor : TaskContributor, val jvm: Jvm)
|
||||||
: BasePlugin(), IRunnerContributor, ITaskContributor, IConfigActor<ApplicationConfig> by configActor {
|
: BasePlugin(), IRunnerContributor, ITaskContributor, IConfigActor<ApplicationConfig> by configActor {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -111,7 +114,7 @@ class ApplicationPlugin @Inject constructor(val configActor: ConfigActor<Applica
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val packages = project.projectProperties.get(PackagingPlugin.PACKAGES) as List<PackageConfig>
|
val packages = project.projectProperties.get(PackagingPlugin.PACKAGES) as List<PackageConfig>
|
||||||
val allDeps = arrayListOf(jarName)
|
val allDeps = arrayListOf(jarName)
|
||||||
val java = JavaInfo.create(File(SystemProperties.javaBase)).javaExecutable!!
|
val java = jvm.javaExecutable!!
|
||||||
if (! isFatJar(packages, jarName)) {
|
if (! isFatJar(packages, jarName)) {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
// If the jar file is not fat, we need to add the transitive closure of all dependencies
|
// If the jar file is not fat, we need to add the transitive closure of all dependencies
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package com.beust.kobalt.plugin.java
|
package com.beust.kobalt.plugin.java
|
||||||
|
|
||||||
import com.beust.kobalt.JavaInfo
|
import com.beust.kobalt.Jvm
|
||||||
import com.beust.kobalt.SystemProperties
|
|
||||||
import com.beust.kobalt.TaskResult
|
import com.beust.kobalt.TaskResult
|
||||||
import com.beust.kobalt.api.*
|
import com.beust.kobalt.api.*
|
||||||
import com.beust.kobalt.internal.CompilerUtils
|
import com.beust.kobalt.internal.CompilerUtils
|
||||||
|
@ -22,7 +21,7 @@ import javax.tools.ToolProvider
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltLog: ParallelLogger,
|
class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltLog: ParallelLogger,
|
||||||
val compilerUtils: CompilerUtils) : ICompiler {
|
val compilerUtils: CompilerUtils, val jvm: Jvm) : ICompiler {
|
||||||
fun compilerAction(executable: File) = object : ICompilerAction {
|
fun compilerAction(executable: File) = object : ICompilerAction {
|
||||||
override fun compile(project: Project?, info: CompilerActionInfo): TaskResult {
|
override fun compile(project: Project?, info: CompilerActionInfo): TaskResult {
|
||||||
val projectName = project?.name
|
val projectName = project?.name
|
||||||
|
@ -119,7 +118,7 @@ class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltL
|
||||||
-> it.compilerFlagsFor(project, context, currentFlags, suffixesBeingCompiled) }
|
-> it.compilerFlagsFor(project, context, currentFlags, suffixesBeingCompiled) }
|
||||||
FlagContributor(it.flagPriority, closure)
|
FlagContributor(it.flagPriority, closure)
|
||||||
}
|
}
|
||||||
return run(project, context, info, JavaInfo.create(File(SystemProperties.javaBase)).javacExecutable!!,
|
return run(project, context, info, jvm.javacExecutable!!,
|
||||||
compilerUtils.compilerFlags(project, context, info, adapters))
|
compilerUtils.compilerFlags(project, context, info, adapters))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +129,7 @@ class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltL
|
||||||
-> it.docFlagsFor(project, context, currentFlags, suffixesBeingCompiled) }
|
-> it.docFlagsFor(project, context, currentFlags, suffixesBeingCompiled) }
|
||||||
FlagContributor(it.flagPriority, closure)
|
FlagContributor(it.flagPriority, closure)
|
||||||
}
|
}
|
||||||
return run(project, context, info, JavaInfo.create(File(SystemProperties.javaBase)).javadocExecutable!!,
|
return run(project, context, info, jvm.javadocExecutable!!,
|
||||||
compilerUtils.compilerFlags(project, context, info, adapters))
|
compilerUtils.compilerFlags(project, context, info, adapters))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,8 @@ class KotlinCompiler @Inject constructor(
|
||||||
val settings: KobaltSettings,
|
val settings: KobaltSettings,
|
||||||
val jvmCompiler: JvmCompiler,
|
val jvmCompiler: JvmCompiler,
|
||||||
val compilerUtils: CompilerUtils,
|
val compilerUtils: CompilerUtils,
|
||||||
val kobaltLog: ParallelLogger) {
|
val kobaltLog: ParallelLogger,
|
||||||
|
val jvm: Jvm) {
|
||||||
|
|
||||||
val compilerAction = object: ICompilerAction {
|
val compilerAction = object: ICompilerAction {
|
||||||
override fun compile(project: Project?, info: CompilerActionInfo): TaskResult {
|
override fun compile(project: Project?, info: CompilerActionInfo): TaskResult {
|
||||||
|
@ -99,7 +100,7 @@ class KotlinCompiler @Inject constructor(
|
||||||
|
|
||||||
private fun invokeCompilerInSeparateProcess(classpath: String, info: CompilerActionInfo,
|
private fun invokeCompilerInSeparateProcess(classpath: String, info: CompilerActionInfo,
|
||||||
compilerVersion: String, project: Project?): TaskResult {
|
compilerVersion: String, project: Project?): TaskResult {
|
||||||
val java = JavaInfo.create(File(SystemProperties.javaBase)).javaExecutable
|
val java = jvm.javaExecutable
|
||||||
|
|
||||||
val compilerClasspath = compilerDep(compilerVersion).jarFile.get().path + File.pathSeparator +
|
val compilerClasspath = compilerDep(compilerVersion).jarFile.get().path + File.pathSeparator +
|
||||||
compilerEmbeddableDependencies(null, compilerVersion).map { it.jarFile.get().path }
|
compilerEmbeddableDependencies(null, compilerVersion).map { it.jarFile.get().path }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue