bazel-deps icon indicating copy to clipboard operation
bazel-deps copied to clipboard

gen_maven_deps.sh issue

Open cfredhart opened this issue 5 years ago • 4 comments

The instructions in the README to build bazel_deps state:

# Build the ParseProject binary
cd $BAZEL_DEPS
bazel build //:parse

but this appears to build parseproject_deploy.jar rather than the parseproject.jar referenced in the gen_maven_deps.sh script.

building with

bazel build //src/scala/com/github/johnynek/bazel_deps:parseproject_deploy.jar

works. It seems that either docs or build should be updated to work cleanly.

cfredhart avatar Apr 04 '19 19:04 cfredhart

Happy to accept a PR.

I think users should be directed to use bazel run actually, and not bother with the deploy_jar in many cases.

But some folks want the deploy jar because they run in a repository rule. This is a style I don’t prefer, but others seem to.

johnynek avatar Apr 05 '19 05:04 johnynek

I'm not sure I understand. I tried to follow the README steps, below. Are you suggesting I use bazel run instead of some of these?

# Build the ParseProject binary
cd $BAZEL_DEPS
bazel build //:parse
# Run parseproject on the dependencies.yaml in MY_PROJ_DIR, generating the 3rdparty/ dir.
cd $MY_PROJ_DIR
$BAZEL_DEPS/gen_maven_deps.sh generate --repo-root "$MY_PROJ_DIR" --sha-file 3rdparty/workspace.bzl --deps dependencies.yaml

cfredhart avatar Apr 05 '19 05:04 cfredhart

hi @cfredhart, sorry for the confusion. I updated the README to add these steps, you're right that the steps should say bazel build //src/scala/com/github/johnynek/bazel_deps:parseproject_deploy. instead of bazel build //:parse.

The confusion comes from how you execute the parseproject binary. If you run it from a checkout of bazel-deps, you can do

cd $BAZEL-DEPS
bazel build //:parse
bazel run //:parse <...>

In this case, running bazel build will only compile the sources for the //:parse target. Running it like this will only work from within the bazel-deps project because the built Java JAR will not include any dependencies, and the bazel workspace is responsible for providing them when you do bazel run.

$ tar -tf bazel-bin/src/scala/com/github/johnynek/bazel_deps/parseproject.jar
META-INF/
META-INF/MANIFEST.MF
com/
com/github/
com/github/johnynek/
com/github/johnynek/bazel_deps/
com/github/johnynek/bazel_deps/ParseProject$.class
com/github/johnynek/bazel_deps/ParseProject.class
templates/
templates/jar_artifact_backend.bzl

If you build the deploy jar, it includes all dependencies and can be run from any context. This is necessary if you want to run the generator from outside the context of a checkout of this repo.

$ tar -tf bazel-bin/src/scala/com/github/johnynek/bazel_deps/parseproject_deploy.jar | wc -l
   24990
$ ls bazel-bin/src/scala/com/github/johnynek/bazel_deps/parseproject*.jar
-r-xr-xr-x  1 kostar  wheel   4.5K Apr  6 10:43 bazel-bin/src/scala/com/github/johnynek/bazel_deps/parseproject.jar
-r-xr-xr-x  1 kostar  wheel    35M Apr  6 10:44 bazel-bin/src/scala/com/github/johnynek/bazel_deps/parseproject_deploy.jar

When https://github.com/johnynek/bazel-deps/issues/160 is fixed there will be a self-contained manner in which you can use bazel-deps from you WORKSPACE.

kojustin avatar Apr 06 '19 17:04 kojustin

@cfredhart I think #249 is addressing this.

thundergolfer avatar Apr 09 '19 06:04 thundergolfer