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

incompatible_load_java_rules_from_bzl: load the Java rules from @rules_java #8746

Closed
iirina opened this issue Jun 28, 2019 · 20 comments
Closed
Labels
incompatible-change Incompatible/breaking change P1 I'll work on this now. (Assignee required) team-Rules-Java Issues for Java rules untriaged

Comments

@iirina
Copy link
Contributor

iirina commented Jun 28, 2019

Flag: --incompatible_load_java_rules_from_bzl
Available since: 0.28
Will be flipped in: 1.0
Tracking issue: #8741

java_library, java_binary, java_test, java_import, java_lite_proto_library, java_proto_library,
java_package_configuration, java_plugin, java_runtime, java_toolchain have to be loaded from @rules_java.

For example if you are using java_library, add the following load statement to your BUILD/bzl file.
load("@rules_java//java:defs.bzl", "java_library")

Migration

Add rules_java repositories to your WORKSPACE file and load its dependecies:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_java",
    url = "https://github.com/bazelbuild/rules_java/releases/download/0.1.1/rules_java-0.1.1.tar.gz",
    sha256 = "220b87d8cfabd22d1c6d8e3cdb4249abd4c93dcc152e0667db061fb1b957ee68",
)
load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
rules_java_dependencies()
rules_java_toolchains()

Fix all your BUILD files that use Java rules to include the load statement. Use buildifier to automatically update all your BUILD files:

buildifier --lint=fix -warnings=native-java -r path/to/your/workspace/root/dir
@iirina iirina self-assigned this Jun 28, 2019
@iirina iirina added bazel 1.0 incompatible-change Incompatible/breaking change P1 I'll work on this now. (Assignee required) team-Rules-Java Issues for Java rules labels Jun 28, 2019
@iirina
Copy link
Contributor Author

iirina commented Jun 28, 2019

Currently the builds will fail with --incompatible_load_java_rules_from_bzl because the java_tools are released separately and do not use the macro definitions yet. This will be fixed by updating BUILD.java_tools and releasing new java_tools versions.

bazel-io pushed a commit that referenced this issue Jun 28, 2019
RELNOTES: --incompatible_load_java_rules_from_bzl was added to forbid loading the native java rules directly. See more on tracking issue #8746
PiperOrigin-RevId: 255600811
bazel-io pushed a commit that referenced this issue Jul 3, 2019
`@rules_java` repository is now available to all Bazel java users. There is the possibility to override the repository in the users' WORKSPACE file in order to safely migrate #8746.

Progress on #8746.

Closes #8758.

PiperOrigin-RevId: 256347290
siberex pushed a commit to siberex/bazel that referenced this issue Jul 4, 2019
RELNOTES: --incompatible_load_java_rules_from_bzl was added to forbid loading the native java rules directly. See more on tracking issue bazelbuild#8746
PiperOrigin-RevId: 255600811
siberex pushed a commit to siberex/bazel that referenced this issue Jul 4, 2019
`@rules_java` repository is now available to all Bazel java users. There is the possibility to override the repository in the users' WORKSPACE file in order to safely migrate bazelbuild#8746.

Progress on bazelbuild#8746.

Closes bazelbuild#8758.

PiperOrigin-RevId: 256347290
@iirina
Copy link
Contributor Author

iirina commented Jul 5, 2019

Repositories referenced by bazel that use the native java rules and have to be migrated & upgraded before migrating bazel itself:

bazel-io pushed a commit that referenced this issue Jul 10, 2019
Baseline: 2e374a9

Cherry picks:

   + 6d0b14b:
     rule_test: apply "tags" to all rules in the macro

Incompatible changes:

  - Add --incompatible_enable_profile_by_default to enable the JSON
    profile by default.
  - The --incompatible_windows_style_arg_escaping flag is flipped to
    "true", and the "false" case unsupported. Bazel no longer accepts
    this flag.

Important changes:

  - Bazel now supports hiding compiler warnings for targets that
    you're not explicitly building (see
    https://docs.bazel.build/versions/master/user-manual.html#flag--au
    to_output_filter).
  - Flag `--incompatible_restrict_escape_sequences` is added. See
    #8380
  - The "info" command now supports the "starlark-semantics"
    argument, which outputs a representation of the effective Starlark
    semantics option values.
  - The `outputs` parameter of the `rule()` function is deprecated
    and attached to flag `--incompatible_no_rule_outputs_param`.
    Migrate rules to use `OutputGroupInfo` or `attr.output` instead.
    See #7977 for more info.
  - When `--incompatible_strict_action_env` is enabled, the default
    `PATH` now includes `/usr/local/bin`.
  - Turn on --experimental_build_setting_api by default for starlark
    build settings (see
    https://docs.bazel.build/versions/master/skylark/config.html#user-
    defined-build-settings for more info)
  - `@bazel_tools//tools/jdk:toolchain_java10` and
    `@bazel_tools//tools/jdk:toolchain_java11` are now available to
    enable java 10, respectively java 11 language level support.
  - The `command` parameter of the `actions.run_shell()` function
    will be restricted to only accept strings (and not string
    sequences). This check is attached to flag
    `--incompatible_run_shell_command_string`. One may migrate by
    using the `arguments` parameter of `actions.run()` instead. See
    #5903 for more info.
  - Incompatible change
    `--incompatible_use_platforms_repo_for_constraints` has been
    added. See #8622 for
    details.
  - Incompatible change
    `--incompatible_use_platforms_repo_for_constraints` has been
    added. See #8622 f...
  - Bazel's C++ autoconfiguration now understands `BAZEL_LINKLIBS`
    environment variable to specify system libraries that should be
    appended to the link command line.
  - paths under the execution root starting with "." or "_" will be
    re-linked across builds
  - execution_log_json_file now allows actions without outputs.
  - Labels aapt as deprecated for aapt_version, and heavily endorses
    aapt2.
  - Update doc links still pointing to cc_binary.features to point to
    common features
  - Incompatible change
    `--incompatible_use_platforms_repo_for_constraints` has been
    added. See #8622 for
    details.
    RELNOTES:
  - --incompatible_disable_nocopts flag has been added. See
    #8706 for details.
  - Fixed treatment of <dist:module /> tags in AndroidManifest.xml
  - Fixed asset precedence for android_binary rules with aapt2.
  - Bazel now officially supports running on CentOS 7.
  - The runtime dynamic libraries are no longer in default output
    group of cc_binary.
  - set the FDOBuildType as CSFDO for binaries built with
    --cs_fdo_absolute_path.
  - Bazel can now be bootstrapped and built on arm64 platforms
    without requiring any flags or patches.
  - Fixed treatment of AndroidManifest.xml attributes which contained
    XML escaping
  - Retire experimental blaze flag
    experimental_link_compile_output_separately. The same behavior is
    available through the feature dynamic_link_test_srcs.
  - --incompatible_load_java_rules_from_bzl was added to forbid
    loading the native java rules directly. See more on tracking
    issue #8746
  - Turn on --experimental_build_setting_api by default for starlark
    build settings (see
    https://docs.bazel.build/versions/master/skylark/config.html#user-
    defined-build-settings for more info)
  - Attribute names are going to be restricted and must be
    syntactically valid identifiers.
    #6437
  - rule_test: fix Bazel 0.27 regression ("tags" attribute was
    ingored, #8723

This release contains contributions from many people at Google, as well as Ben Diuguid, Benjamin Peterson, Dave Lee, Loo Rong Jie, Mark Butcher, Marwan Tammam, Pedro Alvarez.
irengrig pushed a commit to irengrig/bazel that referenced this issue Jul 15, 2019
RELNOTES: --incompatible_load_java_rules_from_bzl was added to forbid loading the native java rules directly. See more on tracking issue bazelbuild#8746
PiperOrigin-RevId: 255600811
irengrig pushed a commit to irengrig/bazel that referenced this issue Jul 15, 2019
`@rules_java` repository is now available to all Bazel java users. There is the possibility to override the repository in the users' WORKSPACE file in order to safely migrate bazelbuild#8746.

Progress on bazelbuild#8746.

Closes bazelbuild#8758.

PiperOrigin-RevId: 256347290
irengrig pushed a commit to irengrig/bazel that referenced this issue Jul 15, 2019
Baseline: 2e374a9

Cherry picks:

   + 6d0b14b:
     rule_test: apply "tags" to all rules in the macro

Incompatible changes:

  - Add --incompatible_enable_profile_by_default to enable the JSON
    profile by default.
  - The --incompatible_windows_style_arg_escaping flag is flipped to
    "true", and the "false" case unsupported. Bazel no longer accepts
    this flag.

Important changes:

  - Bazel now supports hiding compiler warnings for targets that
    you're not explicitly building (see
    https://docs.bazel.build/versions/master/user-manual.html#flag--au
    to_output_filter).
  - Flag `--incompatible_restrict_escape_sequences` is added. See
    bazelbuild#8380
  - The "info" command now supports the "starlark-semantics"
    argument, which outputs a representation of the effective Starlark
    semantics option values.
  - The `outputs` parameter of the `rule()` function is deprecated
    and attached to flag `--incompatible_no_rule_outputs_param`.
    Migrate rules to use `OutputGroupInfo` or `attr.output` instead.
    See bazelbuild#7977 for more info.
  - When `--incompatible_strict_action_env` is enabled, the default
    `PATH` now includes `/usr/local/bin`.
  - Turn on --experimental_build_setting_api by default for starlark
    build settings (see
    https://docs.bazel.build/versions/master/skylark/config.html#user-
    defined-build-settings for more info)
  - `@bazel_tools//tools/jdk:toolchain_java10` and
    `@bazel_tools//tools/jdk:toolchain_java11` are now available to
    enable java 10, respectively java 11 language level support.
  - The `command` parameter of the `actions.run_shell()` function
    will be restricted to only accept strings (and not string
    sequences). This check is attached to flag
    `--incompatible_run_shell_command_string`. One may migrate by
    using the `arguments` parameter of `actions.run()` instead. See
    bazelbuild#5903 for more info.
  - Incompatible change
    `--incompatible_use_platforms_repo_for_constraints` has been
    added. See bazelbuild#8622 for
    details.
  - Incompatible change
    `--incompatible_use_platforms_repo_for_constraints` has been
    added. See bazelbuild#8622 f...
  - Bazel's C++ autoconfiguration now understands `BAZEL_LINKLIBS`
    environment variable to specify system libraries that should be
    appended to the link command line.
  - paths under the execution root starting with "." or "_" will be
    re-linked across builds
  - execution_log_json_file now allows actions without outputs.
  - Labels aapt as deprecated for aapt_version, and heavily endorses
    aapt2.
  - Update doc links still pointing to cc_binary.features to point to
    common features
  - Incompatible change
    `--incompatible_use_platforms_repo_for_constraints` has been
    added. See bazelbuild#8622 for
    details.
    RELNOTES:
  - --incompatible_disable_nocopts flag has been added. See
    bazelbuild#8706 for details.
  - Fixed treatment of <dist:module /> tags in AndroidManifest.xml
  - Fixed asset precedence for android_binary rules with aapt2.
  - Bazel now officially supports running on CentOS 7.
  - The runtime dynamic libraries are no longer in default output
    group of cc_binary.
  - set the FDOBuildType as CSFDO for binaries built with
    --cs_fdo_absolute_path.
  - Bazel can now be bootstrapped and built on arm64 platforms
    without requiring any flags or patches.
  - Fixed treatment of AndroidManifest.xml attributes which contained
    XML escaping
  - Retire experimental blaze flag
    experimental_link_compile_output_separately. The same behavior is
    available through the feature dynamic_link_test_srcs.
  - --incompatible_load_java_rules_from_bzl was added to forbid
    loading the native java rules directly. See more on tracking
    issue bazelbuild#8746
  - Turn on --experimental_build_setting_api by default for starlark
    build settings (see
    https://docs.bazel.build/versions/master/skylark/config.html#user-
    defined-build-settings for more info)
  - Attribute names are going to be restricted and must be
    syntactically valid identifiers.
    bazelbuild#6437
  - rule_test: fix Bazel 0.27 regression ("tags" attribute was
    ingored, bazelbuild#8723

This release contains contributions from many people at Google, as well as Ben Diuguid, Benjamin Peterson, Dave Lee, Loo Rong Jie, Mark Butcher, Marwan Tammam, Pedro Alvarez.
laurentlb pushed a commit that referenced this issue Jul 16, 2019
Baseline: 2e374a9

Cherry picks:

   + 6d0b14b:
     rule_test: apply "tags" to all rules in the macro

Incompatible changes:

  - Add --incompatible_enable_profile_by_default to enable the JSON
    profile by default.
  - The --incompatible_windows_style_arg_escaping flag is flipped to
    "true", and the "false" case unsupported. Bazel no longer accepts
    this flag.

Important changes:

  - Bazel now supports hiding compiler warnings for targets that
    you're not explicitly building (see
    https://docs.bazel.build/versions/master/user-manual.html#flag--au
    to_output_filter).
  - Flag `--incompatible_restrict_escape_sequences` is added. See
    #8380
  - The "info" command now supports the "starlark-semantics"
    argument, which outputs a representation of the effective Starlark
    semantics option values.
  - The `outputs` parameter of the `rule()` function is deprecated
    and attached to flag `--incompatible_no_rule_outputs_param`.
    Migrate rules to use `OutputGroupInfo` or `attr.output` instead.
    See #7977 for more info.
  - When `--incompatible_strict_action_env` is enabled, the default
    `PATH` now includes `/usr/local/bin`.
  - Turn on --experimental_build_setting_api by default for starlark
    build settings (see
    https://docs.bazel.build/versions/master/skylark/config.html#user-
    defined-build-settings for more info)
  - `@bazel_tools//tools/jdk:toolchain_java10` and
    `@bazel_tools//tools/jdk:toolchain_java11` are now available to
    enable java 10, respectively java 11 language level support.
  - The `command` parameter of the `actions.run_shell()` function
    will be restricted to only accept strings (and not string
    sequences). This check is attached to flag
    `--incompatible_run_shell_command_string`. One may migrate by
    using the `arguments` parameter of `actions.run()` instead. See
    #5903 for more info.
  - Incompatible change
    `--incompatible_use_platforms_repo_for_constraints` has been
    added. See #8622 for
    details.
  - Incompatible change
    `--incompatible_use_platforms_repo_for_constraints` has been
    added. See #8622 f...
  - Bazel's C++ autoconfiguration now understands `BAZEL_LINKLIBS`
    environment variable to specify system libraries that should be
    appended to the link command line.
  - paths under the execution root starting with "." or "_" will be
    re-linked across builds
  - execution_log_json_file now allows actions without outputs.
  - Labels aapt as deprecated for aapt_version, and heavily endorses
    aapt2.
  - Update doc links still pointing to cc_binary.features to point to
    common features
  - Incompatible change
    `--incompatible_use_platforms_repo_for_constraints` has been
    added. See #8622 for
    details.
    RELNOTES:
  - --incompatible_disable_nocopts flag has been added. See
    #8706 for details.
  - Fixed treatment of <dist:module /> tags in AndroidManifest.xml
  - Fixed asset precedence for android_binary rules with aapt2.
  - Bazel now officially supports running on CentOS 7.
  - The runtime dynamic libraries are no longer in default output
    group of cc_binary.
  - set the FDOBuildType as CSFDO for binaries built with
    --cs_fdo_absolute_path.
  - Bazel can now be bootstrapped and built on arm64 platforms
    without requiring any flags or patches.
  - Fixed treatment of AndroidManifest.xml attributes which contained
    XML escaping
  - Retire experimental blaze flag
    experimental_link_compile_output_separately. The same behavior is
    available through the feature dynamic_link_test_srcs.
  - --incompatible_load_java_rules_from_bzl was added to forbid
    loading the native java rules directly. See more on tracking
    issue #8746
  - Turn on --experimental_build_setting_api by default for starlark
    build settings (see
    https://docs.bazel.build/versions/master/skylark/config.html#user-
    defined-build-settings for more info)
  - Attribute names are going to be restricted and must be
    syntactically valid identifiers.
    #6437
  - rule_test: fix Bazel 0.27 regression ("tags" attribute was
    ingored, #8723

This release contains contributions from many people at Google, as well as Ben Diuguid, Benjamin Peterson, Dave Lee, Loo Rong Jie, Mark Butcher, Marwan Tammam, Pedro Alvarez.
@Yannic
Copy link
Contributor

Yannic commented Jul 31, 2019

@iirina Can we update the description to include the load statement so users will know to include them?

load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")
rules_java_dependencies()
rules_java_toolchains()

@dslomov
Copy link
Contributor

dslomov commented Aug 5, 2019

Will migration tooling be available to do the migration? (based on buildifier)

@iirina
Copy link
Contributor Author

iirina commented Aug 5, 2019

@dslomov Yes I updated the migration notes to include using buildifier.

@lberki
Copy link
Contributor

lberki commented Oct 5, 2020

We gave up on this :(

@lberki lberki closed this as completed Oct 5, 2020
@MikhailTymchukFT
Copy link

@lberki Can you please elaborate?
And what about tracking issue?

@lberki
Copy link
Contributor

lberki commented Oct 6, 2020

Erm, sorry for the curt answer. We decided not to require everyone to add a load() statement to every single BUILD file because it's too much churn. The current plan is to "pretend" that the eventual C++/Java rules written in Starlark are load()ed everywhere.

We might revisit this decision once they are reasonably stable and once we decide where exactly they need to be load()ed from, but now is not the time. I'll also close the tracking issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
incompatible-change Incompatible/breaking change P1 I'll work on this now. (Assignee required) team-Rules-Java Issues for Java rules untriaged
Projects
None yet
Development

No branches or pull requests