Skip to content

Commit

Permalink
bazel: fix for non bzlmod
Browse files Browse the repository at this point in the history
Now the repository should work in non bzlmod setup
  • Loading branch information
manuelnaranjo committed Mar 12, 2024
1 parent 9bd3fdc commit 0413c53
Show file tree
Hide file tree
Showing 5 changed files with 105 additions and 58 deletions.
37 changes: 0 additions & 37 deletions e2e/smoke/BUILD
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
"""Provides a simple way to test your rules as an external workspace.
Add a basic smoke-test target below.
"""

load("@bazel_gazelle//:def.bzl", "DEFAULT_LANGUAGES", "gazelle", "gazelle_binary")
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load("@buildifier_prebuilt//:rules.bzl", "buildifier")

# load("@com_bookingcom_rules_pitest//pitest:defs.bzl", "...")

# Replace with a usage of your rule/macro
filegroup(name = "empty")

build_test(
name = "smoke_test",
targets = [
# targets you add above
":empty",
],
)

# gazelle:prefix github.com/your/project
gazelle(
name = "gazelle",
gazelle = ":gazelle_bin",
)

gazelle_binary(
name = "gazelle_bin",
languages = DEFAULT_LANGUAGES + [
"@contrib_rules_jvm//java/gazelle",
],
)

