Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nullaway does not work with bazel #737

Closed
purvi-scio opened this issue Feb 22, 2023 · 5 comments
Closed

Nullaway does not work with bazel #737

purvi-scio opened this issue Feb 22, 2023 · 5 comments

Comments

@purvi-scio
Copy link

purvi-scio commented Feb 22, 2023

Looks like the documentation is not updated to install and run nullaway with bazel given that there are changes around defining artifact in maven_jar in workspace, which now requires more details. (Read below for complete detail)

Details:

  1. To run the nullaway, we need to define it in build.bazel rules and workspace rules.
  2. In the Nullaway documentation, it is mentioned to use maven_jar for bazel which required name and artifact fields, but this github issue indicates maven_jar is deprecated and is replaced with jvm_maven_import_external for which there is nothing mentioned in nullaway documentation.
  3. jvm_maven_import_external has server_urls as a mandatory field and a artifact_sha256 field.

Tried this:

  1. searched for the nullaway jar file, got it from maven search,
  2. generated the sha 256 locally and used this value in artifact_sha256 and gave server url as the maven search one.
  3. added @nullable to the java test file
  4. ran the bazel run and hitting this error now
❯ bazel build //java/com/askscio/core/auth/processors/v2:AuthContextProviderTest                                                                                                                                                                                                                                                                                        
INFO: Analyzed target //java/com/askscio/core/auth/processors/v2:AuthContextProviderTest (168 packages loaded, 76709 targets configured).
INFO: Found 1 target...
ERROR: /private/var/tmp/_bazel.../external/nullaway/BUILD:9:12: Extracting interface @nullaway//:nullaway failed: (Aborted): ijar failed: error executing command external/remote_java_tools_darwin/java_tools/ijar/ijar external/nullaway/nullaway-0.3.4.jar bazel-out/darwin_arm64-fastbuild/bin/external/nullaway/_ijar/nullaway/nullaway-0.3.4-ijar.jar --target_label ... (remaining 1 argument skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
file is invalid or corrupted (missing end of central directory record)
Opening zip "external/nullaway/nullaway-0.3.4.jar": Cannot find central directory
Unable to open Zip file external/nullaway/nullaway-0.3.4.jar: Input/output error

Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 3.372s, Critical Path: 0.07s
INFO: 2 processes: 2 internal.
FAILED: Build did NOT complete successfully
@msridhar
Copy link
Collaborator

Hi @purvi-scio did you get this working? The general principles outlined in the README should still hold (get Error Prone installed, and then put NullAway on the annotation processor path). None of the maintainers is actively using Bazel right now but if you get this working we would welcome a PR to fix the docs.

@purvi-scio
Copy link
Author

purvi-scio commented Feb 23, 2023

Hi! I was looking into it and currently stuck at
@nullaway//:nullaway failed: (Aborted): ijar failed: error executing command external/remote_java_tools_darwin/java_tools/ijar/ijar external/nullaway/nullaway-0.3.4.jar bazel-out/darwin_arm64-fastbuild/bin/external/nullaway/_ijar/nullaway/nullaway-0.3.4-ijar.jar --target_label

@ghost
Copy link

ghost commented Feb 27, 2023

this worked, there was some deps issue which was causing error

@ghost
Copy link

ghost commented Feb 27, 2023

Btw, does nullaway generate a reportFile or parsable output? Not sure if this is already implemented here. Saw this as an open request even for Google error prone/#444

@msridhar
Copy link
Collaborator

this worked, there was some deps issue which was causing error

If our documentation is out of date, any chance you could submit a PR to fix it?

Btw, does nullaway generate a reportFile or parsable output? Not sure if this is already implemented here. Saw this as an open request even for Google error prone/#444

Nothing officially documented yet, but we're hoping to piggy-back on Error Prone support, see also google/error-prone#3766.

I'm going to go ahead and close this use for now, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants