diff --git a/.bazelversion b/.bazelversion index b616717999..5210382a7a 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -7.4.0 \ No newline at end of file +8.0.1 \ No newline at end of file diff --git a/MODULE.bazel b/MODULE.bazel new file mode 100644 index 0000000000..d03abd55e7 --- /dev/null +++ b/MODULE.bazel @@ -0,0 +1,196 @@ +module( + name = "com_google_j2cl", + version = "v20250115", + bazel_compatibility = [">=8.0.1"], +) + +bazel_dep( + name = "protobuf", + version = "29.0", + repo_name = "com_google_protobuf", +) + +bazel_dep( + name = "bazel_skylib", + version = "1.7.1", +) + +bazel_dep( + name = "platforms", + version = "0.0.5", +) + +bazel_dep( + name = "rules_kotlin", + version = "1.9.6", +) + +bazel_dep( + name = "rules_license", + version = "1.0.0", +) + +# Works around https://github.com/bazelbuild/rules_python/issues/1169 +bazel_dep( + name = "rules_python", + version = "0.23.1", +) + +python = use_extension("@rules_python//python/extensions:python.bzl", "python") +python.toolchain( + configure_coverage_tool = False, + ignore_root_user_error = True, + python_version = "3.11", +) + +# Override rules_webtesting dependencies +bazel_dep( + name = "rules_webtesting", + repo_name = "io_bazel_rules_webtesting", +) + +git_override( + module_name = "rules_webtesting", + commit = "46b744fa916b5cefce6f0f84252f4ec89128a01b", + remote = "https://github.com/bazelbuild/rules_webtesting", +) + +# rules_scala is not available in BCR. +# The root module has to declare the same override as rules_webtesting. +git_override( + module_name = "rules_scala", + commit = "031fb0d3a63467d87f25397eb8e23faa57d1d3a6", + remote = "https://github.com/mbland/rules_scala", +) + +bazel_dep( + name = "io_bazel_rules_closure", +) + +# io_bazel_rules_closure is not available in BCR. +git_override( + module_name = "io_bazel_rules_closure", + commit = "a8f1d2d110b565f0cf47ed86a29ff1e94a826ab4", + remote = "https://github.com/bazelbuild/rules_closure", +) + +bazel_dep(name = "google_bazel_common") + +# google_bazel_common is not available in BCR. +git_override( + module_name = "google_bazel_common", + commit = "34102e4cf748e2922697f28f629ecea687345254", + remote = "https://github.com/google/bazel-common", +) + +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.j2objc:j2objc-annotations:1.3", + "com.google.escapevelocity:escapevelocity:jar:1.1", + "com.google.errorprone:javac:jar:9+181-r4173-1", + "com.google.code.gson:gson:2.10.1", + ], +) + +use_repo(maven, "maven") + +http_jar = use_repo_rule("@rules_java//java:http_jar.bzl", "http_jar") + +http_jar( + name = "org_eclipse_jdt_content_type", + sha256 = "af418cced47512a7cad606ea9a1114267bc224387abcedd639bae8d3a7fb10b9", + url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.core.contenttype_3.7.700.v20200517-1644.jar", +) + +http_jar( + name = "org_eclipse_jdt_jobs", + sha256 = "4d0042425dcc3655c08654351c08b1645ccb309ab5de45743455bfce4849e917", + url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.core.jobs_3.10.800.v20200421-0950.jar", +) + +http_jar( + name = "org_eclipse_jdt_resources", + sha256 = "ce021447dbea30a4e5ddb3f52534cd2794fb52855071b8dcf257b936ab162168", + url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.core.resources_3.13.700.v20200209-1624.jar", +) + +http_jar( + name = "org_eclipse_jdt_runtime", + sha256 = "b5aebc31d480efff38f910a6eab791c2de7b126a47d260252e097b5a27bd0165", + url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.core.runtime_3.18.0.v20200506-2143.jar", +) + +http_jar( + name = "org_eclipse_jdt_equinox_common", + sha256 = "761f9175b9d294d122c1aa92048688f0b71dd81e808c64cbb245ca7539950716", + url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.equinox.common_3.12.0.v20200504-1602.jar", +) + +http_jar( + name = "org_eclipse_jdt_equinox_preferences", + sha256 = "ca62478a40cffdfe9a10dcfb9f8fada760a93644a7de2c2d1897235f67f57b42", + url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.equinox.preferences_3.8.0.v20200422-1833.jar", +) + +http_jar( + name = "org_eclipse_jdt_compiler_apt", + sha256 = "0559677c8d0528fbdfa3a82b4a16661894a9b64a342e418809c64945bb5d3ef1", + url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.jdt.apt.core_3.6.600.v20200529-1546.jar", +) + +http_jar( + name = "org_eclipse_jdt_core", + sha256 = "af89d348c24917506675767fc1534a0d673355d334fbfadd264b9e45ccd9c34c", + url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.jdt.core_3.22.0.v20200530-2032.jar", +) + +http_jar( + name = "org_eclipse_jdt_osgi", + sha256 = "a3544cde6924babf8aff8323f7452ace232d01d040e20d9f9f43027d7b945424", + url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.osgi_3.15.300.v20200520-1959.jar", +) + +http_jar( + name = "org_eclipse_jdt_text", + sha256 = "83ce07ec2058d8d629feb4e269216e286560b0e4587dea883f4e16b64ea51cad", + url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.text_3.10.200.v20200428-0633.jar", +) + +http_archive = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "com_google_jsinterop_annotations-j2cl", + sha256 = "4164229681bcaf3d130b6c4f463bc345af69de5ad548120e9818f31c70142717", + strip_prefix = "jsinterop-annotations-d2b3aee14b617a81570b788f981926a829ac892c", + urls = ["https://github.com/google/jsinterop-annotations/archive/d2b3aee14b617a81570b788f981926a829ac892c.zip"], +) + +http_archive( + name = "bazel_common_javadoc", + sha256 = "3f090bfb3c0c66e3c2d9ae229d184af1147e4c06223551aeb2ff292661371b9a", + strip_prefix = "bazel-common-ebce2af3f0de560b649dcf98ef732a56b80e829c/tools/javadoc", + urls = ["https://github.com/google/bazel-common/archive/ebce2af3f0de560b649dcf98ef732a56b80e829c.zip"], +) + +http_archive( + name = "com_google_binaryen", + build_file = "@com_google_j2cl//build_defs/internal_do_not_use/binaryen:BUILD.binaryen", + patch_args = ["-p1"], + patches = ["@com_google_j2cl//build_defs/internal_do_not_use/binaryen:generate_intrinsics.patch"], + sha256 = "a3b0c6b4884cd147913088817f6e238e700394834a7cbd8610acd6b23bdd4860", + strip_prefix = "binaryen-6645f0c05b8e9268f35742bb6b0a67e0a9c40795", + url = "https://github.com/WebAssembly/binaryen/archive/6645f0c05b8e9268f35742bb6b0a67e0a9c40795.zip", +) diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index 2276260c09..0000000000 --- a/WORKSPACE +++ /dev/null @@ -1,13 +0,0 @@ -workspace(name = "com_google_j2cl") - -load("//build_defs:repository.bzl", "load_j2cl_repo_deps") -load_j2cl_repo_deps() - -load("//build_defs:workspace.bzl", "setup_j2cl_workspace") -setup_j2cl_workspace() - -# Needed to run unit tests in Chrome. -load("@io_bazel_rules_closure//closure:defs.bzl", "setup_web_test_repositories") -setup_web_test_repositories( - chromium = True, -) diff --git a/build_defs/internal_do_not_use/j2cl_repo.bzl b/build_defs/internal_do_not_use/j2cl_repo.bzl index d614d5ab79..ce327e2934 100644 --- a/build_defs/internal_do_not_use/j2cl_repo.bzl +++ b/build_defs/internal_do_not_use/j2cl_repo.bzl @@ -47,7 +47,7 @@ def _j2cl_import_external_common(repository_ctx, artifact_urls, additional_attrs ] if repository_ctx.attr.annotation_only: - jar = repository_ctx.name + "-java" + jar = _extract_repo_name(repository_ctx.name) + "-java" jar_name = jar + ".jar" repository_ctx.download( @@ -62,7 +62,7 @@ def _j2cl_import_external_common(repository_ctx, artifact_urls, additional_attrs " jars = ['%s']," % jar_name, ")", "j2cl_import(", - " name = '%s'," % repository_ctx.name, + " name = '%s'," % _extract_repo_name(repository_ctx.name), " jar = ':%s'," % jar, ] @@ -77,7 +77,7 @@ def _j2cl_import_external_common(repository_ctx, artifact_urls, additional_attrs "REPLACED_SRCS = [s.split('/super/')[1] for s in SUPER_SRCS]", "", "j2cl_library(", - " name = '%s'," % repository_ctx.name, + " name = '%s'," % _extract_repo_name(repository_ctx.name), " srcs = glob(['**/*.java', '**/*.js'],", " exclude = REPLACED_SRCS + ['**/*_CustomFieldSerializer*']", " ),", @@ -187,3 +187,9 @@ j2cl_maven_import_external = repository_rule( }, implementation = _j2cl_maven_import_external, ) + +# TODO(mollyibot): Replace with repository_ctx.original_name after Bazel 8.1 +def _extract_repo_name(name): + """Extracts the repo name from the rule name.""" + SEPARATOR = Label("@com_google_j2cl").workspace_name.removesuffix("com_google_j2cl")[-1] + return name.rsplit(SEPARATOR, 1)[1] diff --git a/build_defs/repository.bzl b/build_defs/repository.bzl deleted file mode 100644 index a3d0b7eb72..0000000000 --- a/build_defs/repository.bzl +++ /dev/null @@ -1,79 +0,0 @@ -"""Bazel rule for loading external repository deps for J2CL.""" - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -def load_j2cl_repo_deps(): - # TODO(b/211017789):Use old proto version until maven issue is fixed. - http_archive( - name = "com_google_protobuf", - strip_prefix = "protobuf-3.19.0", - sha256 = "4a045294ec76cb6eae990a21adb5d8b3c78be486f1507faa601541d1ccefbd6b", - urls = [ - "https://github.com/protocolbuffers/protobuf/archive/v3.19.0.tar.gz", - ], - ) - - _github_repo( - name = "io_bazel_rules_closure", - repo = "bazelbuild/rules_closure", - tag = "b159f5414b4982568b1d93a9f4c23454c73d2fdb", - sha256 = "95913cb037e0561161518b1e4254e04bc1eb85ab96bff5d76e2439490af519a6", - ) - - # TODO(goktug): Consider moving to setup_j2cl_workspace after licences migration - # is completed. - _github_repo( - name = "rules_license", - repo = "bazelbuild/rules_license", - sha256 = "792aad709d8abfbf9e1b523e4c82b6f7cb6035222241f51901e80a7b64a58f94", - tag = "0.0.4", - ) - - _github_repo( - name = "bazel_skylib", - repo = "bazelbuild/bazel-skylib", - tag = "1.0.2", - sha256 = "64ad2728ccdd2044216e4cec7815918b7bb3bb28c95b7e9d951f9d4eccb07625", - ) - - _github_repo( - name = "io_bazel_rules_kotlin", - repo = "bazelbuild/rules_kotlin", - tag = "legacy-1.3.0-rc3", - sha256 = "54678552125753d9fc0a37736d140f1d2e69778d3e52cf454df41a913b964ede", - ) - - _load_binaryen() - -def _load_binaryen(): - - PY_VERSION = "0.23.1" - - http_archive( - name = "rules_python", - strip_prefix = "rules_python-{}".format(PY_VERSION), - url = "https://github.com/bazelbuild/rules_python/releases/download/{}/rules_python-{}.tar.gz".format(PY_VERSION, PY_VERSION), - sha256 = "84aec9e21cc56fbc7f1335035a71c850d1b9b5cc6ff497306f84cced9a769841", - ) - - _github_repo( - name="com_google_binaryen", - repo = "WebAssembly/binaryen", - tag = "6645f0c05b8e9268f35742bb6b0a67e0a9c40795", - sha256 = "a3b0c6b4884cd147913088817f6e238e700394834a7cbd8610acd6b23bdd4860", - patch_args = ["-p1"], - build_file = "@com_google_j2cl//build_defs/internal_do_not_use/binaryen:BUILD.binaryen", - patches = ["@com_google_j2cl//build_defs/internal_do_not_use/binaryen:generate_intrinsics.patch"], - ) - -def _github_repo(name, repo, tag, **kwargs): - if native.existing_rule(name): - return - - _, project_name = repo.split("/") - http_archive( - name = name, - strip_prefix = "%s-%s" % (project_name, tag), - url = "https://github.com/%s/archive/%s.zip" % (repo, tag), - **kwargs - ) diff --git a/build_defs/workspace.bzl b/build_defs/workspace.bzl deleted file mode 100644 index 78e969ed60..0000000000 --- a/build_defs/workspace.bzl +++ /dev/null @@ -1,251 +0,0 @@ -"""Macro to use for loading the J2CL repository""" - -load("@bazel_skylib//lib:versions.bzl", "versions") -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_jar") -load("@bazel_tools//tools/build_defs/repo:jvm.bzl", "jvm_maven_import_external") -load("@io_bazel_rules_closure//closure:repositories.bzl", "rules_closure_dependencies") -load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains") - -_MAVEN_CENTRAL_URLS = ["https://repo1.maven.org/maven2/"] - -def setup_j2cl_workspace(**kwargs): - """Load all dependencies needed for J2CL.""" - - versions.check("7.4.0") # The version J2CL currently have a CI setup for. - - rules_closure_dependencies( - omit_com_google_auto_common = True, - **kwargs - ) - - jvm_maven_import_external( - name = "com_google_auto_common", - artifact = "com.google.auto:auto-common:1.1.2", - artifact_sha256 = "bfe85e517250fc208afd2b031a2ba80f26529c92536484841b4a60661ca1e3f5", - server_urls = _MAVEN_CENTRAL_URLS, - licenses = ["notice"], - ) - - jvm_maven_import_external( - name = "com_google_auto_service_annotations", - artifact = "com.google.auto.service:auto-service-annotations:1.0-rc7", - artifact_sha256 = "986dc826fa0a43bf9f04194c1a8667774f4f44190ec816b08554b47891ba5459", - server_urls = _MAVEN_CENTRAL_URLS, - licenses = ["notice"], - ) - - jvm_maven_import_external( - name = "com_google_auto_service", - artifact = "com.google.auto.service:auto-service:1.0-rc7", - artifact_sha256 = "24f13c98baf5fb87e7502fd87130457941cda405ec6ff28d8ff964a8f58a82ed", - server_urls = _MAVEN_CENTRAL_URLS, - licenses = ["notice"], - ) - - # We cannot replace com_google_jsinterop_annotations so choose a different name - http_archive( - name = "com_google_jsinterop_annotations-j2cl", - urls = ["https://github.com/google/jsinterop-annotations/archive/d2b3aee14b617a81570b788f981926a829ac892c.zip"], - strip_prefix = "jsinterop-annotations-d2b3aee14b617a81570b788f981926a829ac892c", - sha256 = "4164229681bcaf3d130b6c4f463bc345af69de5ad548120e9818f31c70142717", - ) - - http_archive( - name = "bazel_common_javadoc", - strip_prefix = "bazel-common-ebce2af3f0de560b649dcf98ef732a56b80e829c/tools/javadoc", - urls = ["https://github.com/google/bazel-common/archive/ebce2af3f0de560b649dcf98ef732a56b80e829c.zip"], - sha256 = "3f090bfb3c0c66e3c2d9ae229d184af1147e4c06223551aeb2ff292661371b9a", - ) - - jvm_maven_import_external( - name = "com_google_j2objc_annotations", - artifact = "com.google.j2objc:j2objc-annotations:1.3", - artifact_sha256 = "21af30c92267bd6122c0e0b4d20cccb6641a37eaf956c6540ec471d584e64a7b", - server_urls = _MAVEN_CENTRAL_URLS, - licenses = ["notice"], - ) - - jvm_maven_import_external( - name = "org_jspecify", - artifact = "org.jspecify:jspecify:0.3.0", - artifact_sha256 = "e1c7e1832b6095fcfcbe57485700c7330d53d4e57e2c5bbf9c71819b02e978be", - server_urls = _MAVEN_CENTRAL_URLS, - licenses = ["notice"], - ) - - jvm_maven_import_external( - name = "org_apache_commons_collections", - artifact = "commons-collections:commons-collections:3.2.2", - artifact_sha256 = "eeeae917917144a68a741d4c0dff66aa5c5c5fd85593ff217bced3fc8ca783b8", - server_urls = _MAVEN_CENTRAL_URLS, - licenses = ["notice"], - ) - - jvm_maven_import_external( - name = "org_apache_commons_lang2", - artifact = "commons-lang:commons-lang:2.6", - artifact_sha256 = "50f11b09f877c294d56f24463f47d28f929cf5044f648661c0f0cfbae9a2f49c", - server_urls = _MAVEN_CENTRAL_URLS, - licenses = ["notice"], - ) - - jvm_maven_import_external( - name = "com_google_escapevelocity", - artifact = "com.google.escapevelocity:escapevelocity:1.1", - artifact_sha256 = "37e76e4466836dedb864fb82355cd01c3bd21325ab642d89a0f759291b171231", - server_urls = _MAVEN_CENTRAL_URLS, - licenses = ["notice"], - ) - - jvm_maven_import_external( - name = "org_junit", - artifact = "junit:junit:4.13.2", - artifact_sha256 = "8e495b634469d64fb8acfa3495a065cbacc8a0fff55ce1e31007be4c16dc57d3", - server_urls = _MAVEN_CENTRAL_URLS, - licenses = ["notice"], - ) - - jvm_maven_import_external( - name = "com_google_testing_compile", - artifact = "com.google.testing.compile:compile-testing:0.15", - artifact_sha256 = "f741c21d44ddf4580e99cfc537e76d1760d864637aec1e21d5341f672a165d4c", - server_urls = _MAVEN_CENTRAL_URLS, - licenses = ["notice"], - ) - - jvm_maven_import_external( - name = "org_mockito", - artifact = "org.mockito:mockito-all:1.9.5", - artifact_sha256 = "b2a63307d1dce3aa1623fdaacb2327a4cd7795b0066f31bf542b1e8f2683239e", - server_urls = _MAVEN_CENTRAL_URLS, - licenses = ["notice"], - ) - - jvm_maven_import_external( - name = "com_google_truth", - artifact = "com.google.truth:truth:1.0", - artifact_sha256 = "edaa12f3b581fcf1c07311e94af8766919c4f3d904b00d3503147b99bf5b4004", - server_urls = _MAVEN_CENTRAL_URLS, - licenses = ["notice"], - ) - - # TODO(b/135461024): for now J2CL uses a prepackaged version of javac. But in the future it - # might be better to tie in to the Java platform in bazel and control the version there. - jvm_maven_import_external( - name = "com_sun_tools_javac", - artifact = "com.google.errorprone:javac:9+181-r4173-1", - artifact_sha256 = "1d8d347a0e1579f3fc86ac04d1974e489afc66357f0009ac9804a7ac30912ed6", - server_urls = _MAVEN_CENTRAL_URLS, - licenses = ["notice"], - ) - - # Eclipse JARs listed at - # http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/ - - http_jar( - name = "org_eclipse_jdt_content_type", - url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.core.contenttype_3.7.700.v20200517-1644.jar", - sha256 = "af418cced47512a7cad606ea9a1114267bc224387abcedd639bae8d3a7fb10b9", - ) - - http_jar( - name = "org_eclipse_jdt_jobs", - url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.core.jobs_3.10.800.v20200421-0950.jar", - sha256 = "4d0042425dcc3655c08654351c08b1645ccb309ab5de45743455bfce4849e917", - ) - - http_jar( - name = "org_eclipse_jdt_resources", - url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.core.resources_3.13.700.v20200209-1624.jar", - sha256 = "ce021447dbea30a4e5ddb3f52534cd2794fb52855071b8dcf257b936ab162168", - ) - - http_jar( - name = "org_eclipse_jdt_runtime", - url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.core.runtime_3.18.0.v20200506-2143.jar", - sha256 = "b5aebc31d480efff38f910a6eab791c2de7b126a47d260252e097b5a27bd0165", - ) - - http_jar( - name = "org_eclipse_jdt_equinox_common", - url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.equinox.common_3.12.0.v20200504-1602.jar", - sha256 = "761f9175b9d294d122c1aa92048688f0b71dd81e808c64cbb245ca7539950716", - ) - - http_jar( - name = "org_eclipse_jdt_equinox_preferences", - url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.equinox.preferences_3.8.0.v20200422-1833.jar", - sha256 = "ca62478a40cffdfe9a10dcfb9f8fada760a93644a7de2c2d1897235f67f57b42", - ) - - http_jar( - name = "org_eclipse_jdt_compiler_apt", - url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.jdt.apt.core_3.6.600.v20200529-1546.jar", - sha256 = "0559677c8d0528fbdfa3a82b4a16661894a9b64a342e418809c64945bb5d3ef1", - ) - - http_jar( - name = "org_eclipse_jdt_core", - url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.jdt.core_3.22.0.v20200530-2032.jar", - sha256 = "af89d348c24917506675767fc1534a0d673355d334fbfadd264b9e45ccd9c34c", - ) - - http_jar( - name = "org_eclipse_jdt_osgi", - url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.osgi_3.15.300.v20200520-1959.jar", - sha256 = "a3544cde6924babf8aff8323f7452ace232d01d040e20d9f9f43027d7b945424", - ) - - http_jar( - name = "org_eclipse_jdt_text", - url = "http://download.eclipse.org/eclipse/updates/4.16/R-4.16-202006040540/plugins/org.eclipse.text_3.10.200.v20200428-0633.jar", - sha256 = "83ce07ec2058d8d629feb4e269216e286560b0e4587dea883f4e16b64ea51cad", - ) - - jvm_maven_import_external( - name = "org_ow2_asm_asm", - artifact = "org.ow2.asm:asm:9.7", - artifact_sha256 = "adf46d5e34940bdf148ecdd26a9ee8eea94496a72034ff7141066b3eea5c4e9d", - server_urls = _MAVEN_CENTRAL_URLS, - licenses = ["notice"], - ) - - kotlin_repositories( - compiler_release = { - "urls": [ - "https://github.com/JetBrains/kotlin/releases/download/v1.6.10/kotlin-compiler-1.6.10.zip", - ], - "sha256": "432267996d0d6b4b17ca8de0f878e44d4a099b7e9f1587a98edc4d27e76c215a", - }, - ) - kt_register_toolchains() - - # Required by protobuf_java_util - native.bind( - name = "guava", - actual = "@com_google_guava", - ) - - # Required by protobuf_java_util - native.bind( - name = "gson", - actual = "@com_google_code_gson", - ) - - # Required by protobuf_java_util - native.bind( - name = "error_prone_annotations", - actual = "@com_google_errorprone_error_prone_annotations", - ) - - # Required by protobuf_java_util - native.bind( - name = "jsr305", - actual = "@com_google_code_findbugs_jsr305", - ) - - # Required by protobuf_java_util - native.bind( - name = "j2objc_annotations", - actual = "@com_google_j2objc_annotations", - ) \ No newline at end of file diff --git a/docs/getting-started-j2wasm.md b/docs/getting-started-j2wasm.md index 6c8d6c7652..c4a6781db1 100644 --- a/docs/getting-started-j2wasm.md +++ b/docs/getting-started-j2wasm.md @@ -102,7 +102,7 @@ To setup your first project you can use the sample as template: ```shell $ cp -R /samples/wasm / - $ mv //WORKSPACE.remote //WORKSPACE + $ mv //MODULE.bazel //MODULE.bazel ``` and you are done. diff --git a/docs/getting-started.md b/docs/getting-started.md index 92288acc48..70901ca38c 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -116,7 +116,7 @@ To setup your first project you can use the sample as template: ```shell $ cp -R /samples/helloworld / - $ mv //WORKSPACE.remote //WORKSPACE + $ mv //MODULE.bazel //MODULE.bazel ``` and you are done. diff --git a/jre/javatests/BUILD b/jre/javatests/BUILD index e3bba8b9f6..bfaaa84a6f 100644 --- a/jre/javatests/BUILD +++ b/jre/javatests/BUILD @@ -31,6 +31,7 @@ ERROR_PRONE_SUPPRESSIONS = [ "-Xep:IdentityBinaryExpression:OFF", "-Xep:MixedArrayDimensions:OFF", # See go/lsc-mixedarraydimensions "-Xep:ReturnValueIgnored:OFF", + "-Xep:SelfAssertion:OFF", "-Xep:SelfComparison:OFF", "-Xep:SelfEquality:OFF", "-Xep:SelfEquals:OFF", diff --git a/samples/guava/.bazelversion b/samples/guava/.bazelversion index b616717999..5210382a7a 100644 --- a/samples/guava/.bazelversion +++ b/samples/guava/.bazelversion @@ -1 +1 @@ -7.4.0 \ No newline at end of file +8.0.1 \ No newline at end of file diff --git a/samples/guava/WORKSPACE b/samples/guava/MODULE.bazel similarity index 53% rename from samples/guava/WORKSPACE rename to samples/guava/MODULE.bazel index 7300cde7d1..3453bbca23 100644 --- a/samples/guava/WORKSPACE +++ b/samples/guava/MODULE.bazel @@ -1,23 +1,65 @@ -workspace(name = "com_google_j2cl_samples_guava") - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") +module( + name = "com_google_j2cl_samples_guava", +) -local_repository( +bazel_dep( name = "com_google_j2cl", +) + +local_path_override( + module_name = "com_google_j2cl", path = "../..", ) -load("@com_google_j2cl//build_defs:repository.bzl", "load_j2cl_repo_deps") -load_j2cl_repo_deps() +bazel_dep( + name = "io_bazel_rules_closure", +) -load("@com_google_j2cl//build_defs:workspace.bzl", "setup_j2cl_workspace") -setup_j2cl_workspace() +# io_bazel_rules_closure is not available in BCR. +git_override( + module_name = "io_bazel_rules_closure", + commit = "a8f1d2d110b565f0cf47ed86a29ff1e94a826ab4", + remote = "https://github.com/bazelbuild/rules_closure", +) -_MAVEN_CENTRAL_URLS = ["https://repo1.maven.org/maven2/"] +# io_bazel_rules_webtesting is not available in BCR. +git_override( + module_name = "rules_webtesting", + commit = "46b744fa916b5cefce6f0f84252f4ec89128a01b", + remote = "https://github.com/bazelbuild/rules_webtesting", +) + +# rules_scala is not available in BCR, needed for rules_webtesting. +git_override( + module_name = "rules_scala", + commit = "031fb0d3a63467d87f25397eb8e23faa57d1d3a6", + remote = "https://github.com/mbland/rules_scala", +) +# google_bazel_common is not available in BCR. +git_override( + module_name = "google_bazel_common", + commit = "34102e4cf748e2922697f28f629ecea687345254", + remote = "https://github.com/google/bazel-common", +) -load("@com_google_j2cl//build_defs:rules.bzl", "j2cl_maven_import_external") +# Works around https://github.com/bazelbuild/rules_python/issues/1169 +bazel_dep( + name = "rules_python", + version = "0.23.1", +) +python = use_extension("@rules_python//python/extensions:python.bzl", "python") + +python.toolchain( + configure_coverage_tool = False, + ignore_root_user_error = True, + python_version = "3.11", +) + +j2cl_maven_import_external = use_repo_rule("@com_google_j2cl//build_defs:rules.bzl", "j2cl_maven_import_external") + +_MAVEN_CENTRAL_URLS = ["https://repo1.maven.org/maven2/"] j2cl_maven_import_external( name = "org_checkerframework_checker_qual-j2cl", annotation_only = True, @@ -62,3 +104,4 @@ j2cl_maven_import_external( "@org_checkerframework_checker_qual-j2cl", ], ) + diff --git a/samples/helloworld/.bazelversion b/samples/helloworld/.bazelversion index b616717999..5210382a7a 100644 --- a/samples/helloworld/.bazelversion +++ b/samples/helloworld/.bazelversion @@ -1 +1 @@ -7.4.0 \ No newline at end of file +8.0.1 \ No newline at end of file diff --git a/samples/helloworld/MODULE.bazel b/samples/helloworld/MODULE.bazel new file mode 100644 index 0000000000..e1cddba939 --- /dev/null +++ b/samples/helloworld/MODULE.bazel @@ -0,0 +1,58 @@ +module( + name = "com_google_j2cl_samples_helloworld", +) + +bazel_dep( + name = "com_google_j2cl", +) + +local_path_override( + module_name = "com_google_j2cl", + path = "../..", +) + +bazel_dep( + name = "io_bazel_rules_closure", +) + +# io_bazel_rules_closure is not available in BCR. +git_override( + module_name = "io_bazel_rules_closure", + commit = "a8f1d2d110b565f0cf47ed86a29ff1e94a826ab4", + remote = "https://github.com/bazelbuild/rules_closure", +) + +# io_bazel_rules_webtesting is not available in BCR. +git_override( + module_name = "rules_webtesting", + commit = "46b744fa916b5cefce6f0f84252f4ec89128a01b", + remote = "https://github.com/bazelbuild/rules_webtesting", +) + +# rules_scala is not available in BCR, needed for rules_webtesting. +git_override( + module_name = "rules_scala", + commit = "031fb0d3a63467d87f25397eb8e23faa57d1d3a6", + remote = "https://github.com/mbland/rules_scala", +) + +# google_bazel_common is not available in BCR. +git_override( + module_name = "google_bazel_common", + commit = "34102e4cf748e2922697f28f629ecea687345254", + remote = "https://github.com/google/bazel-common", +) + +# Works around https://github.com/bazelbuild/rules_python/issues/1169 +bazel_dep( + name = "rules_python", + version = "0.23.1", +) + +python = use_extension("@rules_python//python/extensions:python.bzl", "python") + +python.toolchain( + configure_coverage_tool = False, + ignore_root_user_error = True, + python_version = "3.11", +) \ No newline at end of file diff --git a/samples/helloworld/WORKSPACE b/samples/helloworld/WORKSPACE deleted file mode 100644 index df222689a8..0000000000 --- a/samples/helloworld/WORKSPACE +++ /dev/null @@ -1,15 +0,0 @@ -workspace(name = "com_google_j2cl_samples_helloworld") - -# Load j2cl repository -# If you are not developing with J2CL, you may want to use a remote repository -# instead. See WORKSPACE.remote for the alternative. -local_repository( - name = "com_google_j2cl", - path = "../..", -) - -load("@com_google_j2cl//build_defs:repository.bzl", "load_j2cl_repo_deps") -load_j2cl_repo_deps() - -load("@com_google_j2cl//build_defs:workspace.bzl", "setup_j2cl_workspace") -setup_j2cl_workspace() diff --git a/samples/helloworld/WORKSPACE.remote b/samples/helloworld/WORKSPACE.remote deleted file mode 100644 index 59178c62dd..0000000000 --- a/samples/helloworld/WORKSPACE.remote +++ /dev/null @@ -1,16 +0,0 @@ -workspace(name = "com_google_j2cl_samples_helloworld") - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -# Load j2cl repository -http_archive( - name = "com_google_j2cl", - strip_prefix = "j2cl-master", - url = "https://github.com/google/j2cl/archive/master.zip", -) - -load("@com_google_j2cl//build_defs:repository.bzl", "load_j2cl_repo_deps") -load_j2cl_repo_deps() - -load("@com_google_j2cl//build_defs:workspace.bzl", "setup_j2cl_workspace") -setup_j2cl_workspace() diff --git a/samples/wasm/.bazelversion b/samples/wasm/.bazelversion index b616717999..5210382a7a 100644 --- a/samples/wasm/.bazelversion +++ b/samples/wasm/.bazelversion @@ -1 +1 @@ -7.4.0 \ No newline at end of file +8.0.1 \ No newline at end of file diff --git a/samples/wasm/MODULE.bazel b/samples/wasm/MODULE.bazel new file mode 100644 index 0000000000..8dc8f51aca --- /dev/null +++ b/samples/wasm/MODULE.bazel @@ -0,0 +1,59 @@ +module( + name = "com_google_j2cl_samples_wasm", +) + +bazel_dep( + name = "com_google_j2cl", + version = "v20250115", +) + +local_path_override( + module_name = "com_google_j2cl", + path = "../..", +) + +bazel_dep( + name = "io_bazel_rules_closure", +) + +# io_bazel_rules_closure is not available in BCR. +git_override( + module_name = "io_bazel_rules_closure", + commit = "a8f1d2d110b565f0cf47ed86a29ff1e94a826ab4", + remote = "https://github.com/bazelbuild/rules_closure", +) + +# rules_webtesting is not available in BCR +git_override( + module_name = "rules_webtesting", + commit = "46b744fa916b5cefce6f0f84252f4ec89128a01b", + remote = "https://github.com/bazelbuild/rules_webtesting", +) + +# rules_scala is not available in BCR, needed for rules_webtesting.. +git_override( + module_name = "rules_scala", + commit = "031fb0d3a63467d87f25397eb8e23faa57d1d3a6", + remote = "https://github.com/mbland/rules_scala", +) + +# google_bazel_common is not available in BCR. +git_override( + module_name = "google_bazel_common", + commit = "34102e4cf748e2922697f28f629ecea687345254", + remote = "https://github.com/google/bazel-common", +) + +# Works around https://github.com/bazelbuild/rules_python/issues/1169 +bazel_dep( + name = "rules_python", + version = "0.23.1", +) + +python = use_extension("@rules_python//python/extensions:python.bzl", "python") + +python.toolchain( + configure_coverage_tool = False, + ignore_root_user_error = True, + python_version = "3.11", +) diff --git a/samples/wasm/WORKSPACE b/samples/wasm/WORKSPACE deleted file mode 100644 index db9ceff12b..0000000000 --- a/samples/wasm/WORKSPACE +++ /dev/null @@ -1,20 +0,0 @@ -workspace(name = "com_google_j2cl_samples_helloworld") - -# Load j2cl repository -# If you are not developing with J2CL, you may want to use a remote repository -# instead. -local_repository( - name = "com_google_j2cl", - path = "../..", -) - -load("@com_google_j2cl//build_defs:repository.bzl", "load_j2cl_repo_deps") -load_j2cl_repo_deps() - -load("@com_google_j2cl//build_defs:workspace.bzl", "setup_j2cl_workspace") -setup_j2cl_workspace() - -load("@io_bazel_rules_closure//closure:defs.bzl", "setup_web_test_repositories") -setup_web_test_repositories( - chromium = True, -) diff --git a/third_party/BUILD b/third_party/BUILD index a947666383..2473018995 100644 --- a/third_party/BUILD +++ b/third_party/BUILD @@ -10,17 +10,17 @@ package( alias( name = "asm", - actual = "@org_ow2_asm_asm", + actual = "@google_bazel_common//third_party/java/asm", ) alias( name = "guava", - actual = "@com_google_guava", + actual = "@google_bazel_common//third_party/java/guava", ) alias( name = "jsr305_annotations", - actual = "@com_google_code_findbugs_jsr305", + actual = "@google_bazel_common//third_party/java/jsr305_annotations", ) j2cl_import( @@ -30,7 +30,7 @@ j2cl_import( alias( name = "j2objc_annotations", - actual = "@com_google_j2objc_annotations", + actual = "@maven//:com_google_j2objc_j2objc_annotations", ) j2cl_import( @@ -40,7 +40,7 @@ j2cl_import( alias( name = "jspecify_annotations", - actual = "@org_jspecify", + actual = "@google_bazel_common//third_party/java/jspecify_annotations", ) j2cl_import( @@ -55,7 +55,7 @@ alias( alias( name = "args4j", - actual = "@args4j", + actual = "@maven//:args4j_args4j", ) java_library( @@ -76,7 +76,7 @@ java_library( alias( name = "javac", - actual = "@com_sun_tools_javac//jar", + actual = "@maven//:com_google_errorprone_javac", ) alias( @@ -86,7 +86,7 @@ alias( alias( name = "auto_value", - actual = "@com_google_auto_value", + actual = "@google_bazel_common//third_party/java/auto:value", ) j2cl_import( @@ -94,49 +94,37 @@ j2cl_import( jar = ":auto_value", ) -java_library( +alias( name = "auto_service", - exported_plugins = [":auto_service_plugin"], - exports = ["@com_google_auto_service_annotations//jar"], -) - -java_plugin( - name = "auto_service_plugin", - processor_class = "com.google.auto.service.processor.AutoServiceProcessor", - deps = [ - ":auto_common", - ":guava", - "@com_google_auto_service//jar", - "@com_google_auto_service_annotations//jar", - ], + actual = "@google_bazel_common//third_party/java/auto:service", ) alias( name = "auto_common", - actual = "@com_google_auto_common//jar", + actual = "@google_bazel_common//third_party/java/auto:common", ) alias( name = "error_prone_annotations", - actual = "@com_google_errorprone_error_prone_annotations", + actual = "@google_bazel_common//third_party/java/error_prone:annotations", ) alias( name = "gson", - actual = "@com_google_code_gson", + actual = "@maven//:com_google_code_gson_gson", ) java_library( name = "escapevelocity", exports = [ - "@com_google_escapevelocity//jar", + "@maven//:com_google_escapevelocity_escapevelocity", ], ) java_library( name = "junit", testonly = 1, - exports = ["@org_junit//jar"], + exports = ["@google_bazel_common//third_party/java/junit"], ) j2cl_library( @@ -148,19 +136,19 @@ j2cl_library( java_library( name = "mockito", testonly = 1, - exports = ["@org_mockito//jar"], + exports = ["@google_bazel_common//third_party/java/mockito"], ) java_library( name = "truth", testonly = 1, - exports = ["@com_google_truth//jar"], + exports = ["@google_bazel_common//third_party/java/truth"], ) java_library( name = "compile_testing", testonly = 1, - exports = ["@com_google_testing_compile//jar"], + exports = ["@maven//:com_google_testing_compile_compile_testing"], ) alias(