Skip to content

Commit

Permalink
fix(Bazel): Fix local registry modules path
Browse files Browse the repository at this point in the history
Bazel modules are always in a 'modules' directory alongside the
`bazel_registry.json` file. See [1].

The latter is still parsed and will be used in a future commit to handle
modules with type 'local_path'.

This is a fixup for 5968180.

[1]: https://bazel.build/external/registry#index_registry

Signed-off-by: Nicolas Nobelis <nicolas.nobelis@bosch.com>
  • Loading branch information
nnobelis authored and sschuberth committed Jun 27, 2024
1 parent c4b1d66 commit 767475e
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ import java.io.File
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.decodeFromStream

private const val BAZEL_MODULES_DIR = "modules"

/**
* A Bazel registry which is located on the local file system.
*/
class LocalBazelModuleRegistryService(directory: File) : BazelModuleRegistryService {
private val moduleDirectory: File
private val bazelRegistry: BazelRegistry

init {
val registryFile = directory.resolve("bazel_registry.json")
Expand All @@ -37,11 +40,11 @@ class LocalBazelModuleRegistryService(directory: File) : BazelModuleRegistryServ
"The Bazel registry file bazel_registry.json does not exist in '${directory.canonicalPath}'."
}

val bazelRegistry = registryFile.inputStream().use {
bazelRegistry = registryFile.inputStream().use {
JSON.decodeFromStream<BazelRegistry>(it)
}

moduleDirectory = registryFile.resolve(bazelRegistry.moduleBasePath)
moduleDirectory = registryFile.resolveSibling(BAZEL_MODULES_DIR)
}

override suspend fun getModuleMetadata(name: String): ModuleMetadata {
Expand Down

0 comments on commit 767475e

Please sign in to comment.