mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Clean up.
This commit is contained in:
parent
71cd3185d1
commit
5545d8e41b
1 changed files with 14 additions and 14 deletions
|
@ -55,7 +55,7 @@ public class Wrapper {
|
||||||
if (url != null) {
|
if (url != null) {
|
||||||
readProperties(result, url.openConnection().inputStream)
|
readProperties(result, url.openConnection().inputStream)
|
||||||
} else {
|
} else {
|
||||||
throw IllegalArgumentException("Couldn't find ${KOBALT_PROPERTIES}")
|
throw IllegalArgumentException("Couldn't find $KOBALT_PROPERTIES")
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -64,7 +64,7 @@ public class Wrapper {
|
||||||
private fun initWrapperFile(version: String) {
|
private fun initWrapperFile(version: String) {
|
||||||
val config = File(WRAPPER_DIR, KOBALT_WRAPPER_PROPERTIES)
|
val config = File(WRAPPER_DIR, KOBALT_WRAPPER_PROPERTIES)
|
||||||
if (! config.exists()) {
|
if (! config.exists()) {
|
||||||
KFiles.saveFile(config, "${PROPERTY_VERSION}=${version}")
|
KFiles.saveFile(config, "$PROPERTY_VERSION=$version")
|
||||||
}
|
}
|
||||||
properties.load(FileReader(config))
|
properties.load(FileReader(config))
|
||||||
}
|
}
|
||||||
|
@ -84,16 +84,16 @@ public class Wrapper {
|
||||||
val version = properties.getProperty(PROPERTY_VERSION)
|
val version = properties.getProperty(PROPERTY_VERSION)
|
||||||
initWrapperFile(version)
|
initWrapperFile(version)
|
||||||
|
|
||||||
log(2, "Wrapper version: ${wrapperVersion}")
|
log(2, "Wrapper version: $wrapperVersion")
|
||||||
|
|
||||||
val fileName = "${FILE_NAME}-${wrapperVersion}.zip"
|
val fileName = "$FILE_NAME-$wrapperVersion.zip"
|
||||||
File(KFiles.distributionsDir).mkdirs()
|
File(KFiles.distributionsDir).mkdirs()
|
||||||
val localZipFile = Paths.get(KFiles.distributionsDir, fileName)
|
val localZipFile = Paths.get(KFiles.distributionsDir, fileName)
|
||||||
val zipOutputDir = KFiles.distributionsDir + "/" + wrapperVersion
|
val zipOutputDir = KFiles.distributionsDir + "/" + wrapperVersion
|
||||||
val kobaltJarFile = Paths.get(zipOutputDir, "kobalt/wrapper/${FILE_NAME}-${wrapperVersion}.jar")
|
val kobaltJarFile = Paths.get(zipOutputDir, "kobalt/wrapper/$FILE_NAME-$wrapperVersion.jar")
|
||||||
if (!Files.exists(localZipFile) || !Files.exists(kobaltJarFile)) {
|
if (!Files.exists(localZipFile) || !Files.exists(kobaltJarFile)) {
|
||||||
log(1, "Downloading ${fileName}")
|
log(1, "Downloading $fileName")
|
||||||
val fullUrl = "${URL}/${fileName}"
|
val fullUrl = "$URL/$fileName"
|
||||||
val body = Http().get(fullUrl)
|
val body = Http().get(fullUrl)
|
||||||
if (body.code == 200) {
|
if (body.code == 200) {
|
||||||
if (!Files.exists(localZipFile)) {
|
if (!Files.exists(localZipFile)) {
|
||||||
|
@ -105,9 +105,9 @@ public class Wrapper {
|
||||||
// the BufferedSource returned in the ResponseBody
|
// the BufferedSource returned in the ResponseBody
|
||||||
Files.copy(ins, target)
|
Files.copy(ins, target)
|
||||||
}
|
}
|
||||||
log(2, "${localZipFile} downloaded, extracting it")
|
log(2, "$localZipFile downloaded, extracting it")
|
||||||
} else {
|
} else {
|
||||||
log(2, "${localZipFile} already exists, extracting it")
|
log(2, "$localZipFile already exists, extracting it")
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -124,16 +124,16 @@ public class Wrapper {
|
||||||
entryFile.mkdirs()
|
entryFile.mkdirs()
|
||||||
} else {
|
} else {
|
||||||
val dest = Paths.get(zipOutputDir, entryFile.path)
|
val dest = Paths.get(zipOutputDir, entryFile.path)
|
||||||
log(2, " Writing ${entry.name} to ${dest}")
|
log(2, " Writing ${entry.name} to $dest")
|
||||||
Files.createDirectories(dest.parent)
|
Files.createDirectories(dest.parent)
|
||||||
Files.copy(zipFile.getInputStream(entry),
|
Files.copy(zipFile.getInputStream(entry),
|
||||||
dest,
|
dest,
|
||||||
java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log(2, "${localZipFile} extracted")
|
log(2, "$localZipFile extracted")
|
||||||
} else {
|
} else {
|
||||||
error("Couldn't download ${URL}")
|
error("Couldn't download $URL")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ public class Wrapper {
|
||||||
// Copy the wrapper files in the current kobalt/wrapper directory
|
// Copy the wrapper files in the current kobalt/wrapper directory
|
||||||
//
|
//
|
||||||
log(2, "Copying the wrapper files...")
|
log(2, "Copying the wrapper files...")
|
||||||
arrayListOf(KOBALTW, "kobalt/wrapper/${FILE_NAME}-wrapper.jar").forEach {
|
arrayListOf(KOBALTW, "kobalt/wrapper/$FILE_NAME-wrapper.jar").forEach {
|
||||||
val from = Paths.get(zipOutputDir, it)
|
val from = Paths.get(zipOutputDir, it)
|
||||||
val to = Paths.get(File(".").absolutePath, it)
|
val to = Paths.get(File(".").absolutePath, it)
|
||||||
KFiles.copy(from, to, java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
KFiles.copy(from, to, java.nio.file.StandardCopyOption.REPLACE_EXISTING)
|
||||||
|
@ -169,7 +169,7 @@ public class Wrapper {
|
||||||
args.addAll(argv)
|
args.addAll(argv)
|
||||||
val pb = ProcessBuilder(args)
|
val pb = ProcessBuilder(args)
|
||||||
pb.inheritIO()
|
pb.inheritIO()
|
||||||
log(1, "Launching\n ${args.join(" ")}")
|
log(2, "Launching\n ${args.join(" ")}")
|
||||||
val process = pb.start()
|
val process = pb.start()
|
||||||
process.waitFor()
|
process.waitFor()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue