Skip to content

Starlarkify java_import rule #15196

@comius

Description

@comius

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)

Metadata

Metadata

Assignees

Labels

P2We'll consider working on this in future. (Assignee optional)team-Rules-JavaIssues for Java rulestype: feature request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions