mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-26 00:17:11 -07:00
.kobalt find fixes.
This commit is contained in:
parent
4a43d17288
commit
8c13df5be1
2 changed files with 16 additions and 12 deletions
|
@ -1,5 +1,6 @@
|
|||
package com.beust.kobalt.internal.build
|
||||
|
||||
import com.beust.kobalt.misc.KFiles
|
||||
import java.io.File
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
|
@ -9,10 +10,17 @@ import java.nio.file.attribute.BasicFileAttributes
|
|||
* @param path is the path where that file was moved, @param realPath is where the actual file is.
|
||||
*/
|
||||
class BuildFile(val path: Path, val name: String, val realPath: Path = path) {
|
||||
public fun exists() : Boolean = Files.exists(path)
|
||||
fun exists() : Boolean = Files.exists(path)
|
||||
|
||||
public val lastModified : Long
|
||||
val lastModified : Long
|
||||
get() = Files.readAttributes(realPath, BasicFileAttributes::class.java).lastModifiedTime().toMillis()
|
||||
|
||||
public val directory : File get() = path.toFile().parentFile
|
||||
val directory : File get() = path.toFile().parentFile
|
||||
|
||||
/**
|
||||
* @return the .kobalt directory where this build file will be compiled.
|
||||
*/
|
||||
val dotKobaltDir: File get() = File(directory.parentFile.parentFile, KFiles.KOBALT_DOT_DIR).apply {
|
||||
mkdirs()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -222,22 +222,18 @@ class KFiles {
|
|||
}
|
||||
}
|
||||
|
||||
fun findDotDir(startDir: File) : File {
|
||||
var result = startDir
|
||||
while (result != null && result.parentFile != null && ! File(result, KOBALT_DOT_DIR).exists()) {
|
||||
result = result.parentFile
|
||||
private fun findDotDir(buildFile: BuildFile) : File {
|
||||
val result = File(buildFile.directory.parentFile.parentFile, KOBALT_DOT_DIR).apply {
|
||||
mkdirs()
|
||||
}
|
||||
if (result == null) {
|
||||
throw IllegalArgumentException("Couldn't locate $KOBALT_DOT_DIR in $startDir")
|
||||
}
|
||||
return File(result, KOBALT_DOT_DIR)
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* The build location for build scripts is .kobalt/build
|
||||
*/
|
||||
fun findBuildScriptLocation(buildFile: BuildFile, jarFile: String) : String {
|
||||
val result = joinDir(findDotDir(buildFile.directory).absolutePath, KFiles.SCRIPT_BUILD_DIR, jarFile)
|
||||
val result = joinDir(buildFile.dotKobaltDir.absolutePath, KFiles.SCRIPT_BUILD_DIR, jarFile)
|
||||
log(2, "Script jar file: $result")
|
||||
return result
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue