mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Proper assisted injection.
This commit is contained in:
parent
8608df4618
commit
ffc56002c3
3 changed files with 16 additions and 9 deletions
|
@ -38,7 +38,7 @@ class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val buildFil
|
|||
val executors: KobaltExecutors, val buildScriptUtil: BuildScriptUtil, val settings: KobaltSettings,
|
||||
val incrementalManagerFactory: IncrementalManager.IFactory, val args: Args,
|
||||
val aether: KobaltAether, val pomGeneratorFactory: PomGenerator.IFactory,
|
||||
val parallelLogger: ParallelLogger) {
|
||||
val parallelLogger: ParallelLogger, val processedBuildFileFactory: ProcessedBuildFile.IFactory) {
|
||||
|
||||
interface IFactory {
|
||||
fun create(@Assisted("buildFiles") buildFiles: List<BuildFile>, pluginInfo: PluginInfo) : BuildFileCompiler
|
||||
|
@ -167,5 +167,5 @@ class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val buildFil
|
|||
* - the URL's of all the plug-ins that were found.
|
||||
*/
|
||||
private fun parseBuildFile(context: KobaltContext, buildFile: BuildFile) =
|
||||
ProcessedBuildFile(buildFile, context, buildScriptUtil, dependencyManager, files)
|
||||
processedBuildFileFactory.create(buildFile, context)
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ open class MainModule(val args: Args, val settings: KobaltSettings) : AbstractMo
|
|||
Pom.IFactory::class.java,
|
||||
BuildFileCompiler.IFactory::class.java,
|
||||
IncrementalManager.IFactory::class.java,
|
||||
KobaltServer.IFactory::class.java)
|
||||
KobaltServer.IFactory::class.java,
|
||||
ProcessedBuildFile.IFactory::class.java)
|
||||
.forEach {
|
||||
install(builder.build(it))
|
||||
}
|
||||
|
|
|
@ -13,6 +13,8 @@ import com.beust.kobalt.misc.KFiles
|
|||
import com.beust.kobalt.misc.countChar
|
||||
import com.beust.kobalt.misc.kobaltLog
|
||||
import com.beust.kobalt.plugin.kotlin.kotlinCompilePrivate
|
||||
import com.google.inject.Inject
|
||||
import com.google.inject.assistedinject.Assisted
|
||||
import java.io.File
|
||||
import java.net.URL
|
||||
import java.nio.charset.Charset
|
||||
|
@ -22,16 +24,20 @@ import java.util.*
|
|||
/**
|
||||
* Process the given build file (either with kotlinc or through scripting) and return projects and pluginUrls.
|
||||
*/
|
||||
class ProcessedBuildFile(val buildFile: BuildFile, val context: KobaltContext, val buildScriptUtil: BuildScriptUtil,
|
||||
val dependencyManager: DependencyManager, val files: KFiles) {
|
||||
class ProcessedBuildFile @Inject constructor(@Assisted val buildFile: BuildFile, @Assisted val context: KobaltContext,
|
||||
val dependencyManager: DependencyManager, val files: KFiles, val compiledBuildFile: CompiledBuildFile) {
|
||||
|
||||
interface IFactory {
|
||||
fun create(buildFile: BuildFile, context: KobaltContext) : ProcessedBuildFile
|
||||
}
|
||||
|
||||
val pluginUrls = arrayListOf<URL>()
|
||||
val splitFile = SplitBuildFile(buildFile, context, dependencyManager, files)
|
||||
|
||||
fun compile(): BuildFileCompiler.FindProjectResult {
|
||||
|
||||
// Find the projects but also invoke the plugins() directive, which will initialize Plugins.dynamicPlugins
|
||||
val projects = CompiledBuildFile(buildScriptUtil, dependencyManager, files)
|
||||
.findProjects(splitFile, context)
|
||||
val projects = compiledBuildFile.findProjects(splitFile, context)
|
||||
|
||||
// All the plug-ins are now in Plugins.dynamicPlugins, download them if they're not already
|
||||
Plugins.dynamicPlugins.forEach {
|
||||
|
@ -45,8 +51,8 @@ class ProcessedBuildFile(val buildFile: BuildFile, val context: KobaltContext, v
|
|||
/**
|
||||
* Compile a build file with kotlinc.
|
||||
*/
|
||||
class CompiledBuildFile(val buildScriptUtil: BuildScriptUtil, val dependencyManager: DependencyManager,
|
||||
val files: KFiles) {
|
||||
class CompiledBuildFile @Inject constructor(val buildScriptUtil: BuildScriptUtil,
|
||||
val dependencyManager: DependencyManager, val files: KFiles) {
|
||||
|
||||
fun findProjects(splitFile: SplitBuildFile, context: KobaltContext): List<Project> {
|
||||
//
|
Loading…
Add table
Add a link
Reference in a new issue