Migrate to bazel modules Change-Id: I75c90e244498c327b6b9a929d94e2215d0f104b3
diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000..59c9824 --- /dev/null +++ b/.bazelrc
@@ -0,0 +1,2 @@ +# Workspace status command +build --workspace_status_command=tools/workspace_status.sh
diff --git a/.bazelversion b/.bazelversion index 7c69a55..b13d146 100644 --- a/.bazelversion +++ b/.bazelversion
@@ -1 +1 @@ -3.7.0 +9.3.0
diff --git a/BUILD b/BUILD index 2d127b1..f107481 100644 --- a/BUILD +++ b/BUILD
@@ -1,5 +1,8 @@ -load("//tools/bzl:junit.bzl", "junit_tests") -load("//tools/bzl:plugin.bzl", "PLUGIN_DEPS", "PLUGIN_TEST_DEPS", "gerrit_plugin") +load( + "@com_googlesource_gerrit_bazlets//:gerrit_plugin.bzl", + "gerrit_plugin", + "gerrit_plugin_tests", +) gerrit_plugin( name = "serviceuser", @@ -13,22 +16,14 @@ ], resource_jars = ["//plugins/serviceuser/web:serviceuser"], resources = glob(["src/main/resources/**/*"]), - deps = [ - "//java/com/google/gerrit/gpg", - "//lib/bouncycastle:bcpg-neverlink", - "//lib/bouncycastle:bcprov-neverlink", - ] ) -junit_tests( +gerrit_plugin_tests( name = "serviceuser_tests", - testonly = 1, srcs = glob([ "src/test/java/**/*Test.java", "src/test/java/**/*IT.java", ]), + plugin = "serviceuser", tags = ["serviceuser"], - deps = PLUGIN_TEST_DEPS + PLUGIN_DEPS + [ - ":serviceuser__plugin", - ], )
diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000..34f1410 --- /dev/null +++ b/MODULE.bazel
@@ -0,0 +1,62 @@ +module(name = "gerrit-serviceuser") + +bazel_dep(name = "aspect_rules_ts", version = "3.5.2") +bazel_dep(name = "rules_jvm_external", version = "6.10") +bazel_dep(name = "rules_nodejs", version = "6.7.6") +bazel_dep(name = "com_googlesource_gerrit_bazlets") +git_override( + module_name = "com_googlesource_gerrit_bazlets", + commit = "3f9b913f7c0ed091530b8bb40d664d27c9c3d5f8", + remote = "https://gerrit.googlesource.com/bazlets", +) + +GERRIT_API_VERSION = "3.13.5" + +gerrit_api_version = use_repo_rule( + "@com_googlesource_gerrit_bazlets//:gerrit_api_version.bzl", + "gerrit_api_version", +) + +gerrit_api_version( + name = "gerrit_api_version", + version = GERRIT_API_VERSION, + visibility = ["//visibility:public"], +) + +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") +maven.install( + name = "external_plugin_deps", + artifacts = [ + "com.google.gerrit:gerrit-plugin-api:" + GERRIT_API_VERSION, + "com.google.gerrit:gerrit-acceptance-framework:" + GERRIT_API_VERSION, + ], + # IMPORTANT: + # Do NOT set lock_file here. + # + # This repository is intentionally shared across plugins and contains + # only Gerrit-provided APIs (gerrit-plugin-api and acceptance framework) + # that are provided by Gerrit at runtime and must not be bundled into + # the plugin JAR. + # + # When built in-tree, rules_jvm_external merges maven.install() tags + # with the same name across all modules. Defining a lock_file for this + # shared repository in more than one plugin causes multiple lock files + # to be contributed for the same repository name, which is rejected by + # rules_jvm_external during module extension evaluation. + # + # Plugin runtime dependencies must instead be declared in a + # plugin-specific repository (e.g. serviceuser_plugin_deps) that owns + # its own lock file. +) +use_repo(maven, "external_plugin_deps") + +node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node") +node.toolchain(node_version = "20.19.1") + +npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm", dev_dependency = True) +npm.npm_translate_lock( + name = "npm", + pnpm_lock = "//:pnpm-lock.yaml", + verify_node_modules_ignored = "//:.npmrc", +) +use_repo(npm, "npm")
diff --git a/tools/workspace_status.sh b/tools/workspace_status.sh new file mode 100755 index 0000000..5b30b40 --- /dev/null +++ b/tools/workspace_status.sh
@@ -0,0 +1,13 @@ +#!/bin/bash +# Workspace status script for Bazel +# This script provides stable status variables for the build + +# Get the plugin version from git or use a default +if git rev-parse --git-dir >/dev/null 2>&1; then + VERSION=$(git describe --always --dirty --abbrev=7) +else + VERSION="dev" +fi + +# Output stable status variables +echo "STABLE_BUILD_SERVICEUSER_LABEL ${VERSION}"