Search code examples
bazel

I am migrating a project from maven to bazel and getting error


i am following the official bazel documentation for migrating from maven to bazel and used rules_jvm_external to defined external dependencies in workspace file and Build file. But I am getting the follwing error.

C:/users/kunal_visoulia/_bazel_kunal_visoulia/3f5dzdsz/external/maven/BUILD:1212:1: in deps attribute of jvm_import rule @maven//:commons_digester_commons_digester: rule '@maven//:xml_apis_xml_apis' does not exist
ERROR: Analysis of target '//:everything' failed; build aborted: Analysis of target '@maven//:commons_digester_commons_digester' failed; build aborted
INFO: Elapsed time: 724.364s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (4 packages loaded, 371 targets configured)
    Fetching @remotejdk11_win; Restarting.

i am using private nexus repo and also the official maven repo. Please help


Solution

  • I've successfully reproduced your error and found the following workaround:

    1. Add xml-apis:xml-apis:1.4.01 and junit:junit-dep:4.9 to your list of artifacts.
    2. Add the version_conflict_policy = "pinned" attribute to maven_install.

    The root cause is https://github.com/bazelbuild/rules_jvm_external/issues/250. The missing dependencies are artifacts that relocated to new GAV coordinates, which the coursier resolver cannot handle yet. The general workaround is to manually add the legacy GAV coordinates into maven_install.

    Specifically, xml-apis:xml-apis:2.0.2 relocated to xml-apis:xml-apis:1.0.b2 (but 1.4.0.1 wasn't relocated), and junit:junit-dep:4.9 relocated to junit:junit.