mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-25 07:57: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?) {
|
||||
val file = f.normalize()
|
||||
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 ->
|
||||
maybeAddEntry(entry) {
|
||||
addEntry(entry, inputStream)
|
||||
|
|
|
@ -10,7 +10,9 @@ import java.nio.file.Files
|
|||
import java.nio.file.Path
|
||||
import java.nio.file.Paths
|
||||
import java.nio.file.StandardCopyOption
|
||||
import java.util.*
|
||||
import java.util.jar.JarInputStream
|
||||
import java.util.regex.Pattern
|
||||
|
||||
|
||||
class KFiles {
|
||||
|
@ -20,6 +22,20 @@ class KFiles {
|
|||
*/
|
||||
val kobaltJar : List<String>
|
||||
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")
|
||||
if (envJar != null) {
|
||||
debug("Using kobalt jar $envJar")
|
||||
|
@ -31,16 +47,15 @@ class KFiles {
|
|||
if (jarFile.exists()) {
|
||||
return listOf(jarFile.absolutePath)
|
||||
} 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-wrapper.properties: kobalt.version=0.827
|
||||
// When Kobalt can't find the newest jar file, it will instead use the classes produced by IDEA
|
||||
// in the directories specified here:
|
||||
val leftSuffix = Kobalt.version.substring(0, Kobalt.version.lastIndexOf(".") + 1)
|
||||
val previousVersion = leftSuffix +
|
||||
(Kobalt.version.split(".").let { it[it.size - 1] }.toInt() - 1).toString()
|
||||
val previousVersion = latestInstalledVersion().version
|
||||
val previousJar = joinDir(distributionsDir, "kobalt-" + previousVersion,
|
||||
"kobalt/wrapper/kobalt-$previousVersion.jar")
|
||||
val v = latestInstalledVersion()
|
||||
val result = listOf("", "modules/kobalt-plugin-api", "modules/wrapper").map {
|
||||
File(homeDir(KFiles.joinDir("kotlin", "kobalt", it, "kobaltBuild", "classes")))
|
||||
.absolutePath
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.beust.kobalt
|
|||
import com.beust.kobalt.misc.KFiles
|
||||
import com.beust.kobalt.misc.kobaltLog
|
||||
import com.beust.kobalt.misc.warn
|
||||
import org.assertj.core.api.Assertions.assertThat
|
||||
import org.testng.annotations.Test
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
|
@ -38,6 +39,7 @@ class VerifyKobaltZipTest : KobaltTest() {
|
|||
val stream = JarInputStream(FileInputStream(zipFilePath))
|
||||
var entry = stream.nextEntry
|
||||
while (entry != null) {
|
||||
assertThat(entry.name).doesNotContain("\\")
|
||||
if (! entry.name.startsWith(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