google / elemental2

Type checked access to browser APIs for Java code.
Apache License 2.0
150 stars 38 forks source link

Can't create a bazel project which uses elemental2 with j2cl #68

Closed solomatov closed 5 years ago

solomatov commented 6 years ago

Here's the repo: https://github.com/solomatov/j2cl-sandbox

When I run it, I got the following error:

konstantins-mbp:j2cl-sandbox kostik$ bazel build //...
INFO: Build options have changed, discarding analysis cache.
ERROR: /Users/kostik/Projects/j2cl-sandbox/src/sandbox/BUILD.bazel:10:1: error loading package '@com_google_elemental2//java/elemental2/core': Extension file not found. Unable to load package for '@com_google_jsinterop_generator//:jsinterop_generator.bzl': The repository could not be resolved and referenced by '//src/sandbox:main'
ERROR: Analysis of target '//src/sandbox:main' failed; build aborted: error loading package '@com_google_elemental2//java/elemental2/core': Extension file not found. Unable to load package for '@com_google_jsinterop_generator//:jsinterop_generator.bzl': The repository could not be resolved
INFO: Elapsed time: 0.200s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (6 packages loaded)
    currently loading: @bazel_tools//tools/jdk ... (3 packages)
solomatov commented 6 years ago

It seems that the problem is related to the fact that I didn't copy pasted everything from Elemental's workspace into mine. Is there a way to work this around?

solomatov commented 6 years ago

It seems that the problem is lack of support for hierarchical workspaces in bazel: https://github.com/bazelbuild/bazel/issues/1943

jDramaix commented 5 years ago

It's now working. we need add that in your WORKSPACE:

load("//build_defs:repository.bzl", "load_elemental2_repo_deps")
load_elemental2_repo_deps()
load("//build_defs:workspace.bzl", "setup_elemental2_workspace")
setup_elemental2_workspace()

The only problem is if you use bazelbuild/rules_closure. Those rules embed their own version of extern files that are not necessarily synced with version used by elemental.

jDramaix commented 5 years ago

Please follow the instructions in the README: https://github.com/google/elemental2#bazel-dependencies