Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Error compiling project with config_setting that supports "local" or "maven" alias to jar deps #6

Closed
psaville-google opened this issue Aug 17, 2016 · 13 comments

Comments

@psaville-google
Copy link
Contributor

I have a bazel project in which I am using an alias rule to choose "local" java_import rules or the WORKSPACE maven_jar, based on a config_setting rule. The default is to use the maven_jar rule.

I get no errors when building with bazel directly. I get the following error in e4b:

Unhandled exception thrown during build; message: Unrecoverable error while evaluating node 'ASPECT://{subfolder:alias rule}#//tools/must/be/unique:e4b_aspect.bzl%e4b_aspect ba834f18793b6e939eecba4f092f775f ba834f18793b6e939eecba4f092f775f {}' (requested by nodes 'ASPECT://external{bind rule pointing at alias}#//tools/must/be/unique:e4b_aspect.bzl%e4b_aspect ba834f18793b6e939eecba4f092f775f ba834f18793b6e939eecba4f092f775f {}')
____Elapsed time: 0.838s
java.lang.RuntimeException: Unrecoverable error while evaluating node 'ASPECT://{subfolder:alias rule}#//tools/must/be/unique:e4b_aspect.bzl%e4b_aspect ba834f18793b6e939eecba4f092f775f ba834f18793b6e939eecba4f092f775f {}' (requested by nodes 'ASPECT://external:{bind rule pointing at alias}#//tools/must/be/unique:e4b_aspect.bzl%e4b_aspect ba834f18793b6e939eecba4f092f775f ba834f18793b6e939eecba4f092f775f {}')
    at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:1070)
    at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:474)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: com.google.devtools.build.lib.rules.AliasConfiguredTarget cannot be cast to com.google.devtools.build.lib.analysis.RuleConfiguredTarget
    at com.google.devtools.build.lib.skyframe.AspectFunction.compute(AspectFunction.java:207)
    at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:1016)
    ... 4 more
java.lang.RuntimeException: Unrecoverable error while evaluating node 'ASPECT://{subfolder:alias rule}#//tools/must/be/unique:e4b_aspect.bzl%e4b_aspect ba834f18793b6e939eecba4f092f775f ba834f18793b6e939eecba4f092f775f {}' (requested by nodes 'ASPECT://external:{bind rule pointing at alias}#//tools/must/be/unique:e4b_aspect.bzl%e4b_aspect ba834f18793b6e939eecba4f092f775f ba834f18793b6e939eecba4f092f775f {}')
    at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:1070)
    at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:474)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.ClassCastException: com.google.devtools.build.lib.rules.AliasConfiguredTarget cannot be cast to com.google.devtools.build.lib.analysis.RuleConfiguredTarget
    at com.google.devtools.build.lib.skyframe.AspectFunction.compute(AspectFunction.java:207)
    at com.google.devtools.build.skyframe.ParallelEvaluator$Evaluate.run(ParallelEvaluator.java:1016)
    ... 4 more

Build and Workspace files look as follows

WORKSPACE:
  maven_jar:maven_library
  bind(library to <subfolder:alias_library>

  subfolder:
    BUILD:
      config_setting(alias_local_mode: define="localjars=true")
      java_import(local_library from a file in subfolder)
      alias(alias_library, select(alias_local_mode: local_library, default: @maven_library//jar))

  java/package_path:
    BUILD:
      java_library( deps: [//external:library])
@damienmg
Copy link
Contributor

/cc @lberki and @dslomov

Apparently there is a problem related to aspect and alias rules. I though it was fixed?

@psaville-google
Copy link
Contributor Author

Any news on this? Should I be pulling the project and trying to fix locally to make progress on this issue?

@damienmg
Copy link
Contributor

@psaville-google sorry, @dslomov is on holidays.

@damienmg
Copy link
Contributor

@psaville-google Have you tried with Bazel @Head?

@lberki
Copy link

lberki commented Aug 30, 2016

Which Bazel version are you using? I checked and this should be fixed at HEAD, probably in

bazelbuild/bazel@6c3fe26

@lberki
Copy link

lberki commented Aug 30, 2016

My workspace is as follows:

WORKSPACE:

maven_jar(
    name="maven_jar",
    artifact="com.google.guava:guava:18.0",
    sha1="cce0823396aa693798f8882e64213b1772032b09")

bind(name="library", actual="@maven_jar//jar")

java/BUILD:

config_setting(
    name = "local",
    values = {"define": "localjars=true"},
)

alias(
    name = "a",
    actual = select({
        ":local": "locallib",
        "//conditions:default": "//external:library",
    }),
)

java_library(
    name = "locallib",
    srcs = ["Local.java"],
)

java_binary(
    name = "bin",
    main_class = "a.Wtf",
    runtime_deps = [":a"],
)

Both

bazel build --nobuild //java:bin --nocheck_visibility and
bazel build --nobuild //java:bin --nocheck_visibility --define=localjars=true

Work as expected.

@lberki
Copy link

lberki commented Aug 30, 2016

@kchodorow : I'm surprised that the dependency on @maven_jar//jar requires --nocheck_visibility. Is this a known issue?

@lberki
Copy link

lberki commented Aug 30, 2016

@dmarting: I indeed forget about the e4b aspect and now I can actually repro it. Clickety-click...

@psaville-google
Copy link
Contributor Author

lberki,

Your workspace isn't quite how I set it up. I'll clarify here just for
completeness.

WORKSPACE:

maven_jar(
  name = "maven_liba",
  ...
)

bind(
  name = "liba",
  actual = "//local:liba"
)

local/BUILD:

config_setting(
  name = "local",
  ... some define to trigger localjars
)

java_library(
  name = "local_liba",
  srcs = ["local_liba.jar"],
)

alias(
  name = "liba",
  actual = select({
    ":local": ":local_liba",
    "//conditions:default": "@maven_liba//jar"
)

src/java/some-package/BUILD:

java_library(
  name = "doesnt_matter",
  srcs = glob(...),
  deps = [
    "//external:liba",
    ...
  ],
)

Thus, the some-package java can always depend on //external:liba.
We have a jenkins job that downloads an hermetic snapshot of libraries (may
come from another git repo) and builds using the additional --define flags.

The eclipse project now needs to evaluate the //external:liba dependency as
the @maven_liba//jar dependency.

Thanks for working on this - much appreciated.

@psaville-google
Copy link
Contributor Author

Sorry for pinging a closed issue.

When and how does your updatesite get updated, after change commits?

Thanks.

@damienmg
Copy link
Contributor

damienmg commented Sep 1, 2016

Manually :) but this was a problem on the Bazel side so it does not need
any change to the plugin only to Bazel (so basically recompile bazel from
master and you should have the bug fixed).

On Thu, Sep 1, 2016, 10:17 PM psaville-google notifications@github.com
wrote:

Sorry for pinging a closed issue.

When and how does your updatesite get updated, after change commits?

Thanks.


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#6 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ADjHfxzJdDUeziCcrHyyT1TNLyzKgXooks5qlzLPgaJpZM4Jm7Sa
.

@psaville-google
Copy link
Contributor Author

I pulled a local bazel repo clone and built bazel from HEAD yesterday in order to test if this is working with e4b.

Sadly, it still doesn't work.

*** Running [/usr/local/bin/bazel, --watchfs, build, --package_path, %workspace%:/Users/psaville/eclipse/java-neon/Eclipse.app/Contents/Eclipse/../../../../../.p2/pool/plugins/com.google.devtools.bazel.e4b_0.0.1.201604271316/resources, --experimental_interleave_loading_and_analysis, --strategy=Javac=worker, --noexperimental_check_output_files, --aspects=tools/must/be/unique/e4b_aspect.bzl%e4b_aspect, //java/..., //javatests/..., //example/java/..., //scripts/testing/tee:setup_tee, //production/kubernetes/..., //example/java/..., //scs/rapidsync:all] from /Users/psaville/git-gerrit/skybox3 ***
WARNING: Option 'experimental_interleave_loading_and_analysis' is deprecated.
____Loading...
ERROR: /private/var/tmp/_bazel_psaville/33cf99881007ceae82889b09c83f121b/external/maven_prodx_libprodx/jar/BUILD:2:1: in //tools/must/be/unique:e4b_aspect.bzl%e4b_aspect aspect on java_import rule @maven_prodx_libprodx//jar:jar: 
Traceback (most recent call last):
    File "/private/var/tmp/_bazel_psaville/33cf99881007ceae82889b09c83f121b/external/maven_prodx_libprodx/jar/BUILD", line 2
        //tools/must/be/unique:e4b_aspect.bzl%e4b_aspect(...)
    File "/Users/psaville/.p2/pool/plugins/com.google.devtools.bazel.e4b_0.0.1.201604271316/resources/tools/must/be/unique/e4b_aspect.bzl", line 101, in _aspect_impl
        (java_rule_ide_info, java_ide_resol...) = java_rule_ide_info(target, ctx)
Variable 'java_rule_ide_info' is referenced before assignment. The variable is defined in the global scope..
ERROR: /private/var/tmp/_bazel_psaville/33cf99881007ceae82889b09c83f121b/external/maven_prodx_flags/jar/BUILD:2:1: in //tools/must/be/unique:e4b_aspect.bzl%e4b_aspect aspect on java_import rule @maven_prodx_flags//jar:jar: 
Traceback (most recent call last):
    File "/private/var/tmp/_bazel_psaville/33cf99881007ceae82889b09c83f121b/external/maven_prodx_flags/jar/BUILD", line 2
        //tools/must/be/unique:e4b_aspect.bzl%e4b_aspect(...)
    File "/Users/psaville/.p2/pool/plugins/com.google.devtools.bazel.e4b_0.0.1.201604271316/resources/tools/must/be/unique/e4b_aspect.bzl", line 101, in _aspect_impl
        (java_rule_ide_info, java_ide_resol...) = java_rule_ide_info(target, ctx)
Variable 'java_rule_ide_info' is referenced before assignment. The variable is defined in the global scope..
ERROR: Analysis of aspect '/tools/must/be/unique/e4b_aspect.bzl%e4b_aspect of //example/java:ExampleServer' failed; build aborted.

@damienmg
Copy link
Contributor

damienmg commented Sep 8, 2016

:/ Can you open a separate bug?

luca-digrazia pushed a commit to luca-digrazia/DatasetCommitsDiffSearch that referenced this issue Sep 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants