[orx-olive] Add support for working with .kt files that have a filename starting with a digit
This commit is contained in:
@@ -37,13 +37,15 @@ fun ApplicationBuilder.oliveProgram(scriptHost: OliveScriptHost = OliveScriptHos
|
|||||||
|
|
||||||
var sourceLocation = "src/main/kotlin/$rootClassName.kt"
|
var sourceLocation = "src/main/kotlin/$rootClassName.kt"
|
||||||
val candidateFile = File(sourceLocation)
|
val candidateFile = File(sourceLocation)
|
||||||
|
val rootClassNameCleaned = if (rootClassName.startsWith("_")) rootClassName.drop(1) else rootClassName
|
||||||
|
|
||||||
if (!candidateFile.exists()) {
|
if (!candidateFile.exists()) {
|
||||||
val otherCandidates = Files.walk(Paths.get("."))
|
val otherCandidates = Files.walk(Paths.get("."))
|
||||||
.filter { Files.isRegularFile(it) && it.toString().endsWith("$rootClassName.kt") }.toList()
|
.filter { Files.isRegularFile(it) && it.toString().endsWith("$rootClassNameCleaned.kt") }.toList()
|
||||||
if (otherCandidates.size == 1) {
|
if (otherCandidates.size == 1) {
|
||||||
sourceLocation = otherCandidates.first().toString()
|
sourceLocation = otherCandidates.first().toString()
|
||||||
} else {
|
} else {
|
||||||
error("multiple source candidates found: $otherCandidates")
|
error("multiple source candidates found for $rootClassName: $otherCandidates")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
program = object : OliveProgram(sourceLocation, scriptHost, resources) {
|
program = object : OliveProgram(sourceLocation, scriptHost, resources) {
|
||||||
|
|||||||
Reference in New Issue
Block a user