rules_jvm_external icon indicating copy to clipboard operation
rules_jvm_external copied to clipboard

neverlink errors for AARs

Open cpsauer opened this issue 3 years ago • 2 comments

First and foremost, thanks for such a useful set of rules!

I was using this for an Android project and noticed an edge case that I thought I should give a heads up about: Neverlink doesn't seem to work Maven AARs.

As a minimal example, I've got:

maven_install(
    artifacts = [
        maven.artifact("com.facebook.fbjni", "fbjni", "0.2.0", neverlink = True),
    ],
    repositories = [
        "https://jcenter.bintray.com/",
    ],
)

And the error is @maven//:com_facebook_fbjni_fbjni: no such attribute 'neverlink' in 'aar_import' rule. Indeed checking the generated BUILD file, you see neverlink added to the aar_import rule.

A good workaround might be to wrap the aar_import rule in an android_library, which supports neverlink. Alternatively, and probably better, neverlink support could be added to aar_import?

Tagging @jin, because it looks like he was the original author.

cpsauer avatar Mar 13 '21 00:03 cpsauer

I checked with @ahumesky and there isn't nothing particularly blocking to implement neverlink in aar_import. Feel free to open an issue in the core bazel repository!

In the mean time, I'm open to accepting a PR (with tests) that goes with the first approach, since that wouldn't require a Bazel release.

jin avatar Mar 16 '21 03:03 jin

Sounds good. Will do on the issue.

[May come back on the PR, but it turns out that neverlink itself is broken in ways that make it unusable. See https://github.com/bazelbuild/bazel/issues/13216]

cpsauer avatar Mar 16 '21 04:03 cpsauer