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

Starlarkify java_import rule #15196

Closed
comius opened this issue Apr 8, 2022 · 4 comments
Closed

Starlarkify java_import rule #15196

comius opened this issue Apr 8, 2022 · 4 comments
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules type: feature request

Comments

@comius
Copy link
Contributor

comius commented Apr 8, 2022

Bazel team would like to rewrite all rules that are part of Java to Starlark. We're making good progress, but this could be even faster with contributions from the community.

java_import rule is a good "medium" difficulty rule to rewrite to Starlark by the community. Some previous experience in Starlark, previous PRs are probably needed. This is not a good starter project. Bazel team can provide support on ambiguous problems and solutions, however our time is limited and we can't help with everything.

There are other "medium" difficulty rules to rewrite: java_runtime, java_package_configuration or java_toolchain. Each of them contains something tricky - the code is shorted, but probably also not a good starter project without previously agreeing on how to solve tricky part.

Instructions:

  • rewrite to Starlark JavaImport, JavaImportBaseRule, BazelJavaImportBaseRule classes (and their dependencies)
  • use builtin bzl files, see examples of already Starlarkfied rules, follow the style of java_library.bzl implementation
  • test the rule by enabling it temporarily in exports.bzl
  • make the final PR without the rule exported (additional tests and benchmark will be done by Bazel team)
  • make the first rewrite as close to the native rule as possible (to have the tests pass)
  • ensure your place in Starlarkification hall of fame!

Details:

  • semantics.checkRule can be removed, Bazel's implementation is noop
  • JavaConfiguration.getUseIjar, JavaToolchainProvider.getIJar can be exposed to builtins only (not Starlark) - see checkPrivateAccess
  • Starlarkify ijar_action
  • Starlarkify import_deps_check_action
  • Reuse collectProguardSpecs
  • return JavaInfo created with JavaInfo constructor (it might needs extensions - be conservative)
@comius comius added P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-Java Issues for Java rules labels Apr 8, 2022
@comius
Copy link
Contributor Author

comius commented Apr 8, 2022

cc @cushon, @hvadehra

@fmeum
Copy link
Collaborator

fmeum commented May 27, 2022

I worked on this for a bit and starlarkified ijar_action and import_deps_check_action in https://github.com/fmeum/bazel/tree/starlark-java-import. For anyone interested in picking up this issue, feel free to use any bits of these commits (disclaimer: entirely untested).

@kotlaja
Copy link
Contributor

kotlaja commented Jul 5, 2022

I'm starting to work on this task. If anyone is doing it in parallel with me, please let me know so we don't do double work.

PS. Thanks @fmeum, I'll check your code.

@comius comius added P2 We'll consider working on this in future. (Assignee optional) and removed P3 We're not considering working on this, but happy to review a PR. (No assignee) labels Sep 23, 2022
@kotlaja
Copy link
Contributor

kotlaja commented Mar 28, 2023

I'm closing this issue since java_import is fully in Starlark for a few months by now. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules type: feature request
Projects
None yet
Development

No branches or pull requests

4 participants