diff --git a/.idea/modules.xml b/.idea/modules.xml
index 82188f15..fced32d6 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,8 +2,9 @@
+
-
+
\ No newline at end of file
diff --git a/kobalt/Build.kt.iml b/kobalt/Build.kt.iml
new file mode 100644
index 00000000..2c926abd
--- /dev/null
+++ b/kobalt/Build.kt.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/kobalt/wrapper/kobalt-wrapper.properties b/kobalt/wrapper/kobalt-wrapper.properties
index d74a87c1..0ba6e5fb 100644
--- a/kobalt/wrapper/kobalt-wrapper.properties
+++ b/kobalt/wrapper/kobalt-wrapper.properties
@@ -1 +1 @@
-kobalt.version=0.329
\ No newline at end of file
+kobalt.version=0.334
\ No newline at end of file
diff --git a/kobaltw b/kobaltw
index b27b3d89..1fd228db 100755
--- a/kobaltw
+++ b/kobaltw
@@ -1 +1,2 @@
+#!/usr/bin/env bash
java -jar $(dirname $0)/kobalt/wrapper/kobalt-wrapper.jar $*
diff --git a/src/main/kotlin/com/beust/kobalt/AsciiArt.kt b/src/main/kotlin/com/beust/kobalt/AsciiArt.kt
index 6cf5d5d9..de16f9d7 100644
--- a/src/main/kotlin/com/beust/kobalt/AsciiArt.kt
+++ b/src/main/kotlin/com/beust/kobalt/AsciiArt.kt
@@ -85,11 +85,13 @@ class AsciiArt {
const val WHITE = "\u001B[37m"
private fun wrap(s: String, color: String) = color + s + RESET
+ private fun blue(s: String) = wrap(s, BLUE)
private fun red(s: String) = wrap(s, RED)
private fun yellow(s: String) = wrap(s, YELLOW)
- fun taskColor(s: String) = yellow(s)
+ fun taskColor(s: String) = s
fun errorColor(s: String) = red(s)
+ fun warnColor(s: String) = red(s)
}
}
diff --git a/src/main/kotlin/com/beust/kobalt/BuildScript.kt b/src/main/kotlin/com/beust/kobalt/BuildScript.kt
index 1b96858b..11a783fd 100644
--- a/src/main/kotlin/com/beust/kobalt/BuildScript.kt
+++ b/src/main/kotlin/com/beust/kobalt/BuildScript.kt
@@ -5,7 +5,6 @@ import com.beust.kobalt.api.Kobalt
import com.beust.kobalt.api.annotation.Directive
import com.beust.kobalt.maven.DepFactory
import com.beust.kobalt.maven.dependency.FileDependency
-import com.beust.kobalt.misc.KobaltExecutors
import java.io.File
@Directive
@@ -17,15 +16,14 @@ fun file(file: String) : String = FileDependency.PREFIX_FILE + file
@Directive
fun plugins(vararg dependency : IClasspathDependency) {
- Plugins.dynamicPlugins.addAll(dependency)
+ dependency.forEach { Plugins.addDynamicPlugin(it) }
}
@Directive
fun plugins(vararg dependencies : String) {
- val executor = Kobalt.INJECTOR.getInstance(KobaltExecutors::class.java).miscExecutor
val factory = Kobalt.INJECTOR.getInstance(DepFactory::class.java)
dependencies.forEach {
- Plugins.dynamicPlugins.add(factory.create(it, executor))
+ Plugins.addDynamicPlugin(factory.create(it))
}
}
diff --git a/src/main/kotlin/com/beust/kobalt/Constants.kt b/src/main/kotlin/com/beust/kobalt/Constants.kt
new file mode 100644
index 00000000..56fe4f09
--- /dev/null
+++ b/src/main/kotlin/com/beust/kobalt/Constants.kt
@@ -0,0 +1,6 @@
+package com.beust.kobalt
+
+object Constants {
+ val BUILD_FILE_NAME = "Build.kt"
+ val BUILD_FILE_DIRECTORY = "kobalt/src"
+}
diff --git a/src/main/kotlin/com/beust/kobalt/Main.kt b/src/main/kotlin/com/beust/kobalt/Main.kt
index 364d74bd..a0367cd9 100644
--- a/src/main/kotlin/com/beust/kobalt/Main.kt
+++ b/src/main/kotlin/com/beust/kobalt/Main.kt
@@ -251,17 +251,16 @@ 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"))
- try {
- return files.map {
- File(SystemProperties.currentDir, it)
- }.first {
- it.exists()
+ private fun findBuildFile() : File {
+ val deprecatedLocation = File(Constants.BUILD_FILE_NAME)
+ val result: File =
+ if (deprecatedLocation.exists()) {
+ warn(Constants.BUILD_FILE_NAME + " is in a deprecated location, please move it to "
+ + Constants.BUILD_FILE_DIRECTORY)
+ deprecatedLocation
+ } else {
+ File(KFiles.joinDir(Constants.BUILD_FILE_DIRECTORY, Constants.BUILD_FILE_NAME))
}
- } catch(ex: NoSuchElementException) {
- return File("Build.kt")
- }
+ return result
}
}
diff --git a/src/main/kotlin/com/beust/kobalt/Plugins.kt b/src/main/kotlin/com/beust/kobalt/Plugins.kt
index 2de5cdc9..9720613b 100644
--- a/src/main/kotlin/com/beust/kobalt/Plugins.kt
+++ b/src/main/kotlin/com/beust/kobalt/Plugins.kt
@@ -41,7 +41,8 @@ public class Plugins @Inject constructor (val taskManagerProvider : Provider = arrayListOf()
+ internal val dynamicPlugins : ArrayList = arrayListOf()
+ fun addDynamicPlugin(plugin: IClasspathDependency) = dynamicPlugins.add(plugin)
val defaultPlugin : IPlugin get() = findPlugin(KobaltPlugin.PLUGIN_NAME)!!
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 12dfa7b8..09eaf904 100644
--- a/src/main/kotlin/com/beust/kobalt/internal/build/BuildFileCompiler.kt
+++ b/src/main/kotlin/com/beust/kobalt/internal/build/BuildFileCompiler.kt
@@ -1,6 +1,7 @@
package com.beust.kobalt.internal.build
import com.beust.kobalt.Args
+import com.beust.kobalt.Constants
import com.beust.kobalt.KobaltException
import com.beust.kobalt.Plugins
import com.beust.kobalt.api.Kobalt
@@ -55,11 +56,14 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b
return allProjects
}
+ val parsedBuildFiles = arrayListOf()
+
private fun findProjects(context: KobaltContext): List {
val result = arrayListOf()
buildFiles.forEach { buildFile ->
- val processBuildFile = parseBuildFile(context, buildFile)
- val pluginUrls = processBuildFile.pluginUrls
+ val parsedBuildFile = parseBuildFile(context, buildFile)
+ parsedBuildFiles.add(parsedBuildFile)
+ val pluginUrls = parsedBuildFile.pluginUrls
val buildScriptJarFile = File(KFiles.findBuildScriptLocation(buildFile, SCRIPT_JAR))
// If the script jar files were generated by a different version, wipe them in case the API
@@ -74,8 +78,9 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b
// Write the modified Build.kt (e.g. maybe profiles were applied) to a temporary file,
// compile it, jar it in buildScript.jar and run it
val modifiedBuildFile = KFiles.createTempFile(".kt")
- KFiles.saveFile(modifiedBuildFile, processBuildFile.buildScriptCode)
- maybeCompileBuildFile(context, BuildFile(Paths.get(modifiedBuildFile.path), "Modified Build.kt"),
+ KFiles.saveFile(modifiedBuildFile, parsedBuildFile.buildScriptCode)
+ maybeCompileBuildFile(context, BuildFile(Paths.get(modifiedBuildFile.path),
+ "Modified ${Constants.BUILD_FILE_NAME}"),
buildScriptJarFile, pluginUrls)
val projects = buildScriptUtil.runBuildScriptJarFile(buildScriptJarFile, pluginUrls, context)
result.addAll(projects)
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 4c07493f..4e5f7ae0 100644
--- a/src/main/kotlin/com/beust/kobalt/internal/remote/GetDependenciesCommand.kt
+++ b/src/main/kotlin/com/beust/kobalt/internal/remote/GetDependenciesCommand.kt
@@ -1,12 +1,14 @@
package com.beust.kobalt.internal.remote
import com.beust.kobalt.Args
+import com.beust.kobalt.Constants
import com.beust.kobalt.api.IClasspathDependency
import com.beust.kobalt.api.Project
import com.beust.kobalt.internal.PluginInfo
import com.beust.kobalt.internal.build.BuildFile
import com.beust.kobalt.internal.build.BuildFileCompiler
import com.beust.kobalt.maven.DependencyManager
+import com.beust.kobalt.maven.dependency.FileDependency
import com.beust.kobalt.maven.dependency.MavenDependency
import com.beust.kobalt.misc.KobaltExecutors
import com.beust.kobalt.misc.log
@@ -14,6 +16,7 @@ import com.google.gson.Gson
import com.google.gson.JsonObject
import java.io.PrintWriter
import java.net.Socket
+import java.net.URL
import java.nio.file.Paths
import javax.inject.Inject
@@ -29,12 +32,12 @@ class GetDependenciesCommand @Inject constructor(val executors: KobaltExecutors,
override val name = "getDependencies"
override fun run(sender: ICommandSender, received: JsonObject) {
val buildFile = BuildFile(Paths.get(received.get("buildFile").asString), "GetDependenciesCommand")
- val scriptCompiler = buildFileCompilerFactory.create(listOf(buildFile), pluginInfo)
- val projects = scriptCompiler.compileBuildFiles(args)
- sender.sendData(toData(projects))
+ val buildFileCompiler = buildFileCompilerFactory.create(listOf(buildFile), pluginInfo)
+ val projects = buildFileCompiler.compileBuildFiles(args)
+ sender.sendData(toData(projects, buildFileCompiler.parsedBuildFiles.flatMap { it.pluginUrls }))
}
- private fun toData(projects: List) : CommandData {
+ private fun toData(projects: List, pluginUrls: List) : CommandData {
val projectDatas = arrayListOf()
val executor = executors.miscExecutor
@@ -45,8 +48,10 @@ class GetDependenciesCommand @Inject constructor(val executors: KobaltExecutors,
fun allDeps(l: List) = dependencyManager.transitiveClosure(l)
+ val pluginDependencies = pluginUrls.map { java.io.File(it.toURI()) }.map { FileDependency(it.absolutePath) }
projects.forEach { project ->
val allDependencies =
+ pluginDependencies.map { toDependencyData(it, "compile")} +
allDeps(project.compileDependencies).map { toDependencyData(it, "compile") } +
allDeps(project.compileProvidedDependencies).map { toDependencyData(it, "provided") } +
allDeps(project.compileRuntimeDependencies).map { toDependencyData(it, "runtime") } +
@@ -75,6 +80,7 @@ class GetDependenciesCommand @Inject constructor(val executors: KobaltExecutors,
fun main(argv: Array) {
val socket = Socket("localhost", 1234)
(PrintWriter(socket.outputStream, true)).use { out ->
- out.println("""{ "name" : "getDependencies", "buildFile": "/c/users/cbeust/kotlin/kobalt/kobalt/src/Build.kt" }""")
+ out.println("""{ "name" : "getDependencies", "buildFile":
+ "/Users/beust/kotlin/kobalt/kobalt/src/${Constants.BUILD_FILE_NAME}"}""")
}
}
\ No newline at end of file
diff --git a/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt b/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt
index 0796dd9f..a8d5a17f 100644
--- a/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt
+++ b/src/main/kotlin/com/beust/kobalt/misc/KobaltLogger.kt
@@ -75,7 +75,7 @@ class Logger(val dev: Boolean) {
final fun warn(tag: String, message: String, e: Throwable? = null) {
val fullMessage = "***** WARNING " + (e?.message ?: message)
- println(getPattern("W", fullMessage, fullMessage, tag))
+ println(AsciiArt.Companion.warnColor(getPattern("W", fullMessage, fullMessage, tag)))
}
final fun log(tag: String, message: String, newLine: Boolean) =
diff --git a/src/main/kotlin/com/beust/kobalt/plugin/packaging/JarUtils.kt b/src/main/kotlin/com/beust/kobalt/plugin/packaging/JarUtils.kt
index 07403fd4..ccce2653 100644
--- a/src/main/kotlin/com/beust/kobalt/plugin/packaging/JarUtils.kt
+++ b/src/main/kotlin/com/beust/kobalt/plugin/packaging/JarUtils.kt
@@ -109,7 +109,7 @@ public class JarUtils {
while (enumEntries.hasMoreElements()) {
val file = enumEntries.nextElement()
if (file.name == fileName) {
- log(2, "Found $fileName in $zip")
+ log(2, "Found $fileName in ${zip.name}")
zip.getInputStream(file).use { ins ->
return CharStreams.toString(InputStreamReader(ins, "UTF-8"))
}
diff --git a/src/main/resources/kobalt.properties b/src/main/resources/kobalt.properties
index 82d77614..0056770c 100644
--- a/src/main/resources/kobalt.properties
+++ b/src/main/resources/kobalt.properties
@@ -1 +1 @@
-kobalt.version=0.329
+kobalt.version=0.334