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
|
@ -1,6 +1,8 @@
|
|||
package com.beust.kobalt.app
|
||||
|
||||
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.internal.IncrementalManager
|
||||
import com.beust.kobalt.internal.KobaltSettings
|
||||
|
@ -17,6 +19,7 @@ import com.google.inject.Provider
|
|||
import com.google.inject.Singleton
|
||||
import com.google.inject.TypeLiteral
|
||||
import com.google.inject.assistedinject.FactoryModuleBuilder
|
||||
import java.io.File
|
||||
import java.util.concurrent.ExecutorService
|
||||
|
||||
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> {
|
||||
args
|
||||
})
|
||||
EventBus().let { eventBus ->
|
||||
bind(EventBus::class.java).toInstance(eventBus)
|
||||
}
|
||||
bind(EventBus::class.java).toInstance(EventBus())
|
||||
bind(PluginInfo::class.java).toProvider(Provider<PluginInfo> {
|
||||
PluginInfo.readKobaltPluginXml()
|
||||
}).`in`(Singleton::class.java)
|
||||
bind(KobaltSettings::class.java).toProvider(Provider<KobaltSettings> {
|
||||
settings
|
||||
}).`in`(Singleton::class.java)
|
||||
bind(Jvm::class.java).toInstance(JavaInfo.create(File(com.beust.kobalt.SystemProperties.javaBase)))
|
||||
|
||||
// bindListener(Matchers.any(), object: TypeListener {
|
||||
// override fun <I> hear(typeLiteral: TypeLiteral<I>?, typeEncounter: TypeEncounter<I>?) {
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
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.annotation.Directive
|
||||
import com.beust.kobalt.api.annotation.Task
|
||||
|
@ -42,7 +45,7 @@ fun Project.application(init: ApplicationConfig.() -> Unit): ApplicationConfig {
|
|||
@Singleton
|
||||
class ApplicationPlugin @Inject constructor(val configActor: ConfigActor<ApplicationConfig>,
|
||||
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 {
|
||||
|
||||
companion object {
|
||||
|
@ -111,7 +114,7 @@ class ApplicationPlugin @Inject constructor(val configActor: ConfigActor<Applica
|
|||
@Suppress("UNCHECKED_CAST")
|
||||
val packages = project.projectProperties.get(PackagingPlugin.PACKAGES) as List<PackageConfig>
|
||||
val allDeps = arrayListOf(jarName)
|
||||
val java = JavaInfo.create(File(SystemProperties.javaBase)).javaExecutable!!
|
||||
val java = jvm.javaExecutable!!
|
||||
if (! isFatJar(packages, jarName)) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
// 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
|
||||
|
||||
import com.beust.kobalt.JavaInfo
|
||||
import com.beust.kobalt.SystemProperties
|
||||
import com.beust.kobalt.Jvm
|
||||
import com.beust.kobalt.TaskResult
|
||||
import com.beust.kobalt.api.*
|
||||
import com.beust.kobalt.internal.CompilerUtils
|
||||
|
@ -22,7 +21,7 @@ import javax.tools.ToolProvider
|
|||
|
||||
@Singleton
|
||||
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 {
|
||||
override fun compile(project: Project?, info: CompilerActionInfo): TaskResult {
|
||||
val projectName = project?.name
|
||||
|
@ -119,7 +118,7 @@ class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltL
|
|||
-> it.compilerFlagsFor(project, context, currentFlags, suffixesBeingCompiled) }
|
||||
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))
|
||||
}
|
||||
|
||||
|
@ -130,7 +129,7 @@ class JavaCompiler @Inject constructor(val jvmCompiler: JvmCompiler, val kobaltL
|
|||
-> it.docFlagsFor(project, context, currentFlags, suffixesBeingCompiled) }
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,8 @@ class KotlinCompiler @Inject constructor(
|
|||
val settings: KobaltSettings,
|
||||
val jvmCompiler: JvmCompiler,
|
||||
val compilerUtils: CompilerUtils,
|
||||
val kobaltLog: ParallelLogger) {
|
||||
val kobaltLog: ParallelLogger,
|
||||
val jvm: Jvm) {
|
||||
|
||||
val compilerAction = object: ICompilerAction {
|
||||
override fun compile(project: Project?, info: CompilerActionInfo): TaskResult {
|
||||
|
@ -99,7 +100,7 @@ class KotlinCompiler @Inject constructor(
|
|||
|
||||
private fun invokeCompilerInSeparateProcess(classpath: String, info: CompilerActionInfo,
|
||||
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 +
|
||||
compilerEmbeddableDependencies(null, compilerVersion).map { it.jarFile.get().path }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue