Skip to content

feat: Consider putting this module to Bazel Central Registry #232

@honnix

Description

@honnix

Since this repo has moved to bzlmod, maybe it is a good time to add it to BCR, so it would be easier for people to use source from their projects.

The current instructions Build from source in your Bazel Project does not work anymore since migrated to bzlmod, because WORKSPACE is now empty, so there are a few things missing, mostly around rules_kotlin.

BTW, I figured out a way to build from source from our project and I think it might be worth noting.

WORKSPACE:

http_archive(
    name = "rules_kotlin",
    sha256 = "d9898c3250e0442436eeabde4e194c30d6c76a4a97f517b18cefdfd4e345725a",
    url = "https://github.com/bazelbuild/rules_kotlin/releases/download/v1.9.1/rules_kotlin-v1.9.1.tar.gz",
)

load("@rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories")

kotlin_repositories()

load("@rules_kotlin//kotlin:core.bzl", "kt_register_toolchains")

kt_register_toolchains()

http_archive(
    name = "bazel_diff",
    patch_args = ["-p1"],
    patches = [
        "//tools/bazel_diff:cli.patch",
    ],
    sha256 = "9059cc0fe833f69c946aee9603c12122e9d40373af3f5de8ad9949cfb2ecfba2",
    strip_prefix = "bazel-diff-ba464a41076a719ffcdc1ff52240ad59c5f2a3f2",
    url = "https://github.com/Tinder/bazel-diff/archive/ba464a41076a719ffcdc1ff52240ad59c5f2a3f2.tar.gz",
)

load("@bazel_diff//:repositories.bzl", "bazel_diff_dependencies")

bazel_diff_dependencies()

load("@bazel_diff//:artifacts.bzl", "BAZEL_DIFF_MAVEN_ARTIFACTS")

maven_install(
    name = "bazel_diff_maven",
    artifacts = BAZEL_DIFF_MAVEN_ARTIFACTS,
    maven_install_json = "@bazel_diff//:maven_install.json",
    repositories = [...],
)

load("@bazel_diff_maven//:defs.bzl", bazel_diff_pinned_maven_install = "pinned_maven_install")

bazel_diff_pinned_maven_install()

cli.patch (this is needed because we don't have STABLE_GIT_TAG):

diff --git a/cli/BUILD b/cli/BUILD
index 6a0b1be..4573286 100644
--- a/cli/BUILD
+++ b/cli/BUILD
@@ -13,7 +13,7 @@ genrule(
     srcs = [],
     outs = ["version"],
     cmd_bash = """
-        version_tag=$$(grep ^STABLE_GIT_TAG bazel-out/stable-status.txt | cut -d' ' -f2); \
+        version_tag=$$(grep ^STABLE_GIT_TAG bazel-out/stable-status.txt || echo "unknown" | cut -d' ' -f2); \
         printf '%s' $$version_tag > $@;
     """,
     stamp = 1,

Even with cli.patch in place, bazel run @bazel_diff//:bazel-diff -- -V still doesn't work because it seems rules_kotlin does not handle resources well, so we end up with having a bad resources jar: ../bazel_diff/cli/version is the file packed in the jar. But this is not critical at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions