1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-27 00:38:11 -07:00

Simplify.

This commit is contained in:
Cedric Beust 2015-12-02 19:09:41 -08:00
parent cbfbdd21a1
commit 73a7b7b5a0
3 changed files with 5 additions and 19 deletions

View file

@ -8,14 +8,12 @@ import com.beust.kobalt.api.KobaltContext
import com.beust.kobalt.api.PluginProperties import com.beust.kobalt.api.PluginProperties
import com.beust.kobalt.api.Project import com.beust.kobalt.api.Project
import com.beust.kobalt.internal.PluginInfo import com.beust.kobalt.internal.PluginInfo
import com.beust.kobalt.internal.build.VersionFile
import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.maven.DependencyManager
import com.beust.kobalt.misc.KFiles import com.beust.kobalt.misc.KFiles
import com.beust.kobalt.misc.KobaltExecutors import com.beust.kobalt.misc.KobaltExecutors
import com.beust.kobalt.misc.log import com.beust.kobalt.misc.log
import com.beust.kobalt.plugin.kotlin.kotlinCompilePrivate import com.beust.kobalt.plugin.kotlin.kotlinCompilePrivate
import com.google.inject.assistedinject.Assisted import com.google.inject.assistedinject.Assisted
import rx.subjects.PublishSubject
import java.io.File import java.io.File
import java.net.URL import java.net.URL
import java.nio.file.Paths import java.nio.file.Paths
@ -35,8 +33,6 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b
fun create(@Assisted("buildFiles") buildFiles: List<BuildFile>, pluginInfo: PluginInfo) : BuildFileCompiler fun create(@Assisted("buildFiles") buildFiles: List<BuildFile>, pluginInfo: PluginInfo) : BuildFileCompiler
} }
val observable = PublishSubject.create<List<Project>>()
private val SCRIPT_JAR = "buildScript.jar" private val SCRIPT_JAR = "buildScript.jar"
fun compileBuildFiles(args: Args): List<Project> { fun compileBuildFiles(args: Args): List<Project> {
@ -115,12 +111,6 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b
* - the source code for the modified Build.kt (after profiles are applied) * - the source code for the modified Build.kt (after profiles are applied)
* - the URL's of all the plug-ins that were found. * - the URL's of all the plug-ins that were found.
*/ */
private fun parseBuildFile(context: KobaltContext, buildFile: BuildFile) : ParsedBuildFile { private fun parseBuildFile(context: KobaltContext, buildFile: BuildFile) =
// Parse the build file so we can generate preBuildScript and buildScript from it. ParsedBuildFile(buildFile, context, buildScriptUtil, dependencyManager, files)
with(ParsedBuildFile(buildFile, context, buildScriptUtil, dependencyManager, files)) {
// Notify possible listeners (e.g. KobaltServer) we now have all the projects
observable.onNext(projects)
return this
}
}
} }

View file

@ -30,12 +30,8 @@ class GetDependenciesCommand @Inject constructor(val executors: KobaltExecutors,
override fun run(sender: ICommandSender, received: JsonObject) { override fun run(sender: ICommandSender, received: JsonObject) {
val buildFile = BuildFile(Paths.get(received.get("buildFile").asString), "GetDependenciesCommand") val buildFile = BuildFile(Paths.get(received.get("buildFile").asString), "GetDependenciesCommand")
val scriptCompiler = buildFileCompilerFactory.create(listOf(buildFile), pluginInfo) val scriptCompiler = buildFileCompilerFactory.create(listOf(buildFile), pluginInfo)
scriptCompiler.observable.subscribe { val projects = scriptCompiler.compileBuildFiles(args)
projects -> if (projects.size > 0) { sender.sendData(toData(projects))
sender.sendData(toData(projects))
}
}
scriptCompiler.compileBuildFiles(args)
} }
private fun toData(projects: List<Project>) : CommandData { private fun toData(projects: List<Project>) : CommandData {

View file

@ -52,7 +52,7 @@ public class PomGenerator @Inject constructor(@Assisted val project: Project) {
val s = StringWriter() val s = StringWriter()
MavenXpp3Writer().write(s, m) MavenXpp3Writer().write(s, m)
val buildDir = KFiles.makeDir(project.directory, project.buildDirectory!!) val buildDir = KFiles.makeDir(project.directory, project.buildDirectory)
val outputDir = KFiles.makeDir(buildDir.path, "libs") val outputDir = KFiles.makeDir(buildDir.path, "libs")
val mavenId = MavenId.create(project.group!!, project.artifactId!!, project.packaging, project.version!!) val mavenId = MavenId.create(project.group!!, project.artifactId!!, project.packaging, project.version!!)
val pomFile = SimpleDep(mavenId).toPomFileName() val pomFile = SimpleDep(mavenId).toPomFileName()