buildifier(
name = "buildifier",
exclude_patterns = [
"./.git/*",
],
)
9 changes: 1 addition & 8 deletions e2e/smoke/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
bazel_dep(name = "com_bookingcom_rules_pitest", version = "0.0.0", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.5.0", dev_dependency = True)

bazel_dep(name = "com_bookingcom_rules_pitest", version = "0.0.0")
local_path_override(
module_name = "com_bookingcom_rules_pitest",
path = "../..",
)

bazel_dep(name = "rules_java", version = "7.4.0")
bazel_dep(name = "rules_jvm_external", version = "6.0")

bazel_dep(name = "gazelle", version = "0.35.0", dev_dependency = True, repo_name = "bazel_gazelle")
bazel_dep(name = "bazel_skylib_gazelle_plugin", version = "1.4.1", dev_dependency = True)
bazel_dep(name = "buildifier_prebuilt", version = "6.1.2", dev_dependency = True)

bazel_dep(name = "contrib_rules_jvm", version = "0.24.0")

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
Expand Down
41 changes: 37 additions & 4 deletions e2e/smoke/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,47 @@ load("@com_bookingcom_rules_pitest//pitest:repositories.bzl", "rules_pitest_depe

rules_pitest_dependencies()

# Fetches the contrib_rules_jvm dependencies.
# If you want to have a different version of some dependency,
# you should fetch it *before* calling this.
load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")

rules_java_dependencies()

rules_java_toolchains()

load("@contrib_rules_jvm//:repositories.bzl", "contrib_rules_jvm_deps")

contrib_rules_jvm_deps()

# Now ensure that the downloaded deps are properly configured
load("@contrib_rules_jvm//:setup.bzl", "contrib_rules_jvm_setup")

contrib_rules_jvm_setup()

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

rules_jvm_external_setup()

load("@com_bookingcom_rules_pitest//pitest:deps.bzl", pitest_maven_dependencies = "maven_dependencies")

pitest_maven_dependencies()

load("@rules_jvm_external//:defs.bzl", "maven_install")

maven_install(
name = "maven",
artifacts = [
"org.junit.jupiter:junit-jupiter:5.10.2",
"org.junit.jupiter:junit-jupiter-engine:5.10.2",
"org.junit.platform:junit-platform-launcher:1.10.2",
"org.junit.platform:junit-platform-reporting:1.10.2",
"junit:junit:4.13.2",
"pl.pragmatists:JUnitParams:1.1.1",
],
fetch_sources = False,
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
20 changes: 20 additions & 0 deletions pitest/deps.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
"Extra Dependencies to call when using rules_pitest from WORKSPACE"

load("@rules_jvm_external//:defs.bzl", "maven_install")

def maven_dependencies():
"Import this method and execute it from your WORKSPACE when not using bzlmod"
maven_install(
name = "maven_pitest",
artifacts = [
"org.pitest:pitest:1.15.8",
"org.pitest:pitest-entry:1.15.8",
"org.pitest:pitest-command-line:1.15.8",
"org.pitest:pitest-junit5-plugin:1.2.1",
],
fetch_sources = False,
repositories = [
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)
56 changes: 47 additions & 9 deletions pitest/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,57 @@ def http_archive(name, **kwargs):
# and released only in semver majors.
# This is all fixed by bzlmod, so we just tolerate it for now.
def rules_pitest_dependencies():
# The minimal version of bazel_skylib we require
"When using rules_pitest with no bzlmod then import and execute this method from your WORKSPACE"
if native.bazel_version >= "7.":
http_archive(
name = "rules_java",
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/7.4.0/rules_java-7.4.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/rules_java/releases/download/7.4.0/rules_java-7.4.0.tar.gz",
],
sha256 = "976ef08b49c929741f201790e59e3807c72ad81f428c8bc953cdbeff5fed15eb",
)
elif native.bazel_version >= "6.":
http_archive(
name = "rules_java",
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/6.5.2/rules_java-6.5.2.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/rules_java/releases/download/6.5.2/rules_java-6.5.2.tar.gz",
],
sha256 = "16bc94b1a3c64f2c36ceecddc9e09a643e80937076b97e934b96a8f715ed1eaa",
)
else:
fail("bazel %s not supported, minimun version 6.x" % native.bazel_version)

http_archive(
name = "bazel_skylib",
sha256 = "cd55a062e763b9349921f0f5db8c3933288dc8ba4f76dd9416aac68acee3cb94",
name = "contrib_rules_jvm",
sha256 = "2412e22bc1eb9d3a5eae15180f304140f1aad3f8184dbd99c845fafde0964559",
strip_prefix = "rules_jvm-0.24.0",
urls = [
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.5.0/bazel-skylib-1.5.0.tar.gz",
"https://github.com/bazel-contrib/rules_jvm/releases/download/v0.24.0/rules_jvm-v0.24.0.tar.gz",
"https://mirror.bazel.build/github.com/bazel-contrib/rules_jvm/releases/download/v0.24.0/rules_jvm-v0.24.0.tar.gz",
],
)

http_archive(
name = "contrib_rules_jvm",
sha256 = "2412e22bc1eb9d3a5eae15180f304140f1aad3f8184dbd99c845fafde0964559",
strip_prefix = "rules_jvm-0.24.0",
url = "https://github.com/bazel-contrib/rules_jvm/releases/download/v0.24.0/rules_jvm-v0.24.0.tar.gz",
name = "buildifier_prebuilt",
sha256 = "8ada9d88e51ebf5a1fdff37d75ed41d51f5e677cdbeafb0a22dda54747d6e07e",
strip_prefix = "buildifier-prebuilt-6.4.0",
urls = [
"http://github.com/keith/buildifier-prebuilt/archive/6.4.0.tar.gz",
"https://mirror.bazel.build/github.com/buildifier-prebuilt/archive/6.4.0.tar.gz",
],
)

RULES_JVM_EXTERNAL_TAG = "6.0"
RULES_JVM_EXTERNAL_SHA = "85fd6bad58ac76cc3a27c8e051e4255ff9ccd8c92ba879670d195622e7c0a9b7"

http_archive(
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA,
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz" % (RULES_JVM_EXTERNAL_TAG, RULES_JVM_EXTERNAL_TAG),
"https://github.com/bazelbuild/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz" % (RULES_JVM_EXTERNAL_TAG, RULES_JVM_EXTERNAL_TAG),
],
)

0 comments on commit 0413c53

Please sign in to comment.