mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Support for --download.
This commit is contained in:
parent
13b87527f6
commit
ae7511be25
10 changed files with 264 additions and 282 deletions
|
@ -2,6 +2,7 @@
|
|||
import com.beust.kobalt.api.License
|
||||
import com.beust.kobalt.api.Project
|
||||
import com.beust.kobalt.api.Scm
|
||||
import com.beust.kobalt.file
|
||||
import com.beust.kobalt.homeDir
|
||||
import com.beust.kobalt.internal.TaskResult
|
||||
import com.beust.kobalt.internal.test
|
||||
|
@ -11,6 +12,7 @@ import com.beust.kobalt.plugin.java.javaProject
|
|||
import com.beust.kobalt.plugin.kotlin.kotlinCompiler
|
||||
import com.beust.kobalt.plugin.kotlin.kotlinProject
|
||||
import com.beust.kobalt.plugin.packaging.assemble
|
||||
import com.beust.kobalt.plugin.publish.jcenter
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
|
@ -71,7 +73,8 @@ val kobalt = kotlinProject(wrapper) {
|
|||
"org.apache.maven:maven-model:3.3.3",
|
||||
"com.github.spullara.mustache.java:compiler:0.9.1",
|
||||
"io.reactivex:rxjava:1.0.14",
|
||||
"com.google.code.gson:gson:2.4"
|
||||
"com.google.code.gson:gson:2.4",
|
||||
file("modules/wrapper/kobaltBuild/libs/kobalt-wrapper.jar")
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -103,10 +106,10 @@ val kobalt = kotlinProject(wrapper) {
|
|||
args("-nowarn")
|
||||
}
|
||||
|
||||
// jcenter {
|
||||
// publish = true
|
||||
// file("$buildDirectory/libs/$name-$version.zip", "$name/$version/$name-$version.zip")
|
||||
// }
|
||||
jcenter {
|
||||
publish = true
|
||||
file("$buildDirectory/libs/$name-$version.zip", "$name/$version/$name-$version.zip")
|
||||
}
|
||||
}
|
||||
|
||||
fun readVersion() : String {
|
||||
|
|
Binary file not shown.
|
@ -1,2 +1 @@
|
|||
kobalt.version=0.238
|
||||
kobalt.downloadUrl=https://github.com/cbeust/kobalt/releases/download/0.238/kobalt-0.238.zip
|
||||
kobalt.version=0.244
|
|
@ -34,8 +34,12 @@ public class Main {
|
|||
private static int logLevel = 1;
|
||||
|
||||
private void installAndLaunchMain(String[] argv) throws IOException, InterruptedException {
|
||||
boolean noLaunch = false;
|
||||
for (int i = 0; i < argv.length; i++) {
|
||||
switch(argv[i]) {
|
||||
case "--no-launch":
|
||||
noLaunch = true;
|
||||
break;
|
||||
case "--log":
|
||||
logLevel = Integer.parseInt(argv[i + 1]);
|
||||
i++;
|
||||
|
@ -43,8 +47,10 @@ public class Main {
|
|||
}
|
||||
}
|
||||
Path kobaltJarFile = installJarFile();
|
||||
if (! noLaunch) {
|
||||
launchMain(kobaltJarFile, argv);
|
||||
}
|
||||
}
|
||||
|
||||
private void readProperties(Properties properties, InputStream ins) throws IOException {
|
||||
properties.load(ins);
|
||||
|
@ -106,7 +112,6 @@ public class Main {
|
|||
Path kobaltJarFile = Paths.get(zipOutputDir,
|
||||
getWrapperDir().getPath() + "/" + FILE_NAME + "-" + getWrapperVersion() + ".jar");
|
||||
if (! Files.exists(localZipFile) || ! Files.exists(kobaltJarFile)) {
|
||||
if (!Files.exists(localZipFile)) {
|
||||
download(localZipFile.toFile());
|
||||
}
|
||||
|
||||
|
@ -142,12 +147,11 @@ public class Main {
|
|||
download(localZipFile.toFile());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Copy the wrapper files in the current kobalt/wrapper directory
|
||||
//
|
||||
if (! version.equals(getWrapperVersion())) {
|
||||
boolean sameVersion = equals(getWrapperVersion());
|
||||
log(2, "Copying the wrapper files");
|
||||
for (String file : FILES) {
|
||||
Path from = Paths.get(zipOutputDir, file);
|
||||
|
@ -163,9 +167,7 @@ public class Main {
|
|||
}
|
||||
}
|
||||
new File(KOBALTW).setExecutable(true);
|
||||
} else {
|
||||
log(2, "Wrapper and current versions are identical");
|
||||
}
|
||||
|
||||
return kobaltJarFile;
|
||||
}
|
||||
|
||||
|
@ -267,8 +269,6 @@ public class Main {
|
|||
System.out.println("[Wrapper error] *** " + s);
|
||||
}
|
||||
|
||||
private static final String KOBALT_MAIN_CLASS = "com.beust.kobalt.KobaltPackage";
|
||||
|
||||
private void launchMain(Path kobaltJarFile, String[] argv) throws IOException, InterruptedException {
|
||||
List<String> args = new ArrayList<>();
|
||||
args.add("java");
|
||||
|
|
|
@ -19,6 +19,9 @@ class Args {
|
|||
@Parameter(names = arrayOf("--dev"), description = "Turn of dev mode, resulting in a more verbose log output")
|
||||
var dev: Boolean = false
|
||||
|
||||
@Parameter(names = arrayOf("--download"), description = "Force a download from the downloadUrl in the wrapper")
|
||||
var download: Boolean = false
|
||||
|
||||
@Parameter(names = arrayOf("--dryRun"), description = "Display all the tasks that will get run without " +
|
||||
"actually running them")
|
||||
var dryRun: Boolean = false
|
||||
|
|
|
@ -14,7 +14,6 @@ import com.beust.kobalt.maven.Http
|
|||
import com.beust.kobalt.maven.KobaltException
|
||||
import com.beust.kobalt.maven.LocalRepo
|
||||
import com.beust.kobalt.misc.*
|
||||
import com.beust.kobalt.wrapper.Wrapper
|
||||
import com.google.inject.Guice
|
||||
import java.io.File
|
||||
import java.nio.file.Paths
|
||||
|
@ -40,7 +39,7 @@ private fun parseArgs(argv: Array<String>): Main.RunInfo {
|
|||
public fun mainNoExit(argv: Array<String>): Int {
|
||||
val (jc, args) = parseArgs(argv)
|
||||
Kobalt.INJECTOR = Guice.createInjector(MainModule(args))
|
||||
return Kobalt.INJECTOR.getInstance(Main::class.java).run(jc, args)
|
||||
return Kobalt.INJECTOR.getInstance(Main::class.java).run(jc, args, argv)
|
||||
}
|
||||
|
||||
private class Main @Inject constructor(
|
||||
|
@ -59,8 +58,7 @@ private class Main @Inject constructor(
|
|||
val server: KobaltServer,
|
||||
val pluginInfo: PluginInfo,
|
||||
val projectGenerator: ProjectGenerator,
|
||||
val resolveDependency: ResolveDependency,
|
||||
val wrapper: Wrapper) {
|
||||
val resolveDependency: ResolveDependency) {
|
||||
|
||||
data class RunInfo(val jc: JCommander, val args: Args)
|
||||
|
||||
|
@ -71,7 +69,7 @@ private class Main @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
public fun run(jc: JCommander, args: Args) : Int {
|
||||
public fun run(jc: JCommander, args: Args, argv: Array<String>): Int {
|
||||
|
||||
//
|
||||
// Add all the repos from repo contributors (at least those that return values without a Project)
|
||||
|
@ -95,7 +93,7 @@ private class Main @Inject constructor(
|
|||
val seconds = benchmark("build", {
|
||||
// runTest()
|
||||
try {
|
||||
result = runWithArgs(jc, args)
|
||||
result = runWithArgs(jc, args, argv)
|
||||
} catch(ex: KobaltException) {
|
||||
error(ex.message ?: "", ex)
|
||||
result = 1
|
||||
|
@ -124,7 +122,7 @@ private class Main @Inject constructor(
|
|||
// val file = File("src\\main\\resources\\META-INF\\plugin.ml")
|
||||
// }
|
||||
|
||||
private fun runWithArgs(jc: JCommander, args: Args) : Int {
|
||||
private fun runWithArgs(jc: JCommander, args: Args, argv: Array<String>): Int {
|
||||
var result = 0
|
||||
val p = if (args.buildFile != null) File(args.buildFile) else findBuildFile()
|
||||
args.buildFile = p.absolutePath
|
||||
|
@ -137,8 +135,9 @@ private class Main @Inject constructor(
|
|||
if (args.init) {
|
||||
//
|
||||
// --init: create a new build project and install the wrapper
|
||||
// Make sure the wrapper won't call us back with --no-launch
|
||||
//
|
||||
wrapper.install()
|
||||
com.beust.kobalt.wrapper.Main.main(arrayOf("--no-launch") + argv)
|
||||
projectGenerator.run(args)
|
||||
} else if (args.usage) {
|
||||
jc.usage()
|
||||
|
@ -177,6 +176,8 @@ private class Main @Inject constructor(
|
|||
println(sb.toString())
|
||||
} else if (args.checkVersions) {
|
||||
checkVersions.run(allProjects)
|
||||
} else if (args.download) {
|
||||
updateKobalt.downloadKobalt()
|
||||
} else if (args.update) {
|
||||
updateKobalt.updateKobalt()
|
||||
} else {
|
||||
|
@ -192,6 +193,7 @@ 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"))
|
||||
|
|
|
@ -15,12 +15,6 @@ class KobaltWrapperProperties @Inject constructor() {
|
|||
private val PROPERTY_VERSION = "kobalt.version"
|
||||
private val PROPERTY_DOWNLOAD_URL = "kobalt.downloadUrl"
|
||||
|
||||
fun defaultUrlFor(version: String) =
|
||||
"bogushttps://github.com/cbeust/kobalt/releases/download/$version/kobalt-$version.zip"
|
||||
|
||||
val file: File
|
||||
get() = File("$WRAPPER_DIR/$KOBALT_WRAPPER_PROPERTIES")
|
||||
|
||||
fun create(version: String) {
|
||||
log(2, "Creating $file with $version and ${defaultUrlFor(version)}")
|
||||
KFiles.saveFile(file, listOf(
|
||||
|
@ -29,7 +23,13 @@ class KobaltWrapperProperties @Inject constructor() {
|
|||
).joinToString("\n"))
|
||||
}
|
||||
|
||||
val properties : Properties
|
||||
private fun defaultUrlFor(version: String) =
|
||||
"https://github.com/cbeust/kobalt/releases/download/$version/kobalt-$version.zip"
|
||||
|
||||
private val file: File
|
||||
get() = File("$WRAPPER_DIR/$KOBALT_WRAPPER_PROPERTIES")
|
||||
|
||||
private val properties : Properties
|
||||
get() {
|
||||
val config = file
|
||||
if (!config.exists()) {
|
||||
|
@ -45,20 +45,5 @@ class KobaltWrapperProperties @Inject constructor() {
|
|||
get() = properties.getProperty(PROPERTY_VERSION)
|
||||
|
||||
val downloadUrl : String
|
||||
get() {
|
||||
return properties.getProperty(PROPERTY_DOWNLOAD_URL)
|
||||
?: defaultUrlFor(version)
|
||||
}
|
||||
|
||||
fun maybeCreate(version: String) {
|
||||
if (! file.exists()) {
|
||||
create(version)
|
||||
}
|
||||
}
|
||||
|
||||
// fun urlFor(version: String) : String {
|
||||
// // val URL = "https://dl.bintray.com/cbeust/generic/"
|
||||
// // return "https://dl.bintray.com/cbeust/generic/$fileName-$version.zip"
|
||||
// return downloadUrl ?: defaultUrlFor(version)
|
||||
// }
|
||||
get() = properties.getProperty(PROPERTY_DOWNLOAD_URL)
|
||||
}
|
||||
|
|
|
@ -5,10 +5,17 @@ import javax.inject.Inject
|
|||
/**
|
||||
* Update Kobalt to the latest version.
|
||||
*/
|
||||
public class UpdateKobalt @Inject constructor(val github: GithubApi, val kobaltWrapperProperties: KobaltWrapperProperties) {
|
||||
public class UpdateKobalt @Inject constructor(val github: GithubApi, val wrapperProperties: KobaltWrapperProperties) {
|
||||
fun updateKobalt() {
|
||||
val newVersion = github.latestKobaltVersion
|
||||
kobaltWrapperProperties.maybeCreate(newVersion.get())
|
||||
com.beust.kobalt.wrapper.main(arrayOf())
|
||||
wrapperProperties.create(newVersion.get())
|
||||
com.beust.kobalt.wrapper.Main.main(arrayOf())
|
||||
}
|
||||
|
||||
/**
|
||||
* Download from the URL found in the kobalt-wrapper.properties regardless of what the latest version is
|
||||
*/
|
||||
fun downloadKobalt() {
|
||||
com.beust.kobalt.wrapper.Main.main(arrayOf("--download"))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,187 +1,170 @@
|
|||
package com.beust.kobalt.wrapper
|
||||
|
||||
import com.beust.kobalt.JavaInfo
|
||||
import com.beust.kobalt.SystemProperties
|
||||
import com.beust.kobalt.api.Kobalt
|
||||
import com.beust.kobalt.maven.Http
|
||||
import com.beust.kobalt.misc.KFiles
|
||||
import com.beust.kobalt.misc.KobaltWrapperProperties
|
||||
import com.beust.kobalt.misc.benchmark
|
||||
import com.beust.kobalt.misc.log
|
||||
import com.google.inject.Inject
|
||||
import java.io.File
|
||||
import java.io.InputStream
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import java.util.*
|
||||
import java.util.zip.ZipFile
|
||||
|
||||
public fun main(argv: Array<String>) {
|
||||
Kobalt.INJECTOR.getInstance(Wrapper::class.java).installAndLaunchMain(argv)
|
||||
}
|
||||
//public fun main(argv: Array<String>) {
|
||||
// Kobalt.INJECTOR.getInstance(Wrapper::class.java).installAndLaunchMain(argv)
|
||||
//}
|
||||
|
||||
/**
|
||||
* Download and install a new wrapper if requested.
|
||||
*/
|
||||
public class Wrapper @Inject constructor(val wrapperProperties: KobaltWrapperProperties){
|
||||
// kobalt.properties
|
||||
private val KOBALT_PROPERTIES = "kobalt.properties"
|
||||
private val KOBALTW = "kobaltw"
|
||||
|
||||
val FILE_NAME = "kobalt"
|
||||
|
||||
private val properties = Properties()
|
||||
|
||||
public fun installAndLaunchMain(argv: Array<String>) {
|
||||
val kobaltJarFile = install()
|
||||
launchMain(kobaltJarFile, argv)
|
||||
}
|
||||
|
||||
private fun readProperties(properties: Properties, ins: InputStream) {
|
||||
properties.load(ins)
|
||||
ins.close()
|
||||
properties.forEach { es -> System.setProperty(es.key.toString(), es.value.toString()) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Attemps to read kobalt.properties (which should always exist).
|
||||
*/
|
||||
private fun maybeCreateKobaltProperties() : Properties {
|
||||
val result = Properties()
|
||||
|
||||
// kobalt.properties is internal to Kobalt
|
||||
val url = javaClass.classLoader.getResource(KOBALT_PROPERTIES)
|
||||
if (url != null) {
|
||||
readProperties(result, url.openConnection().inputStream)
|
||||
} else {
|
||||
throw IllegalArgumentException("Couldn't find $KOBALT_PROPERTIES")
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// private fun initWrapperFile(version: String) {
|
||||
// val config = wrapperProperties.file
|
||||
// if (! config.exists()) {
|
||||
// wrapperProperties.create(version)
|
||||
// }
|
||||
// properties.load(FileReader(config))
|
||||
//public class Wrapper @Inject constructor(val wrapperProperties: KobaltWrapperProperties){
|
||||
// // kobalt.properties
|
||||
// private val KOBALT_PROPERTIES = "kobalt.properties"
|
||||
// private val KOBALTW = "kobaltw"
|
||||
//
|
||||
// val FILE_NAME = "kobalt"
|
||||
//
|
||||
// private val properties = Properties()
|
||||
//
|
||||
// public fun installAndLaunchMain(argv: Array<String>) {
|
||||
// val kobaltJarFile = install()
|
||||
// launchMain(kobaltJarFile, argv)
|
||||
// }
|
||||
//
|
||||
// private val wrapperVersion : String
|
||||
// get() {
|
||||
// return properties.getProperty(PROPERTY_VERSION)
|
||||
// private fun readProperties(properties: Properties, ins: InputStream) {
|
||||
// properties.load(ins)
|
||||
// ins.close()
|
||||
// properties.forEach { es -> System.setProperty(es.key.toString(), es.value.toString()) }
|
||||
// }
|
||||
//
|
||||
// private val wrapperDownloadUrl : String
|
||||
// get() {
|
||||
// return properties.getProperty(PROPERTY_DOWNLOAD_URL)
|
||||
// /**
|
||||
// * Attemps to read kobalt.properties (which should always exist).
|
||||
// */
|
||||
// private fun maybeCreateKobaltProperties() : Properties {
|
||||
// val result = Properties()
|
||||
//
|
||||
// // kobalt.properties is internal to Kobalt
|
||||
// val url = javaClass.classLoader.getResource(KOBALT_PROPERTIES)
|
||||
// if (url != null) {
|
||||
// readProperties(result, url.openConnection().inputStream)
|
||||
// } else {
|
||||
// throw IllegalArgumentException("Couldn't find $KOBALT_PROPERTIES")
|
||||
// }
|
||||
//
|
||||
// fun urlFor(version: String) : String {
|
||||
// // val URL = "https://dl.bintray.com/cbeust/generic/"
|
||||
// // return "https://dl.bintray.com/cbeust/generic/$fileName-$version.zip"
|
||||
// return wrapperDownloadUrl ?: defaultUrlFor(version)
|
||||
// return result
|
||||
// }
|
||||
|
||||
/**
|
||||
* Install a new version if requested in .kobalt/wrapper/kobalt-wrapper.properties
|
||||
*
|
||||
* @return the path to the Kobalt jar file
|
||||
*/
|
||||
public fun install() : Path {
|
||||
val properties = maybeCreateKobaltProperties()
|
||||
val version = properties.getProperty("kobalt.version")
|
||||
wrapperProperties.maybeCreate(version)
|
||||
log(2, "Wrapper version: ${wrapperProperties.version}")
|
||||
|
||||
val wrapperVersion = wrapperProperties.version
|
||||
val fileName = "$FILE_NAME-$wrapperVersion.zip"
|
||||
File(KFiles.distributionsDir).mkdirs()
|
||||
val localZipFile = Paths.get(KFiles.distributionsDir, fileName)
|
||||
val zipOutputDir = KFiles.distributionsDir + "/" + wrapperVersion
|
||||
val kobaltJarFile = Paths.get(zipOutputDir, "kobalt/wrapper/$FILE_NAME-$wrapperVersion.jar")
|
||||
if (!Files.exists(localZipFile) || !Files.exists(kobaltJarFile)) {
|
||||
log(1, "Downloading $fileName")
|
||||
val fullUrl = wrapperProperties.downloadUrl
|
||||
val body = Http().get(fullUrl)
|
||||
if (body.code == 200) {
|
||||
if (!Files.exists(localZipFile)) {
|
||||
val target = localZipFile.toAbsolutePath()
|
||||
val ins = body.getAsStream()
|
||||
benchmark("Download .zip file") {
|
||||
// This takes about eight seconds for a 21M file because of the extra copying, not good.
|
||||
// Should use Okio.sink(file) to create a Sink and then call readAll(fileSink) on
|
||||
// the BufferedSource returned in the ResponseBody
|
||||
Files.copy(ins, target)
|
||||
}
|
||||
log(2, "$localZipFile downloaded, extracting it")
|
||||
} else {
|
||||
log(2, "$localZipFile already exists, extracting it")
|
||||
}
|
||||
|
||||
//
|
||||
// Extract all the zip files
|
||||
//// private fun initWrapperFile(version: String) {
|
||||
//// val config = wrapperProperties.file
|
||||
//// if (! config.exists()) {
|
||||
//// wrapperProperties.create(version)
|
||||
//// }
|
||||
//// properties.load(FileReader(config))
|
||||
//// }
|
||||
////
|
||||
//// private val wrapperVersion : String
|
||||
//// get() {
|
||||
//// return properties.getProperty(PROPERTY_VERSION)
|
||||
//// }
|
||||
////
|
||||
//// private val wrapperDownloadUrl : String
|
||||
//// get() {
|
||||
//// return properties.getProperty(PROPERTY_DOWNLOAD_URL)
|
||||
//// }
|
||||
////
|
||||
//// fun urlFor(version: String) : String {
|
||||
//// // val URL = "https://dl.bintray.com/cbeust/generic/"
|
||||
//// // return "https://dl.bintray.com/cbeust/generic/$fileName-$version.zip"
|
||||
//// return wrapperDownloadUrl ?: defaultUrlFor(version)
|
||||
//// }
|
||||
//
|
||||
val zipFile = ZipFile(localZipFile.toFile())
|
||||
val entries = zipFile.entries()
|
||||
val outputDirectory = File(KFiles.distributionsDir)
|
||||
outputDirectory.mkdirs()
|
||||
while (entries.hasMoreElements()) {
|
||||
val entry = entries.nextElement()
|
||||
val entryFile = File(entry.name)
|
||||
if (entry.isDirectory) {
|
||||
entryFile.mkdirs()
|
||||
} else {
|
||||
val dest = Paths.get(zipOutputDir, entryFile.path)
|
||||
log(2, " Writing ${entry.name} to $dest")
|
||||
Files.createDirectories(dest.parent)
|
||||
Files.copy(zipFile.getInputStream(entry),
|
||||
dest,
|
||||
java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
}
|
||||
log(2, "$localZipFile extracted")
|
||||
} else {
|
||||
error("Couldn't download $fullUrl")
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Install a new version if requested in .kobalt/wrapper/kobalt-wrapper.properties
|
||||
// *
|
||||
// * @return the path to the Kobalt jar file
|
||||
// */
|
||||
// public fun install() : Path {
|
||||
// val properties = maybeCreateKobaltProperties()
|
||||
// val version = properties.getProperty("kobalt.version")
|
||||
// wrapperProperties.maybeCreate(version)
|
||||
// log(2, "Wrapper version: ${wrapperProperties.version}")
|
||||
//
|
||||
// Copy the wrapper files in the current kobalt/wrapper directory
|
||||
// val wrapperVersion = wrapperProperties.version
|
||||
// val fileName = "$FILE_NAME-$wrapperVersion.zip"
|
||||
// File(KFiles.distributionsDir).mkdirs()
|
||||
// val localZipFile = Paths.get(KFiles.distributionsDir, fileName)
|
||||
// val zipOutputDir = KFiles.distributionsDir + "/" + wrapperVersion
|
||||
// val kobaltJarFile = Paths.get(zipOutputDir, "kobalt/wrapper/$FILE_NAME-$wrapperVersion.jar")
|
||||
// if (!Files.exists(localZipFile) || !Files.exists(kobaltJarFile)) {
|
||||
// log(1, "Downloading $fileName")
|
||||
// val fullUrl = wrapperProperties.downloadUrl
|
||||
// val body = Http().get(fullUrl)
|
||||
// if (body.code == 200) {
|
||||
// if (!Files.exists(localZipFile)) {
|
||||
// val target = localZipFile.toAbsolutePath()
|
||||
// val ins = body.getAsStream()
|
||||
// benchmark("Download .zip file") {
|
||||
// // This takes about eight seconds for a 21M file because of the extra copying, not good.
|
||||
// // Should use Okio.sink(file) to create a Sink and then call readAll(fileSink) on
|
||||
// // the BufferedSource returned in the ResponseBody
|
||||
// Files.copy(ins, target)
|
||||
// }
|
||||
// log(2, "$localZipFile downloaded, extracting it")
|
||||
// } else {
|
||||
// log(2, "$localZipFile already exists, extracting it")
|
||||
// }
|
||||
//
|
||||
log(2, "Copying the wrapper files...")
|
||||
arrayListOf(KOBALTW, "kobalt/wrapper/$FILE_NAME-wrapper.jar").forEach {
|
||||
val from = Paths.get(zipOutputDir, it)
|
||||
val to = Paths.get(File(".").absolutePath, it)
|
||||
KFiles.copy(from, to, java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
||||
}
|
||||
File(KOBALTW).setExecutable(true)
|
||||
|
||||
return kobaltJarFile
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch kobalt-xxx.jar
|
||||
*
|
||||
* Note: currently launching it in a separate VM because both this jar file and the wrapper contain
|
||||
* the same classes, so the old classes will be run. Once wrapper.jar contains only the
|
||||
* wrapper class and nothing else from the Kobalt distribution, we can just invoke main from the same JVM here,
|
||||
* which will speed up the start up
|
||||
*/
|
||||
private fun launchMain(kobaltJarFile: Path, argv: Array<String>) {
|
||||
val jvm = JavaInfo.create(File(SystemProperties.javaBase))
|
||||
val java = jvm.javaExecutable
|
||||
|
||||
val args = arrayListOf(
|
||||
java!!.absolutePath,
|
||||
"-jar", kobaltJarFile.toFile().absolutePath)
|
||||
args.addAll(argv)
|
||||
val pb = ProcessBuilder(args)
|
||||
pb.inheritIO()
|
||||
log(2, "Launching\n ${args.joinToString(" ")}")
|
||||
val process = pb.start()
|
||||
process.waitFor()
|
||||
}
|
||||
}
|
||||
// //
|
||||
// // Extract all the zip files
|
||||
// //
|
||||
// val zipFile = ZipFile(localZipFile.toFile())
|
||||
// val entries = zipFile.entries()
|
||||
// val outputDirectory = File(KFiles.distributionsDir)
|
||||
// outputDirectory.mkdirs()
|
||||
// while (entries.hasMoreElements()) {
|
||||
// val entry = entries.nextElement()
|
||||
// val entryFile = File(entry.name)
|
||||
// if (entry.isDirectory) {
|
||||
// entryFile.mkdirs()
|
||||
// } else {
|
||||
// val dest = Paths.get(zipOutputDir, entryFile.path)
|
||||
// log(2, " Writing ${entry.name} to $dest")
|
||||
// Files.createDirectories(dest.parent)
|
||||
// Files.copy(zipFile.getInputStream(entry),
|
||||
// dest,
|
||||
// java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
||||
// }
|
||||
// }
|
||||
// log(2, "$localZipFile extracted")
|
||||
// } else {
|
||||
// error("Couldn't download $fullUrl")
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //
|
||||
// // Copy the wrapper files in the current kobalt/wrapper directory
|
||||
// //
|
||||
// log(2, "Copying the wrapper files...")
|
||||
// arrayListOf(KOBALTW, "kobalt/wrapper/$FILE_NAME-wrapper.jar").forEach {
|
||||
// val from = Paths.get(zipOutputDir, it)
|
||||
// val to = Paths.get(File(".").absolutePath, it)
|
||||
// KFiles.copy(from, to, java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
||||
// }
|
||||
// File(KOBALTW).setExecutable(true)
|
||||
//
|
||||
// return kobaltJarFile
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Launch kobalt-xxx.jar
|
||||
// *
|
||||
// * Note: currently launching it in a separate VM because both this jar file and the wrapper contain
|
||||
// * the same classes, so the old classes will be run. Once wrapper.jar contains only the
|
||||
// * wrapper class and nothing else from the Kobalt distribution, we can just invoke main from the same JVM here,
|
||||
// * which will speed up the start up
|
||||
// */
|
||||
// private fun launchMain(kobaltJarFile: Path, argv: Array<String>) {
|
||||
// val jvm = JavaInfo.create(File(SystemProperties.javaBase))
|
||||
// val java = jvm.javaExecutable
|
||||
//
|
||||
// val args = arrayListOf(
|
||||
// java!!.absolutePath,
|
||||
// "-jar", kobaltJarFile.toFile().absolutePath)
|
||||
// args.addAll(argv)
|
||||
// val pb = ProcessBuilder(args)
|
||||
// pb.inheritIO()
|
||||
// log(2, "Launching\n ${args.joinToString(" ")}")
|
||||
// val process = pb.start()
|
||||
// process.waitFor()
|
||||
// }
|
||||
//}
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
kobalt.version=0.238
|
||||
kobalt.version=0.244
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue