diff --git a/.bazelrc b/.bazelrc index 80d0a762af..6b9b4aaca3 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,5 +1,15 @@ -# Compile/run with Java 21 -build --java_language_version=21 +# Enable Java 21 build --java_runtime_version=21 +build --java_language_version=21 build --tool_java_language_version=21 build --tool_java_runtime_version=21 + +# Don't leak PATH and LD_LIBRARY_PATH into the build. +build --incompatible_strict_action_env + +# To facilitate testing in bazelci incompatible flags +# @see https://github.com/bazelbuild/bazel/pull/26906#issue-3386957462 +build --incompatible_autoload_externally= + +# For bazel 8 BCR CI +build --incompatible_disable_native_repo_rules diff --git a/.bazelversion b/.bazelversion new file mode 100644 index 0000000000..6da4de57dc --- /dev/null +++ b/.bazelversion @@ -0,0 +1 @@ +8.4.1 diff --git a/.bcr/config.yml b/.bcr/config.yml deleted file mode 100644 index 994a1e5e8b..0000000000 --- a/.bcr/config.yml +++ /dev/null @@ -1,3 +0,0 @@ -fixedReleaser: - login: mollyibot - email: mollyibot@google.com diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json index 7565a4213b..2d531842a7 100644 --- a/.bcr/metadata.template.json +++ b/.bcr/metadata.template.json @@ -1,25 +1,15 @@ { - "homepage": "https://github.com/bazelbuild/rules_closure", + "homepage": "https://github.com/stackb/rules_closure", "maintainers": [ { - "name": "Goktug Gokdogan", - "email": "goktug@google.com", - "github": "gkdn" - }, - { - "name": "Julien Dramaix", - "email": "dramaix@google.com", - "github": "jDramaix" - }, - { - "name": "Yuan Tian", - "email": "mollyibot@google.com", - "github": "mollyibot" + "name": "Paul Cody", + "email": "pcj@stack.build", + "github": "pcj" } ], "repository": [ - "github:bazelbuild/rules_closure" + "github:stackb/rules_closure" ], "versions": [], "yanked_versions": {} -} +} \ No newline at end of file diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml index 8cfb8c8c97..b19745d3a0 100644 --- a/.bcr/presubmit.yml +++ b/.bcr/presubmit.yml @@ -1,15 +1,12 @@ -matrix: - platform: - - macos - - ubuntu2004 - bazel: - - "7.x" - - "8.x" -tasks: - run_tests: - bazel: ${{ bazel }} - platform: ${{ platform }} - build_targets: - - "..." - test_targets: - - "..." +bcr_test_module: + module_path: "." + matrix: + platform: ["debian11", "ubuntu2404", "macos"] + bazel: [7.x, 8.x] + tasks: + run_tests: + name: "Build module" + platform: ${{ platform }} + bazel: ${{ bazel }} + test_targets: + - "//..." diff --git a/.bcr/source.template.json b/.bcr/source.template.json index 9efefe985e..f8192ee372 100644 --- a/.bcr/source.template.json +++ b/.bcr/source.template.json @@ -1,5 +1,5 @@ { "integrity": "", - "strip_prefix": "{REPO}-{VERSION}", + "strip_prefix": "{REPO}-{TAG}", "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/{REPO}-{TAG}.tar.gz" } \ No newline at end of file diff --git a/.github/workflows/ci.bazelrc b/.github/workflows/ci.bazelrc new file mode 100644 index 0000000000..5f63ad54c3 --- /dev/null +++ b/.github/workflows/ci.bazelrc @@ -0,0 +1,13 @@ +# Debug where options came from +build --announce_rc + +# Don't rely on test logs being easily accessible from the test runner, +# though it makes the log noisier. +test --test_output=errors + +# This directory is configured in GitHub actions to be persisted between runs. +build --disk_cache=$HOME/.cache/bazel +build --repository_cache=$HOME/.cache/bazel-repo + +# Allows tests to run bazelisk-in-bazel, since this is the cache folder used +test --test_env=XDG_CACHE_HOME diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000000..6fbee1f082 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,34 @@ +name: CI + +# Controls when the action will run. +on: + push: + branches: [master] + pull_request: + workflow_dispatch: + +concurrency: + # Cancel previous actions from the same PR: https://stackoverflow.com/a/72408109 + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + test: + runs-on: self-hosted + steps: + - uses: actions/checkout@v4 + - uses: bazel-contrib/setup-bazel@0.15.0 + with: + # Avoid downloading Bazel every time. + bazelisk-cache: true + # Store build cache per workflow. + disk-cache: true + # Share repository cache between workflows. + repository-cache: true + - name: bazel test + run: >- + bazelisk + --bazelrc=.github/workflows/ci.bazelrc + --bazelrc=.bazelrc + test + //... diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000000..aa1cb7ccda --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,36 @@ +# Publish new releases to Bazel Central Registry. +name: Publish to BCR +on: + # Run the publish workflow after a successful release + # Will be triggered from the release.yaml workflow + workflow_call: + inputs: + tag_name: + required: true + type: string + secrets: + publish_token: + required: true + # In case of problems, let release engineers retry by manually dispatching + # the workflow from the GitHub UI + workflow_dispatch: + inputs: + tag_name: + description: git tag being released + required: true + type: string +jobs: + publish: + uses: bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml@v0.2.3 + with: + draft: false + tag_name: ${{ inputs.tag_name }} + # GitHub repository which is a fork of the upstream where the Pull Request will be opened. + registry_fork: stackb/bazel-central-registry + permissions: + attestations: write + contents: write + id-token: write + secrets: + # Necessary to push to the BCR fork, and to open a pull request against a registry + publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000000..4274bfd73f --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,36 @@ +# Cut a release whenever a new tag is pushed to the repo. +name: Release +on: + # Can be triggered from the tag.yaml workflow + workflow_call: + inputs: + tag_name: + required: true + type: string + secrets: + publish_token: + required: true + # Or, developers can manually push a tag from their clone + push: + tags: + - "v*.*.*" +permissions: + id-token: write + attestations: write + contents: write +jobs: + release: + uses: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v7.2.3 + # uses: ./.github/workflows/release_ruleset.yaml # copied-from: bazel-contrib/.github/.github/workflows/release_ruleset.yaml@v7.2.3 + with: + prerelease: false + release_files: rules_closure-*.tar.gz + tag_name: ${{ inputs.tag_name || github.ref_name }} + secrets: inherit + publish: + needs: release + uses: ./.github/workflows/publish.yaml + with: + tag_name: ${{ inputs.tag_name || github.ref_name }} + secrets: + publish_token: ${{ secrets.publish_token || secrets.BCR_PUBLISH_TOKEN }} diff --git a/.github/workflows/release_prep.sh b/.github/workflows/release_prep.sh new file mode 100755 index 0000000000..80856c2a3e --- /dev/null +++ b/.github/workflows/release_prep.sh @@ -0,0 +1,28 @@ + +#!/usr/bin/env bash + +set -o errexit -o nounset -o pipefail + +# Set by GH actions, see +# https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables +readonly TAG=$1 +# The prefix is chosen to match what GitHub generates for source archives. +# This guarantees that users can easily switch from a released artifact to a source archive +# with minimal differences in their code (e.g. strip_prefix remains the same) +readonly PREFIX="rules_closure-${TAG}" +readonly ARCHIVE="${PREFIX}.tar.gz" + +# NB: configuration for 'git archive' is in /.gitattributes +git archive --format=tar --prefix=${PREFIX}/ ${TAG} | gzip > $ARCHIVE +SHA=$(shasum -a 256 $ARCHIVE | awk '{print $1}') + +# The stdout of this program will be used as the top of the release notes for this release. +cat << EOF +## Using bzlmod with Bazel 6 or later: + +Add to your \`MODULE.bazel\` file: + +\`\`\`starlark +bazel_dep(name = "rules_closure", version = "${TAG}") +\`\`\` +EOF diff --git a/.github/workflows/release_ruleset.yaml b/.github/workflows/release_ruleset.yaml new file mode 100644 index 0000000000..b790a305b0 --- /dev/null +++ b/.github/workflows/release_ruleset.yaml @@ -0,0 +1,208 @@ +# Reusable workflow that can be referenced by repositories in their `.github/workflows/release.yaml`. +# See example usage in https://github.com/bazel-contrib/rules-template/blob/main/.github/workflows/release.yaml +# +# This workflow calls `.github/workflows/release_prep.sh` as the command to prepare the release. +# Release notes are expected to be outputted to stdout from the release prep command. +# +# This workflow uses https://github.com/bazel-contrib/setup-bazel to prepare the cache folders. +# Caching may be disabled by setting `mount_bazel_caches` to false. +# +# The workflow requires the following permissions to be set on the invoking job: +# +# permissions: +# id-token: write # Needed to attest provenance +# attestations: write # Needed to attest provenance +# contents: write # Needed to upload release files + +permissions: {} + +on: + # Make this workflow reusable, see + # https://github.blog/2022-02-10-using-reusable-workflows-github-actions + workflow_call: + inputs: + release_files: + required: true + description: | + Newline-delimited globs of paths to assets to upload for release. + relative to the module repository. The paths should include any files + such as a release archive created by the release_prep script`. + + See https://github.com/softprops/action-gh-release#inputs. + type: string + # TODO: there's a security design problem here: + # Users of a workflow_dispatch trigger could fill in something via the GH Web UI + # that would cause the release to use an arbitrary script. + # That change wouldn't be reflected in the sources in the repo, and therefore + # would not be verifiable by the attestation. + # For now, we force this path to be hard-coded. + # + # release_prep_command: + # default: .github/workflows/release_prep.sh + # description: | + # Command to run to prepare the release and generate release notes. + # Release notes are expected to be outputted to stdout. + # type: string + bazel_test_command: + default: "bazel test //..." + description: | + Bazel test command that may be overridden to set custom flags and targets. + The --disk_cache=~/.cache/bazel-disk-cache --repository_cache=~/.cache/bazel-repository-cache flags are + automatically appended to the command. + type: string + mount_bazel_caches: + default: true + description: | + Whether to enable caching in the bazel-contrib/setup-bazel action. + type: boolean + prerelease: + default: true + description: Indicator of whether or not this is a prerelease. + type: boolean + draft: + default: false + description: | + Whether the release should be created as a draft or published immediately. + type: boolean + tag_name: + description: | + The tag which is being released. + By default, https://github.com/softprops/action-gh-release will use `github.ref_name`. + type: string + +jobs: + build: + outputs: + release-files-artifact-id: ${{ steps.upload-release-files.outputs.artifact-id }} + release-notes-artifact-id: ${{ steps.upload-release-notes.outputs.artifact-id }} + runs-on: self-hosted + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.tag_name }} + + - uses: bazel-contrib/setup-bazel@0.14.0 + with: + disk-cache: ${{ inputs.mount_bazel_caches }} + repository-cache: ${{ inputs.mount_bazel_caches }} + + - name: Test + run: ${{ inputs.bazel_test_command }} --disk_cache=~/.cache/bazel-disk-cache --repository_cache=~/.cache/bazel-repository-cache + + # Fetch built artifacts (if any) from earlier jobs, which the release script may want to read. + # Extract into ${GITHUB_WORKSPACE}/artifacts/* + - uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1 + + - name: Build release artifacts and prepare release notes + run: | + if [ ! -f ".github/workflows/release_prep.sh" ]; then + echo "ERROR: create a .github/workflows/release_prep.sh script" + exit 1 + fi + .github/workflows/release_prep.sh ${{ inputs.tag_name || github.ref_name }} > release_notes.txt + + - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 #v4.6.0 + id: upload-release-files + with: + name: release_files + path: ${{ inputs.release_files }} + + - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 #v4.6.0 + id: upload-release-notes + with: + name: release_notes + path: release_notes.txt + + attest: + needs: build + outputs: + attestations-artifact-id: ${{ steps.upload-attestations.outputs.artifact-id }} + permissions: + id-token: write + attestations: write + runs-on: ubuntu-latest + steps: + # actions/download-artifact@v4 does not yet support downloading via the immutable artifact-id, + # but the Javascript library does. See: https://github.com/actions/download-artifact/issues/349 + - run: npm install @actions/artifact@2.1.9 + - name: download-release-files + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + env: + ARTIFACT_ID: ${{ needs.build.outputs.release-files-artifact-id }} + with: + script: | + const {default: artifactClient} = require('@actions/artifact') + const { ARTIFACT_ID } = process.env + await artifactClient.downloadArtifact(ARTIFACT_ID, { path: 'release_files/'}) + + # https://github.com/actions/attest-build-provenance + - name: Attest release files + id: attest_release + uses: actions/attest-build-provenance@v2 + with: + subject-path: release_files/**/* + + # The Bazel Central Registry requires an attestation per release archive, but the + # actions/attest-build-provenance action only produces a single attestation for a + # list of subjects. Copy the combined attestations into individually named + # .intoto.jsonl files. + - name: Write release archive attestations into intoto.jsonl + id: write_release_archive_attestation + run: | + # https://bazel.build/rules/lib/repo/http#http_archive + RELEASE_ARCHIVE_REGEX="(\.zip|\.jar|\.war|\.aar|\.tar|\.tar\.gz|\.tgz|\.tar\.xz|\.txz|\.tar\.xzt|\.tzst|\.tar\.bz2|\.ar|\.deb)$" + + ATTESTATIONS_DIR=$(mktemp --directory) + for filename in $(find release_files/ -type f -printf "%f\n"); do + if [[ "${filename}" =~ $RELEASE_ARCHIVE_REGEX ]]; then + ATTESTATION_FILE="$(basename "${filename}").intoto.jsonl" + echo "Writing attestation to ${ATTESTATION_FILE}" + cat ${{ steps.attest_release.outputs.bundle-path }} | jq --compact-output > "${ATTESTATIONS_DIR}/${ATTESTATION_FILE}" + fi + done + echo "release_archive_attestations_dir=${ATTESTATIONS_DIR}" >> $GITHUB_OUTPUT + - uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 #v4.6.0 + id: upload-attestations + with: + name: attestations + path: ${{ steps.write_release_archive_attestation.outputs.release_archive_attestations_dir }}/* + + release: + needs: [build, attest] + permissions: + contents: write + runs-on: ubuntu-latest + steps: + # actions/download-artifact@v4 does not yet support downloading via the immutable artifact-id, + # but the Javascript library does. See: https://github.com/actions/download-artifact/issues/349 + - run: npm install @actions/artifact@2.1.9 + - name: download-artifacts + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + env: + RELEASE_FILES_ARTIFACT_ID: ${{ needs.build.outputs.release-files-artifact-id }} + RELEASE_NOTES_ARTIFACT_ID: ${{ needs.build.outputs.release-notes-artifact-id }} + ATTESTATIONS_ARTIFACT_ID: ${{ needs.attest.outputs.attestations-artifact-id }} + with: + script: | + const {default: artifactClient} = require('@actions/artifact') + const { RELEASE_FILES_ARTIFACT_ID, RELEASE_NOTES_ARTIFACT_ID, ATTESTATIONS_ARTIFACT_ID } = process.env + await Promise.all([ + artifactClient.downloadArtifact(RELEASE_FILES_ARTIFACT_ID, { path: 'release_files/'}), + artifactClient.downloadArtifact(RELEASE_NOTES_ARTIFACT_ID, { path: 'release_notes/'}), + artifactClient.downloadArtifact(ATTESTATIONS_ARTIFACT_ID, { path: 'attestations/'}) + ]) + + - name: Release + uses: softprops/action-gh-release@v2 + with: + prerelease: ${{ inputs.prerelease }} + draft: ${{ inputs.draft }} + # Use GH feature to populate the changelog automatically + generate_release_notes: true + body_path: release_notes/release_notes.txt + fail_on_unmatched_files: true + tag_name: ${{ inputs.tag_name }} + files: | + release_files/**/* + attestations/* diff --git a/MODULE.bazel b/MODULE.bazel index a795b4e314..25881e5c97 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,94 +1,77 @@ module( - name = "rules_closure", - version = "0.15.0", -) - -bazel_dep( - name = "bazel_skylib", - version = "1.7.1", -) - -bazel_dep( - name = "platforms", - version = "0.0.5", -) - -# TODO(mollyibot): Remove this in the future. -bazel_dep( - name = "rules_proto", - version = "7.0.2", -) - -bazel_dep( - name = "protobuf", - version = "31.0", - repo_name = "com_google_protobuf", -) - -bazel_dep( - name = "google_bazel_common", - version = "0.0.1", -) - -bazel_dep( - name = "rules_webtesting", - version = "0.4.1", -) - -bazel_dep( - name = "rules_web_testing_java", - version = "0.4.1", -) - -##### Java dependencies ##### -bazel_dep( - name = "rules_java", - version = "8.6.1", -) - -bazel_dep( - name = "rules_jvm_external", - version = "6.6", -) - -maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") - -maven.install( - artifacts = [ - "args4j:args4j:2.33", - "com.google.closure-stylesheets:closure-stylesheets:1.5.0", - "com.google.dagger:dagger-producers:2.43.2", - "com.google.jimfs:jimfs:1.1", - "net.java.dev.javacc:javacc:7.0.13", - "org.jsoup:jsoup:1.16.1", - "org.seleniumhq.selenium:selenium-remote-driver:4.27.0", - "org.seleniumhq.selenium:selenium-api:4.27.0", - "org.seleniumhq.selenium:selenium-support:4.27.0", - ], -) - -# Using maven.artifact here because the version number vxxxxx cannot parsed correctly. -maven.artifact( - artifact = "closure-compiler", - group = "com.google.javascript", - version = "v20250402", -) - -# javacc:javacc was not updated since 2008 and relocated to net.java.dev.javacc -maven.override( - coordinates = "javacc:javacc", - target = "@maven//:net_java_dev_javacc_javacc", -) - -use_repo(maven, "maven") + name = "stackb_rules_closure", + version = "0.0.0", + compatibility_level = 1, +) + +# ------------------------------------------------------------------- +# Direct Dependencies +# ------------------------------------------------------------------- + +bazel_dep(name = "bazel_skylib", version = "1.8.2") +bazel_dep(name = "build_stack_rules_proto", version = "4.1.1") +bazel_dep(name = "closure-templates", version = "1.0.1") +bazel_dep(name = "google_bazel_common", version = "0.0.1") +bazel_dep(name = "platforms", version = "1.0.0") +bazel_dep(name = "protobuf_javascript", version = "0.0.0") +bazel_dep(name = "protobuf", version = "32.1", repo_name = "com_google_protobuf") +bazel_dep(name = "rules_java", version = "8.16.1") +bazel_dep(name = "rules_shell", version = "0.6.1") +bazel_dep(name = "rules_jvm_external", version = "6.8") +bazel_dep(name = "rules_proto", version = "7.1.0") +bazel_dep(name = "rules_python", version = "1.5.3") +bazel_dep(name = "rules_tsickle", version = "1.1.0") +bazel_dep(name = "rules_web_testing_java", version = "0.4.1") +bazel_dep(name = "rules_webtesting", version = "0.4.1") + +# google_bazel_common override is needed for @closure-compiler +git_override( + module_name = "google_bazel_common", + # Pin to newer version to fix b/408030907 + commit = "2cab52929507935aa43d460a3976d3bedc814d3a", + remote = "https://github.com/google/bazel-common", +) + +# ------------------------------------------------------------------- +# Overrides +# ------------------------------------------------------------------- + +# NOTE: cannot upgrade past protobuf editions... +# +# Commit: 263ee701cba6b75e1f8eddad5adcdf74718318b1 +# Date: 2025-10-08 21:32:22 +0000 UTC +# URL: https://github.com/protocolbuffers/protobuf-javascript/commit/263ee701cba6b75e1f8eddad5adcdf74718318b1 +# +# remove writeZigzagVarint64BigInt +# Size: 401599 (402 kB) +archive_override( + module_name = "protobuf_javascript", + sha256 = "8a50071fbca5e4a26361e6c9d81dd842207f0005f7cc1720226f20c25a231805", + strip_prefix = "protobuf-javascript-263ee701cba6b75e1f8eddad5adcdf74718318b1", + urls = ["https://github.com/protocolbuffers/protobuf-javascript/archive/263ee701cba6b75e1f8eddad5adcdf74718318b1.tar.gz"], + patches = ["closure/protobuf/protobuf_javascript.patch"], + patch_strip = 1, +) + +# Commit: 04fc63fb40bf30d2e5e0b3786028eb41218de979 +# Date: 2025-10-09 04:43:15 +0000 UTC +# URL: https://github.com/stackb/rules_proto/commit/04fc63fb40bf30d2e5e0b3786028eb41218de979 +# +# Remove lock file for @maven +# +# It is shared by multiple workspaces and seems to cause problems when locked +# Size: 4088796 (4.1 MB) +archive_override( + module_name = "build_stack_rules_proto", + sha256 = "aff21579deef91316c726582bec71c621dde2ae2ec74099a55b637bda8997333", + strip_prefix = "rules_proto-04fc63fb40bf30d2e5e0b3786028eb41218de979", + urls = ["https://github.com/stackb/rules_proto/archive/04fc63fb40bf30d2e5e0b3786028eb41218de979.tar.gz"], +) + +# ------------------------------------------------------------------- +# additional http dependencies +# ------------------------------------------------------------------- -##### Python dependencies ##### -bazel_dep( - name = "rules_python", - version = "1.0.0", -) - -##### Other dependencies ##### http_file = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file") http_file( @@ -160,3 +143,60 @@ platform_http_file( "https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip", ], ) + +# ------------------------------------------------------------------- +# java configuration +# ------------------------------------------------------------------- + +# Compatibility layer +compat = use_extension("@rules_java//java:rules_java_deps.bzl", "compatibility_proxy") +use_repo(compat, "compatibility_proxy") + +# ------------------------------------------------------------------- +# maven configuration +# ------------------------------------------------------------------- + +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") + +# NOTE: even though we isolate OUR maven deps into a separate namespace, we +# still need the ones from other contributing modules. That is why this +# maven.install() declaration exists, and I am surprised bzlmod / +# rules_jvm_external works this way. +maven.install( + name = "maven", + known_contributing_modules = [ + "build_stack_rules_proto", + "grpc-java", + "stackb_rules_closure", + "protobuf", + "rules_web_testing_java", + ], +) +maven.install( + name = "maven_rules_closure", + artifacts = [ + "args4j:args4j:2.33", + "com.google.closure-stylesheets:closure-stylesheets:1.5.0", + "com.google.dagger:dagger-producers:2.43.2", + "com.google.jimfs:jimfs:1.1", + "net.java.dev.javacc:javacc:7.0.13", + "org.jsoup:jsoup:1.16.1", + "org.seleniumhq.selenium:selenium-remote-driver:4.27.0", + "org.seleniumhq.selenium:selenium-api:4.27.0", + "org.seleniumhq.selenium:selenium-support:4.27.0", + ], + lock_file = "//:maven_rules_closure_install.json", +) +maven.artifact( + name = "maven_rules_closure", + artifact = "closure-compiler", + group = "com.google.javascript", + # version = "v20250402", # Using maven.artifact here because the version number vxxxxx cannot parsed correctly. + version = "v20250820", # Using maven.artifact here because the version number vxxxxx cannot parsed correctly. +) +maven.override( + name = "maven_rules_closure", + coordinates = "javacc:javacc", + target = "@maven_rules_closure//:net_java_dev_javacc_javacc", # javacc:javacc was not updated since 2008 and relocated to net.java.dev.javacc +) +use_repo(maven, "maven_rules_closure") diff --git a/README.md b/README.md index b047348fac..5dd82195b7 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,20 @@ +# Notice + +This is fork of [bazelbuild/rules_closure](https://github.com/bazelbuild/rules_closure) with the following main differences: + +- repo name is `@stackb_rules_closure` instead of `@rules_closure`. +- the `closure/library` has been restored. +- missing shims and third-party closure js code has been vendored in `google3/`. +- support for protobuf-javascript has been restored. +- support for closure-templates has been restored. +- integrated example app (`//closure/compiler/test/app:web`). +- bzlmod deps updated +- stricter .bazelrc flags + # Closure Rules for Bazel (αlpha) [](https://buildkite.com/bazel/closure-compiler-rules-closure-postsubmit) -JavaScript | Stylesheets | Miscellaneous ---- | --- | --- +JavaScript | Stylesheets | Miscellaneous +---------------------|-----------------------|----------------- [closure_js_library] | [closure_css_library] | [phantomjs_test] [closure_js_binary] | [closure_css_binary] | | [closure_js_test] | | @@ -64,7 +77,7 @@ First you must [install Bazel]. Then you add the following to your MODULE.bazel file: ```bzl -bazel_dep(name = "rules_closure", version = "0.15.0") +bazel_dep(name = "stackb_rules_closure", version = "0.15.0") ``` The root module has to declare the same override for rules_webtesting, rules_scala, and google_bazel_common temporarily until they are registered @@ -77,9 +90,9 @@ for that matter; they will be fetched automatically by Bazel. Please see the test directories within this project for concrete examples of usage: -- [//closure/testing/test](https://github.com/bazelbuild/rules_closure/tree/master/closure/testing/test) -- [//closure/compiler/test](https://github.com/bazelbuild/rules_closure/tree/master/closure/compiler/test) -- [//closure/stylesheets/test](https://github.com/bazelbuild/rules_closure/tree/master/closure/stylesheets/test) +- [//closure/testing/test](https://github.com/stackb/stackb_rules_closure/tree/master/closure/testing/test) +- [//closure/compiler/test](https://github.com/stackb/stackb_rules_closure/tree/master/closure/compiler/test) +- [//closure/stylesheets/test](https://github.com/stackb/stackb_rules_closure/tree/master/closure/stylesheets/test) # Reference @@ -88,7 +101,7 @@ Please see the test directories within this project for concrete examples of usa ## closure\_js\_library ```starlark -load("@rules_closure//closure:defs.bzl", "closure_js_library") +load("//closure:defs.bzl", "closure_js_library") closure_js_library(name, srcs, data, deps, exports, suppress, convention, no_closure_library) ``` @@ -188,7 +201,7 @@ This rule can be referenced as though it were the following: ## closure\_js\_binary ```starlark -load("@rules_closure//closure:defs.bzl", "closure_js_binary") +load("//closure:defs.bzl", "closure_js_binary") closure_js_binary(name, deps, css, debug, language, entry_points, dependency_mode, compilation_level, formatting, output_wrapper, property_renaming_report, defs) @@ -301,7 +314,7 @@ This rule can be referenced as though it were the following: - **defs:** (List of strings; optional) Specifies additional flags to be passed to the Closure Compiler, e.g. `"--hide_warnings_for=some/path/"`. To see what flags are available, run: - `bazel run @rules_closure//third_party/java/jscomp:main -- --help` + `bazel run @stackb_rules_closure//third_party/java/jscomp:main -- --help` ### Support for AngularJS @@ -322,7 +335,7 @@ closure_js_binary( ## closure\_js\_test ```starlark -load("@rules_closure//closure:defs.bzl", "closure_js_test") +load("//closure:defs.bzl", "closure_js_test") closure_js_test(name, srcs, data, deps, css, html, language, suppress, compilation_level, entry_points, defs) ``` @@ -394,7 +407,7 @@ This rule can be referenced as though it were the following: ## phantomjs\_test ```starlark -load("@rules_closure//closure:defs.bzl", "phantomjs_test") +load("//closure:defs.bzl", "phantomjs_test") phantomjs_test(name, data, deps, html, harness, runner) ``` @@ -423,17 +436,17 @@ This rule can be referenced as though it were the following: ` + + +
+ + + +