in src/main/kotlin/io/bazel/kotlin/builder/utils/BazelUtils.kt [62:94]
fun resolveVerified(vararg path: String): File {
check(path.isNotEmpty())
val fromManifest = manifestFile?.let { mf ->
path.joinToString("/").let { rfPath ->
// trim off the external/ prefix if it is present.
val trimmedPath =
if (rfPath.startsWith("external/")) {
rfPath.replaceFirst("external/", "")
} else {
rfPath
}
File(
checkNotNull(runfiles[trimmedPath]) {
"runfile manifest $mf did not contain path mapping for $rfPath"
}
)
}.also {
check(it.exists()) { "file $it resolved from runfiles did not exist" }
}
}
if (fromManifest != null) {
return fromManifest
}
/// if it could not be resolved from the manifest then first try to resolve it directly.
val resolvedDirect = File(path.joinToString(File.separator)).takeIf { it.exists() }
if (resolvedDirect != null) {
return resolvedDirect
}
// Try the java runfiles as the last resort.
return javaRunFiles.resolveVerified(path.joinToString(File.separator))
}