Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support bzlmod #153

Closed
plaird opened this issue Jun 17, 2022 · 19 comments
Closed

Support bzlmod #153

plaird opened this issue Jun 17, 2022 · 19 comments

Comments

@plaird
Copy link
Contributor

plaird commented Jun 17, 2022

Starting with Bazel 5, bzlmod has been provided such that rules can surface their external dependencies. We need to support that.

https://bazel.build/docs/bzlmod

@cdickson-sum
Copy link

@plaird is this on the roadmap anytime soon?

@plaird
Copy link
Contributor Author

plaird commented May 5, 2023

@cdickson-sum I hope to get to this within a couple of months. Are you implementing bzlmod right now?

@plaird
Copy link
Contributor Author

plaird commented Nov 5, 2023

I think we have been done with this for about a year when I added the MODULE.bazel file. rules_spring doesn't have any real dependencies. The ones in the workspace are for the examples. The exception is system python3, which is used in couple of optional features (dupe classes, javax detection). I am going to ignore that.

I will do the following:

  • separate the examples into their own WORKSPACE to make it clear those deps aren't needed. will use Bazel 6.x as a demo of bazelmod too
  • add rules_spring to the central registry

@plaird plaird added the 2.4.0 label Nov 5, 2023
@plaird plaird self-assigned this Nov 5, 2023
@luangong
Copy link

luangong commented Jan 15, 2024

Hi Peter. Are there any updates? Almost all other rules have adopted bzlmod except rules_spring. Also bzlmod is enabled by default in Bazel 7. It would be great if we can compile, test, and run Spring Boot applications with Bazel and bzlmod. Thank you!

@plaird
Copy link
Contributor Author

plaird commented Jan 18, 2024

We have a large monorepo with hundreds of springboot instances, so it is taking time for us to migrate. But we are getting closer to making the switch.

What feature of rules_spring is failing for you? The dupe class and javax checkers require python, which is not listed in the module file.

@Vertexwahn
Copy link
Contributor

Does it make sense to add rules_spring (2.3.1 Jan 2024 Support for Spring Boot 3.2.0) to the Bazel Central Registry? Or is there something why it should not be added?

@luangong
Copy link

luangong commented Jan 30, 2024

Since rules_spring is already using bzlmod but not yet published to BCR, I made it work by using git_override() in MODULE.bazel:

bazel_dep(name = "rules_spring")

git_override(
    module_name = "rules_spring",
    remote = "https://github.com/salesforce/rules_spring",
    commit = "1854fbca3c9d6e704dffaeb6f2f70b0476882acb", # v2.3.1
)

What feature of rules_spring is failing for you? The dupe class and javax checkers require python, which is not listed in the module file.

If someone wants to use the dupe class and javax checkers, he/she may need to add the patches attribute to git_override() to patch MOUDLE.bazel and reference the Python toolchain, or wait for the team to fix MODULE.bazel.

@Vertexwahn
Copy link
Contributor

Created a PR to add rules_spring 2.3.2 to Bzlmod: bazelbuild/bazel-central-registry#1854

@jduan-highnote
Copy link

@Vertexwahn are you going to try to add rules_spring to BCR again? Thanks!

@plaird
Copy link
Contributor Author

plaird commented Dec 8, 2024

Here we go again: bazelbuild/bazel-central-registry#3352

@plaird
Copy link
Contributor Author

plaird commented Dec 9, 2024

Aside from the BCR entry, this repo is now fully migrated to Bzlmod as of 2.5.0.

https://github.com/salesforce/rules_spring/releases/tag/2.5.0

@jduan-highnote
Copy link

Fantastic. Thank you for opening that PR!

@Vertexwahn
Copy link
Contributor

@jduan-highnote Sorry for the late reply - was unsure what to do about the python dependency issue

As far as I understand it the following code forces everyone to use Python 3.11 - what if you need a newer or an older version?

# For Dupe Class checking support
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
    # This takes priority over captive python from //tools/python_interpreter unless extra toolchains are specified e.g.
    # bazel run --extra_toolchains //tools/python_interpreter:captive_python_toolchain <target>
    is_default = True,
    python_version = "3.11",
)

Maybe a BCR entry can live without pining in to a certain version - would make it more generic

@jduan-highnote
Copy link

I'm not well versed in BCR. You've got a good point about python though. Python 3.9 won't reach end of life until late 2025.

@plaird
Copy link
Contributor Author

plaird commented Dec 9, 2024

I seem to recall that 3.11 came from boilerplate seen elsewhere. I can test without it.

BTW the snippet above is already aged. The current version in main now looks like:

# Python for dupe class checking support
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
python.toolchain(
    python_version = "3.11",
    ignore_root_user_error = True, # https://github.com/bazelbuild/rules_python/issues/1169
)

@plaird
Copy link
Contributor Author

plaird commented Dec 9, 2024

Remaining work:

  • Test without specific python version pin
  • Get 2.5.x add to BCR.
  • Figure out why the BCR tool has a MODULE.bazel diff, I don't want a diff I just want it to use the MODULE.bazel as-is.
  • Not specific to this work item, but I really need to duplicate //examples/demoapp into a dedicated git repo so that I can quickly verify new rules_spring releases. It is a chore to verify with our internal monorepo (100's of rules_spring invocations), and problems found there are not possible to link in Issues.

@plaird plaird added the 2.5.1 label Dec 10, 2024
@plaird
Copy link
Contributor Author

plaird commented Dec 22, 2024

I have submitted rules_spring 2.6.0 to BCR:
bazelbuild/bazel-central-registry#3476

@plaird
Copy link
Contributor Author

plaird commented Jan 3, 2025

rules_spring is now in BCR.

Thanks everyone for your patience in this!

@jduan-highnote
Copy link

Thank you for doing the hard work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants