mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-29 17:38:12 -07:00
Switch to the new plug-in architecture.
This commit is contained in:
parent
f5601b1f5c
commit
91b9cc64f4
6 changed files with 148 additions and 123 deletions
|
@ -1,7 +1,9 @@
|
|||
package com.beust.kobalt
|
||||
|
||||
import com.beust.jcommander.JCommander
|
||||
import com.beust.kobalt.api.*
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.api.PluginInfo
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.internal.TaskManager
|
||||
import com.beust.kobalt.internal.remote.KobaltClient
|
||||
import com.beust.kobalt.internal.remote.KobaltServer
|
||||
|
@ -17,7 +19,6 @@ import java.io.File
|
|||
import java.nio.file.Paths
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
import javax.xml.bind.JAXBContext
|
||||
|
||||
public fun main(argv: Array<String>) {
|
||||
val result = mainNoExit(argv)
|
||||
|
@ -34,6 +35,7 @@ private fun parseArgs(argv: Array<String>): Main.RunInfo {
|
|||
return Main.RunInfo(result, args)
|
||||
}
|
||||
|
||||
|
||||
public fun mainNoExit(argv: Array<String>) : Int {
|
||||
val (jc, args) = parseArgs(argv)
|
||||
Kobalt.INJECTOR = Guice.createInjector(MainModule(args))
|
||||
|
@ -54,7 +56,7 @@ private class Main @Inject constructor(
|
|||
val updateKobalt: UpdateKobalt,
|
||||
val client: KobaltClient,
|
||||
val server: KobaltServer,
|
||||
val pluginInfoDescription: PluginInfoDescription) {
|
||||
val pluginInfo: PluginInfo) {
|
||||
|
||||
data class RunInfo(val jc: JCommander, val args: Args)
|
||||
|
||||
|
@ -93,11 +95,11 @@ private class Main @Inject constructor(
|
|||
|
||||
public fun runTest() {
|
||||
val file = File("src\\main\\resources\\META-INF\\plugin.xml")
|
||||
val jaxbContext = JAXBContext.newInstance(KobaltPluginXml::class.java)
|
||||
|
||||
val kotlinPlugin : KobaltPluginXml = jaxbContext.createUnmarshaller().unmarshal(file) as KobaltPluginXml
|
||||
val pluginInfo = PluginInfo.create(kotlinPlugin)
|
||||
System.out.println(kotlinPlugin.name)
|
||||
// val jaxbContext = JAXBContext.newInstance(KobaltPluginXml::class.java)
|
||||
//
|
||||
// val kotlinPlugin : KobaltPluginXml = jaxbContext.createUnmarshaller().unmarshal(file) as KobaltPluginXml
|
||||
// val pluginInfo = PluginInfo.create(kotlinPlugin)
|
||||
// System.out.println(kotlinPlugin.name)
|
||||
}
|
||||
|
||||
private fun runWithArgs(jc: JCommander, args: Args) : Int {
|
||||
|
@ -124,10 +126,10 @@ private class Main @Inject constructor(
|
|||
if (! buildFile.exists()) {
|
||||
error(buildFile.path.toFile().path + " does not exist")
|
||||
} else {
|
||||
var allProjects = listOf<Project>()
|
||||
val pluginInfo = PluginInfo(pluginInfoDescription)
|
||||
var allProjects = arrayListOf<Project>()
|
||||
try {
|
||||
allProjects = buildFileCompilerFactory.create(listOf(buildFile), pluginInfo).compileBuildFiles(args)
|
||||
allProjects.addAll(buildFileCompilerFactory.create(listOf(buildFile), pluginInfo)
|
||||
.compileBuildFiles(args))
|
||||
} catch(ex: Throwable) {
|
||||
// This can happen if the ABI for the build script file changed. Try to wipe .kobalt.
|
||||
log(2, "Couldn't parse preBuildScript.jar: ${ex.message}")
|
||||
|
@ -136,8 +138,8 @@ private class Main @Inject constructor(
|
|||
return 1
|
||||
} else {
|
||||
log(1, "Deleted .kobalt")
|
||||
allProjects = buildFileCompilerFactory.create(listOf(buildFile), pluginInfo)
|
||||
.compileBuildFiles(args)
|
||||
allProjects.addAll(buildFileCompilerFactory.create(listOf(buildFile), pluginInfo)
|
||||
.compileBuildFiles(args))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +174,6 @@ private class Main @Inject constructor(
|
|||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun findBuildFile(): File {
|
||||
val files = arrayListOf("Build.kt", "build.kobalt", KFiles.src("build.kobalt"),
|
||||
KFiles.src("Build.kt"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue