Skip to content

Commit

Permalink
[fix] server logs non existing files instead of failing | #BAZEL-498 …
Browse files Browse the repository at this point in the history
…Done

Merge-request: BAZEL-MR-536
Merged-by: Marcin Abramowicz <marcin.abramowicz@jetbrains.com>
  • Loading branch information
abrams27 authored and Space Team committed Sep 22, 2023
1 parent 89706f8 commit 54a1fec
Showing 1 changed file with 11 additions and 1 deletion.
Expand Up @@ -27,6 +27,8 @@ import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
import kotlin.io.path.exists
import kotlin.io.path.notExists

const val KOTLIN_STDLIB_ROOT_EXECUTION = "external/com_github_jetbrains_kotlin"
const val KOTLIN_STDLIB_RELATIVE_PATH_PREFIX = "lib/"
Expand Down Expand Up @@ -364,14 +366,22 @@ class BazelProjectMapper(
language.binary_targets.contains(kind)

private fun resolveSourceSet(target: TargetInfo, languagePlugin: LanguagePlugin<*>): SourceSet {
val sources = target.sourcesList.asSequence().map(bazelPathsResolver::resolve)
val sources = target.sourcesList.toSet()
.map(bazelPathsResolver::resolve)
.onEach { if (it.notExists()) it.logNonExistingFile(target.id) }
.filter { it.exists() }
val sourceRoots = sources.mapNotNull(languagePlugin::calculateSourceRoot)
return SourceSet(
sources.map(bazelPathsResolver::resolveUri).toSet(),
sourceRoots.map(bazelPathsResolver::resolveUri).toSet()
)
}

private fun Path.logNonExistingFile(targetId: String) {
val message = "[WARN] target $targetId: $this does not exist."
bspClientLogger.error(message)
}

private fun resolveResources(target: TargetInfo): Set<URI> =
bazelPathsResolver.resolveUris(target.resourcesList).toSet()

Expand Down

0 comments on commit 54a1fec

Please sign in to comment.