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

Deprecate Build.kt in the root dir.

This commit is contained in:
Cedric Beust 2015-12-13 08:21:37 +04:00
parent d71cdf7010
commit 4fb726be91
4 changed files with 22 additions and 13 deletions

View file

@ -0,0 +1,6 @@
package com.beust.kobalt
object Constants {
val BUILD_FILE_NAME = "Build.kt"
val BUILD_FILE_DIRECTORY = "kobalt/src"
}

View file

@ -252,16 +252,15 @@ private class Main @Inject constructor(
}
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()
}
} catch(ex: NoSuchElementException) {
return File(KFiles.joinFileAndMakeDir("kobalt", "src", "Build.kt"))
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))
}
return result
}
}

View file

@ -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
@ -78,7 +79,8 @@ public class BuildFileCompiler @Inject constructor(@Assisted("buildFiles") val b
// compile it, jar it in buildScript.jar and run it
val modifiedBuildFile = KFiles.createTempFile(".kt")
KFiles.saveFile(modifiedBuildFile, parsedBuildFile.buildScriptCode)
maybeCompileBuildFile(context, BuildFile(Paths.get(modifiedBuildFile.path), "Modified Build.kt"),
maybeCompileBuildFile(context, BuildFile(Paths.get(modifiedBuildFile.path),
"Modified ${Constants.BUILD_FILE_NAME}"),
buildScriptJarFile, pluginUrls)
val projects = buildScriptUtil.runBuildScriptJarFile(buildScriptJarFile, pluginUrls, context)
result.addAll(projects)

View file

@ -1,6 +1,7 @@
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
@ -79,6 +80,7 @@ class GetDependenciesCommand @Inject constructor(val executors: KobaltExecutors,
fun main(argv: Array<String>) {
val socket = Socket("localhost", 1234)
(PrintWriter(socket.outputStream, true)).use { out ->
out.println("""{ "name" : "getDependencies", "buildFile": "/Users/beust/kotlin/kobalt/kobalt/src/Build.kt"}""")
out.println("""{ "name" : "getDependencies", "buildFile":
"/Users/beust/kotlin/kobalt/kobalt/src/${Constants.BUILD_FILE_NAME}"}""")
}
}