mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 08:27:12 -07:00
Any nonexistent version will cause Kobalt to use local build directories.
Relaxes the restriction for that version to be +1.
This commit is contained in:
parent
f7cb803edc
commit
c9e61e49a9
1 changed files with 19 additions and 4 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue