Giter Club home page Giter Club logo

Comments (2)

swarren12 avatar swarren12 commented on June 5, 2024

To summarise some points from fmeum's reply on the Bazel issue and my follow-up comment:

It just so happens that Bazel 6 uses a JDK 17 and Bazel 7 uses a JDK 21 for the Java toolchains registered by default. These toolchains use a transition on --java_runtime_version to resolve a matching JDK, which is why you see this additional resolution in the debugger.

It seems this also applies to the versions of rules_java: 6.3.2 uses Java 17 by default, whilst 7.0.4 uses Java 21.

We can use this to resolve the immediate issue by downgrading to 6.3.2 until the migration is complete. However, it is still unclear to me if (or how) we would force version 7.0.6 to use the Java 17 toolchain, rather than the Java 21 toolchain.

from rules_java.

EdbertChan avatar EdbertChan commented on June 5, 2024

Thought I would leave my comment here for the record:
bazelbuild/bazel#19934 (comment)

I believe the real fix is to add

[
    default_java_toolchain(
        name = "toolchain_java%d" % release,
        configuration = DEFAULT_TOOLCHAIN_CONFIGURATION,
        source_version = "%s" % release,
        target_version = "%s" % release,
+     java_runtime = "@bazel_tools//tools/jdk:toolchain_jdk%d" %release,
    )
    for release in RELEASES
]

And supply the toolchain_jdk for versions 8,9,10,11 (or at least a corresponding @bazel_tools//tools/jdk:remote_jdk{8,9,10}).

This will not work out of the box without it because otherwise you will get

java_runtime attribute of java_toolchain rule @rules_java//toolchains:toolchain_java11: '@bazel_tools//tools/jdk:toolchain_java11' does not have mandatory providers: 'JavaRuntimeInfo'

from rules_java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.