Skip to content

Conversation

@wiwa
Copy link
Contributor

@wiwa wiwa commented May 3, 2022

Description

Allow per-target selection of Java compilation toolchain.

Note: This change doesn't add similar functionality to thrift_library.

Motivation

Helps with JDK migrations by allowing targets to incrementally update.
Also allows targets to opt into newer Java syntax.

Co-authored-by: Shane Delmore [email protected]

@wiwa wiwa requested review from liucijus and simuons as code owners May 3, 2022 21:16
@wiwa wiwa force-pushed the f/compile-jdk branch from 5b99da4 to 6c7b176 Compare May 3, 2022 22:27
@wiwa wiwa changed the title Use a public java_compile_toolchain attr instead of _java_toolchain [wip] Use a public java_compile_toolchain attr instead of _java_toolchain May 3, 2022
Copy link
Contributor

@wisechengyi wisechengyi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Shane and Win!

scala_junit_test(
name = "CheckBytecodeMajorVersion",
srcs = ["CheckBytecodeMajorVersionTest.scala"],
suffixes = ["Test"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for my learning, is suffixes significant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is necessary for scala_junit_test to discover test classes. Specifically one of prefixes or suffixes is needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ok thanks! not blocking, but if there's a default pattern to follow, then this declaration can be further simplified.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there isn't a default so we must manually specify 😞


Assert.assertTrue(
s"Expected java 8 (major version 52) but got major version $expectJava8",
majorVersionToJdkVersion(expectJava8) == 8
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: here and below using assertEquals is more idiomatic in junit. Eg.:

assertEquals(
  "Must be Java 8 (major version 52) bytecode", 
  8,
  majorVersionToJdkVersion(expectJava8)
)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed, thanks!

@wiwa wiwa changed the title [wip] Use a public java_compile_toolchain attr instead of _java_toolchain Use a public java_compile_toolchain attr instead of _java_toolchain May 4, 2022
@wiwa wiwa requested a review from liucijus May 5, 2022 20:16
@liucijus liucijus merged commit 3907126 into bazel-contrib:master May 9, 2022
@liucijus
Copy link
Collaborator

liucijus commented May 9, 2022

Thanks, @wiwa!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants