The PMD (a static analysis tool) integration for the Bazel build system.
bazel_dep(name = "rules_pmd", version = "...")
Declare the rule in the WORKSPACE
file.
Please refer to GitHub releases for the version and the SHA-256 hashsum.
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
rules_pmd_version = "REPLACE_ME"
rules_pmd_sha = "REPLACE_ME"
http_archive(
name = "rules_pmd",
sha256 = rules_pmd_sha,
strip_prefix = "bazel_rules_pmd-{v}".format(v = rules_pmd_version),
url = "https://github.com/buildfoundation/bazel_rules_pmd/archive/v{v}.tar.gz".format(v = rules_pmd_version),
)
load("@rules_pmd//pmd:dependencies.bzl", "rules_pmd_dependencies")
rules_pmd_dependencies()
load("@rules_pmd//pmd:toolchains.bzl", "rules_pmd_toolchains")
rules_pmd_toolchains()
Once declared in the WORSKPACE
file, the rule can be loaded in the BUILD
file.
load("@rules_pmd//pmd:defs.bzl", "pmd_test")
pmd_test(
name = "pmd_analysis_test",
srcs = glob(["src/main/java/**/*.java"]),
)
Change the MODULE.bazel
file:
pmd = use_extension("//pmd:extensions.bzl", "pmd")
pmd.pmd_version(
version = "x.x.x",
sha256 = "x.x.x.sha256",
)
use_repo(pmd, "net_sourceforge_pmd")
Or change the WORKSPACE
file:
load("@rules_pmd//pmd:versions.bzl", "pmd_version")
load("@rules_pmd//pmd:dependencies.bzl", "rules_pmd_dependencies")
rules_pmd_dependencies(
pmd_version = pmd_version(
version = "x.x.x",
sha256 = "x.x.x.sha256",
)
)
See available attributes.
$ bazel build //YOUR_PACKAGE:pmd_analysis