rules_jvm_external
rules_jvm_external copied to clipboard
Build issue when building using m2Local support + pinning
Error is observed when building an (android) project using local artifact (via 'm2Local' reprository) and pinning.
Repro:
- Unzip androidx.zip into
~/.m2/repository
folder. - Clone https://github.com/oliviernotteghem/rules_jvm_external which contains this commit
-
cd examples/android_kotlin_app
-
rm -rf <path to repo cache, ex : /private/var/tmp/_bazel_oliviern/cache/repos/v1>; bazel clean --expunge; bazel build app
Result:
ERROR: /private/var/tmp/_bazel_oliviern/d757db415344097304197092f16ed4d8/external/maven/BUILD:9:11: Stamping the manifest of @maven//:androidx_annotation_annotation failed: missing input file '@maven//:androidx/annotation/annotation/1.5.0-LOCAL/annotation-1.5.0-LOCAL.jar'
Note: When building without pinning, builds succeeds.
It looks like the issue is due to the symlink from the absolute path of the artifact to the relative path within the output_base/external for local artifact gets wipeout at the beginning of build when pinning is used (i.e maven_install_json attribute is specified)
Possible fix :
def extract_netrc_from_auth_url(url):
"""Return a dict showing the netrc machine, login, and password extracted from a url.
@@ -1005,7 +1005,7 @@ def _coursier_fetch_impl(repository_ctx):
# b) Otherwise, we clear the url and also simlink the file from the maven local directory
# to file within the repository rule workspace
print("Assuming maven local for artifact: %s" % artifact["coord"])
- artifact.update({"url": None})
+ artifact.update({"url": "file://" + artifact["file"]})
if not repository_ctx.attr.name.startswith("unpinned_"):
artifact.update({"file": _relativize_and_symlink_file_in_maven_local(repository_ctx, artifact["file"])})
artifact.update({"url": "file://" + artifact["file"]})
Tried applying this fix, but it did not work. Works with the version from the PR #961.