bazelbuild / rules_groovy

Groovy rules for Bazel
Apache License 2.0
11 stars 28 forks source link

Ability to change dependency coordinates for Groovy SDK, JUnit and Spock #39

Open bmuschko opened 5 years ago

bmuschko commented 5 years ago

Right now the versions for the Groovy SDK, JUnit and Spock libraries are hardcoded. Is there a way to change the coordinates or just the versions for these dependencies from a user's BUILD file? An example would be helpful if that's already possible.

ekuefler commented 5 years ago

If you want to use a custom version, you can skip calling groovy_repositories() from your WORKSPACE file and instead use bind to set up bindings for the four targets it depends on (listed at https://github.com/bazelbuild/rules_groovy#setup).

I know bind is deprecated, and as this was set up several years ago I suspect there are better patterns for doing this now. Do you know of any better approaches for doing this?

nickbreen commented 3 years ago

The issue I had was that the dependencies are referenced as //external:*. If they were referenced as //:* then the build_file or build_file_content attributes of http_archive could be used to trivially add them in.

nickbreen commented 3 years ago

I used this page as a reference to patch the groovy/groovy.bzl file to refer to my own packages.

  1. clone this repo
  2. use ‑‑override_repository=rules_groovy=<path to checkout> to point my project at this checkout
  3. edited groovy/groovy.bzl until bazel build <target> worked
  4. generated a patch filegit diff > rules_groovy.patch
  5. configured the patch as per http_archive.patches