bazelbuild / BUILD_file_generator

Generate BUILD files for your Java files
Apache License 2.0
39 stars 19 forks source link

Bazel deps helper scripts #19

Closed greggdonovan closed 6 years ago

greggdonovan commented 6 years ago

Add scripts to auto-generate the thirdparty/jvm BUILD files from the maven_deps.yaml.

These scripts handle:

The PR also runs these scripts to regenerate the thirdparty/jvm files that have been buildifier formatted.

This allows us to more easily add new dependencies to maven_deps.yaml. For example, for Scala support.

bazel-io commented 6 years ago

Can one of the admins verify this patch?

petroseskinder commented 6 years ago

@greggdonovan can you add a line checking if buildifier is installed (and installing it otherwise)? I ran into this issue when running generate.sh on a machine without buildifier.

greggdonovan commented 6 years ago

@petroseskinder Good idea, thanks. I should do the same with buildozer, as well, I think.

I'll update the PR.

cgrushko commented 6 years ago

ok to test

greggdonovan commented 6 years ago

Re: The buildozer and buildifier dependencies. How should we be having folks install them? For OSX there is a homebrew package for buildifier. We can add one for buildozer. I'm not sure if we hope to have these tools in standard yum/deb repos for linux.

Are we better off exiting with the proper instructions for installing them or better off doing something like: command -v buildozer >/dev/null 2>&1 || { echo >&2 "buildozer is missing; installing via go get."; go get github.com/bazelbuild/buildtools/buildozer; } ?

The devtools script handles this via having buildifier as a submodule and building from source if missing, but maybe that's not the right approach for an end-user oriented tool?

cgrushko commented 6 years ago

I filed https://github.com/bazelbuild/bazel/issues/3895 after chatting with @damienmg . There's a tentative agreement, but I'm told it's low priority.

BFG uses Buildozer to create the BUILD files, so it's actually a prerequisite. I'll update README.md with instructions.

So, I think it's ok to exit with instructions (pointing at README.md should be fine)

cgrushko commented 6 years ago

Feel free to merge (you should have Write permissions).

cgrushko commented 6 years ago

Ah, I ran into some trouble with setup.sh - I tried using it in another repo, and it clashes with BFG. Might be worth to change BAZEL_DEPS_DIR to point inside the repo (i.e. BAZEL_DEPS_DIR="$ROOT_DIR/bazel-deps")

greggdonovan commented 6 years ago

@cgrushko That's a good point -- I'll update in a PR. I can also add in removals of the workaround to bazel-deps#73 and bazel-deps#85.

I should be back to the meat of the Scala work this week, too. Sorry -- had to finish up some other work.

kevingessner commented 6 years ago

I'm hoping to work on https://github.com/bazelbuild/bazel/issues/1673 this week, which should make setup.sh unnecessary. I'll let you know if I can make progress!

greggdonovan commented 6 years ago

@cgrushko Cloning bazel-deps inside of the BFG repo means that its rules get run on bazel test //... and there doesn't appear to be a good solution for excluding them.

How about BAZEL_DEPS_DIR="$ROOT_DIR/../BUILD_file_generator-bazel-deps" for now to avoid conflicts until @kevingessner solves this for real with bazelbuild/bazel#1673?