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

JavaInfo value has no field or method 'transitive_exports' when upgrading to Bazel 5.x+ #676

Open
ivanempire opened this issue Apr 1, 2022 · 1 comment

Comments

@ivanempire
Copy link

Hi-Diddly-Ho, rules_jvm_external developers!
We're seeing a build failure with Bazel version 5+ with a missing field in JavaInfo. Everything works fine with Bazel 4.2.1, the pinned version in this repo, but the upgrade causes the build to fail.

Information

Running our build on the older version of Bazel works as expected:
bazel run --define "maven_repo=file://$HOME/.m2/repository" //java/main/java/org/odict:odict.publish, and everything gets published, however, when upgrading we get:

ERROR: /Users/imelnikov/Documents/dev/odict/java/main/java/org/odict/BUILD.bazel:4:12: in maven_project_jar rule //java/main/java/org/odict:odict-project: 
Traceback (most recent call last):
	File "/private/var/tmp/_bazel_imelnikov/d792e4c95a32b3f00d6ffc5d5ab946f1/external/rules_jvm_external/private/rules/maven_project_jar.bzl", line 52, column 36, in _maven_project_jar_impl
		targets = [] + target[JavaInfo].transitive_exports.to_list()
Error: 'JavaInfo' value has no field or method 'transitive_exports'
Available attributes: annotation_processing, api_generating_plugins, compilation_info, compile_jars, full_compile_jars, java_outputs, outputs, plugins, runtime_output_jars, source_jars, transitive_compile_time_jars, transitive_deps, transitive_native_libraries, transitive_runtime_deps, transitive_runtime_jars, transitive_source_jars
ERROR: /Users/imelnikov/Documents/dev/odict/java/main/java/org/odict/BUILD.bazel:4:12: Analysis of target '//java/main/java/org/odict:odict-project' failed
ERROR: Analysis of target '//java/main/java/org/odict:odict.publish' failed; build aborted:

This happens because, from what we can tell, that field no longer exists in the latest versions of Bazel:
https://docs.bazel.build/versions/4.2.0/skylark/lib/JavaInfo.html#transitive_exports
https://docs.bazel.build/versions/5.1.0/skylark/lib/JavaInfo.html#transitive_exports <-- he's dead, Jim

I'd be happy to take a look at this and see if this can be fixed, couldn't find anything useful in Bazel's release notes. Thanks!

Our macro, for helpful reference:

java_export(
    name = "odict",
    maven_coordinates = "{}:{}:{}.{}.{}".format(maven["group"], maven["artifact"], version["major"], version["minor"], version["patch"]),
    resources = ["//java/main/cpp:libodict.so"],
    visibility = ["//java:__pkg__"],
    srcs = glob(["**/*.java"]),
    deps = [
        "//schema/java",
        "@native_utils",
        "@odict_java_deps//:com_fasterxml_jackson_core_jackson_annotations",
        "@odict_java_deps//:com_fasterxml_jackson_core_jackson_core",
        "@odict_java_deps//:com_fasterxml_jackson_core_jackson_databind",
        "@odict_java_deps//:org_xerial_snappy_snappy_java",
    ],
)
@ivanempire ivanempire changed the title JavaInfo value has no field or method 'transitive_exports' when upgrading to Blaze 5.x+ JavaInfo value has no field or method 'transitive_exports' when upgrading to Bazel 5.x+ Apr 11, 2022
@jin
Copy link
Member

jin commented May 26, 2022

Which version of RJE are you using? This was fixed in #557

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