google / elemental2

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

Can't bazel build //... #70

Closed solomatov closed 5 years ago

solomatov commented 6 years ago
Starting local Bazel server and connecting to it...
INFO: SHA256 (https://github.com/google/jsinterop-generator/archive/master.zip) = 8a12f0247e51630e57f4e69849d739f4f60f0c2664f7d5ffc61be220d75b4ba8
INFO: SHA256 (https://github.com/google/jsinterop-base/archive/master.zip) = 1b3e51c7d0cecbda5ade78feeff93791639d7fa48922a7ca63220654c69c0ee4
ERROR: /Users/kostik/Projects/elemental2/third_party/BUILD:228:1: error loading package '@com_google_jsinterop_base//java/jsinterop/base': Extension file not found. Unable to load package for '@com_google_j2cl//build_defs:rules.bzl': The repository could not be resolved and referenced by '//third_party:jsinterop-base'
ERROR: Analysis of target '//third_party:jsinterop-base' failed; build aborted: error loading package '@com_google_jsinterop_base//java/jsinterop/base': Extension file not found. Unable to load package for '@com_google_j2cl//build_defs:rules.bzl': The repository could not be resolved
INFO: Elapsed time: 11.512s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (35 packages loaded)
    currently loading: @com_google_jsinterop_base//java/jsinterop/base

I wanted to import it to my project. I saw there're errors, and decided to check whether it compiles. It obvious don't. Could you help with fixing it?

jDramaix commented 6 years ago

We need some change for allowing that. I've already make jsinterop-generator (used for generating the java classes) ready for bazel and j2cl: https://github.com/google/jsinterop-generator/commit/26d5af76f211323fbe81bcc68213ad3254581f9f

I need now to make some change in this repo for using that change

niloc132 commented 6 years ago

I'm also seeing this issue, but I'm able to fix it by changing jsinterop-generator locally to provide details on how to get args4j, and by changing this repo to load j2cl. As I'm on a mac, I also had to apply https://github.com/google/jsinterop-base/pull/8 (and then of course change the http_archive etc rules to local_archive.

Edit: Oh sorry @jDramaix you're looking into this now to finish making the changes now required from the jsinterop-generator changes. Thanks!

solomatov commented 6 years ago

@niloc132 I want to note that I use two computers, one is a mac and the other is a linux one, and different issues and outputs are send from different computers.

jDramaix commented 6 years ago

If you can wait few days, I should have time to fix everything. The WORKSPACE file need some love since j2cl is opensource

solomatov commented 6 years ago

@jDramaix Thank you!

@jDramaix @niloc132 Concerning nested workspaces, do I understand correctly that they aren't well supported by bazel? What's the right way to work with them? Just create a script and load all sub-workspaces from the root WORKSPACE file?

niloc132 commented 6 years ago

I wouldn't say they are not well supported, but they don't nest nicely (i.e. one WORKSPACE per git repo?), and if you modify your own WORKSPACE to point at a local copy of some project "foo" instead of a remote one, you need to iterate over your other dependencies and also download and modify any of them which also point to that same "foo". For this reason, it makes a lot more sense to just either have one big project, or maybe some kind of easy switch to toggle between local/development or remote/stable (I've seen lots of projects that move their deps into a bzl file instead of WORKSPACE, and generally assume that this is why that is done, so you can share those, like maven poms? https://docs.bazel.build/versions/master/external.html#transitive-dependencies and the rest of the file discuss this a bit, but I haven't found any "best practices" docs that really dig in to this topic).

gkdn commented 6 years ago

Bazel calls the concept as recursive workspaces and they are working on proper support for it.

The design doc [1] discusses the current common practice under section called "The dependencies() pattern".

[1] they have https://github.com/bazelbuild/proposals/blob/master/designs/2018-11-07-design-recursive-workspaces.md

jDramaix commented 5 years ago

bazel build ... now works (except if we have a temporary sync issue with extern file)