mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 16:07:12 -07:00
Merge branch 'master' of github.com:cbeust/kobalt
This commit is contained in:
commit
0f80fe6d68
3 changed files with 22 additions and 5 deletions
|
@ -25,7 +25,7 @@ class MetaArchive(outputFile: File, val manifest: Manifest?) : Closeable {
|
||||||
fun addFile(f: File, entryFile: File, path: String?) {
|
fun addFile(f: File, entryFile: File, path: String?) {
|
||||||
val file = f.normalize()
|
val file = f.normalize()
|
||||||
FileInputStream(file).use { inputStream ->
|
FileInputStream(file).use { inputStream ->
|
||||||
val actualPath = if (path != null) path + entryFile.path else entryFile.path
|
val actualPath = KFiles.fixSlashes(if (path != null) path + entryFile.path else entryFile.path)
|
||||||
ZipArchiveEntry(actualPath).let { entry ->
|
ZipArchiveEntry(actualPath).let { entry ->
|
||||||
maybeAddEntry(entry) {
|
maybeAddEntry(entry) {
|
||||||
addEntry(entry, inputStream)
|
addEntry(entry, inputStream)
|
||||||
|
|
|
@ -10,7 +10,9 @@ import java.nio.file.Files
|
||||||
import java.nio.file.Path
|
import java.nio.file.Path
|
||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import java.nio.file.StandardCopyOption
|
import java.nio.file.StandardCopyOption
|
||||||
|
import java.util.*
|
||||||
import java.util.jar.JarInputStream
|
import java.util.jar.JarInputStream
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
|
|
||||||
class KFiles {
|
class KFiles {
|
||||||
|
@ -20,6 +22,20 @@ class KFiles {
|
||||||
*/
|
*/
|
||||||
val kobaltJar : List<String>
|
val kobaltJar : List<String>
|
||||||
get() {
|
get() {
|
||||||
|
val PATTERN = Pattern.compile("kobalt-([-.0-9]+)")
|
||||||
|
|
||||||
|
fun latestInstalledVersion() : StringVersion {
|
||||||
|
val versions = File(distributionsDir).listFiles().map { it.name }.map {
|
||||||
|
val matcher = PATTERN.matcher(it)
|
||||||
|
val result =
|
||||||
|
if (matcher.matches()) matcher.group(1)
|
||||||
|
else null
|
||||||
|
result
|
||||||
|
}.filterNotNull().map(::StringVersion)
|
||||||
|
Collections.sort(versions, reverseOrder())
|
||||||
|
return versions[0]
|
||||||
|
}
|
||||||
|
|
||||||
val envJar = System.getenv("KOBALT_JAR")
|
val envJar = System.getenv("KOBALT_JAR")
|
||||||
if (envJar != null) {
|
if (envJar != null) {
|
||||||
debug("Using kobalt jar $envJar")
|
debug("Using kobalt jar $envJar")
|
||||||
|
@ -31,16 +47,15 @@ class KFiles {
|
||||||
if (jarFile.exists()) {
|
if (jarFile.exists()) {
|
||||||
return listOf(jarFile.absolutePath)
|
return listOf(jarFile.absolutePath)
|
||||||
} else {
|
} else {
|
||||||
// In development mode, keep your kobalt.properties version one above kobalt-wrapper.properties:
|
// In development mode, keep your kobalt.properties version to a nonexistent version
|
||||||
// kobalt.properties: kobalt.version=0.828
|
// kobalt.properties: kobalt.version=0.828
|
||||||
// kobalt-wrapper.properties: kobalt.version=0.827
|
// kobalt-wrapper.properties: kobalt.version=0.827
|
||||||
// When Kobalt can't find the newest jar file, it will instead use the classes produced by IDEA
|
// When Kobalt can't find the newest jar file, it will instead use the classes produced by IDEA
|
||||||
// in the directories specified here:
|
// in the directories specified here:
|
||||||
val leftSuffix = Kobalt.version.substring(0, Kobalt.version.lastIndexOf(".") + 1)
|
val previousVersion = latestInstalledVersion().version
|
||||||
val previousVersion = leftSuffix +
|
|
||||||
(Kobalt.version.split(".").let { it[it.size - 1] }.toInt() - 1).toString()
|
|
||||||
val previousJar = joinDir(distributionsDir, "kobalt-" + previousVersion,
|
val previousJar = joinDir(distributionsDir, "kobalt-" + previousVersion,
|
||||||
"kobalt/wrapper/kobalt-$previousVersion.jar")
|
"kobalt/wrapper/kobalt-$previousVersion.jar")
|
||||||
|
val v = latestInstalledVersion()
|
||||||
val result = listOf("", "modules/kobalt-plugin-api", "modules/wrapper").map {
|
val result = listOf("", "modules/kobalt-plugin-api", "modules/wrapper").map {
|
||||||
File(homeDir(KFiles.joinDir("kotlin", "kobalt", it, "kobaltBuild", "classes")))
|
File(homeDir(KFiles.joinDir("kotlin", "kobalt", it, "kobaltBuild", "classes")))
|
||||||
.absolutePath
|
.absolutePath
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.beust.kobalt
|
||||||
import com.beust.kobalt.misc.KFiles
|
import com.beust.kobalt.misc.KFiles
|
||||||
import com.beust.kobalt.misc.kobaltLog
|
import com.beust.kobalt.misc.kobaltLog
|
||||||
import com.beust.kobalt.misc.warn
|
import com.beust.kobalt.misc.warn
|
||||||
|
import org.assertj.core.api.Assertions.assertThat
|
||||||
import org.testng.annotations.Test
|
import org.testng.annotations.Test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileInputStream
|
import java.io.FileInputStream
|
||||||
|
@ -38,6 +39,7 @@ class VerifyKobaltZipTest : KobaltTest() {
|
||||||
val stream = JarInputStream(FileInputStream(zipFilePath))
|
val stream = JarInputStream(FileInputStream(zipFilePath))
|
||||||
var entry = stream.nextEntry
|
var entry = stream.nextEntry
|
||||||
while (entry != null) {
|
while (entry != null) {
|
||||||
|
assertThat(entry.name).doesNotContain("\\")
|
||||||
if (! entry.name.startsWith(root)) {
|
if (! entry.name.startsWith(root)) {
|
||||||
throw AssertionError("Entries in the zip file should be under the directory $root")
|
throw AssertionError("Entries in the zip file should be under the directory $root")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue