From 73a7b7b5a0dcda9da8a00dd23aae11c38ca10f77 Mon Sep 17 00:00:00 2001 From: Cedric Beust Date: Wed, 2 Dec 2015 19:09:41 -0800 Subject: [PATCH] Simplify. --- .../kobalt/internal/build/BuildFileCompiler.kt | 14 ++------------ .../internal/remote/GetDependenciesCommand.kt | 8 ++------ .../kotlin/com/beust/kobalt/maven/PomGenerator.kt | 2 +- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/com/beust/kobalt/internal/build/BuildFileCompiler.kt b/src/main/kotlin/com/beust/kobalt/internal/build/BuildFileCompiler.kt index 41ce498d..12dfa7b8 100644 --- a/src/main/kotlin/com/beust/kobalt/internal/build/BuildFileCompiler.kt +++ b/src/main/kotlin/com/beust/kobalt/internal/build/BuildFileCompiler.kt @@ -8,14 +8,12 @@ import com.beust.kobalt.api.KobaltContext import com.beust.kobalt.api.PluginProperties import com.beust.kobalt.api.Project import com.beust.kobalt.internal.PluginInfo -import com.beust.kobalt.internal.build.VersionFile import com.beust.kobalt.maven.DependencyManager import com.beust.kobalt.misc.KFiles import com.beust.kobalt.misc.KobaltExecutors import com.beust.kobalt.misc.log import com.beust.kobalt.plugin.kotlin.kotlinCompilePrivate import com.google.inject.assistedinject.Assisted -import rx.subjects.PublishSubject import java.io.File import java.net.URL import java.nio.file.Paths @@ -35,8 +33,6 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b fun create(@Assisted("buildFiles") buildFiles: List, pluginInfo: PluginInfo) : BuildFileCompiler } - val observable = PublishSubject.create>() - private val SCRIPT_JAR = "buildScript.jar" fun compileBuildFiles(args: Args): List { @@ -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 URL's of all the plug-ins that were found. */ - private fun parseBuildFile(context: KobaltContext, buildFile: BuildFile) : ParsedBuildFile { - // Parse the build file so we can generate preBuildScript and buildScript from it. - with(ParsedBuildFile(buildFile, context, buildScriptUtil, dependencyManager, files)) { - // Notify possible listeners (e.g. KobaltServer) we now have all the projects - observable.onNext(projects) - return this - } - } + private fun parseBuildFile(context: KobaltContext, buildFile: BuildFile) = + ParsedBuildFile(buildFile, context, buildScriptUtil, dependencyManager, files) } diff --git a/src/main/kotlin/com/beust/kobalt/internal/remote/GetDependenciesCommand.kt b/src/main/kotlin/com/beust/kobalt/internal/remote/GetDependenciesCommand.kt index 6dbb49d6..4c07493f 100644 --- a/src/main/kotlin/com/beust/kobalt/internal/remote/GetDependenciesCommand.kt +++ b/src/main/kotlin/com/beust/kobalt/internal/remote/GetDependenciesCommand.kt @@ -30,12 +30,8 @@ class GetDependenciesCommand @Inject constructor(val executors: KobaltExecutors, override fun run(sender: ICommandSender, received: JsonObject) { val buildFile = BuildFile(Paths.get(received.get("buildFile").asString), "GetDependenciesCommand") val scriptCompiler = buildFileCompilerFactory.create(listOf(buildFile), pluginInfo) - scriptCompiler.observable.subscribe { - projects -> if (projects.size > 0) { - sender.sendData(toData(projects)) - } - } - scriptCompiler.compileBuildFiles(args) + val projects = scriptCompiler.compileBuildFiles(args) + sender.sendData(toData(projects)) } private fun toData(projects: List) : CommandData { diff --git a/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt b/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt index c038d71a..d4853dd3 100644 --- a/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt +++ b/src/main/kotlin/com/beust/kobalt/maven/PomGenerator.kt @@ -52,7 +52,7 @@ public class PomGenerator @Inject constructor(@Assisted val project: Project) { val s = StringWriter() 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 mavenId = MavenId.create(project.group!!, project.artifactId!!, project.packaging, project.version!!) val pomFile = SimpleDep(mavenId).toPomFileName()