Skip to content

Allow all necessary tools to be sourced from Java toolchain#29

Merged
chrisnovakovic merged 5 commits intoplease-build:masterfrom
chrisnovakovic:java_toolchain-everywhere
Dec 15, 2023
Merged

Allow all necessary tools to be sourced from Java toolchain#29
chrisnovakovic merged 5 commits intoplease-build:masterfrom
chrisnovakovic:java_toolchain-everywhere

Conversation

@chrisnovakovic
Copy link
Copy Markdown
Contributor

@chrisnovakovic chrisnovakovic commented Dec 13, 2023

Certain Java build rules provided by this plugin accept and make use of a Java toolchain outputted by java_toolchain in order to compile Java code (via javac) and run test JARs (via java). Extend the rules so that all JDK tools that they depend upon can be provided by a Java toolchain; in practice the only additional tool that the toolchain needs to provide is jlink (for java_runtime_image), although jlink was added in Java 9 which means that java_runtime_image is only usable with a java_toolchain that provides JDK 9 or newer. There's a run-time check for this in the build rule.

This adds two new plugin configuration options, JavaTool and RunSelfExecutablesWithJavaTool. The former is used whenever the java binary is required and no toolchain is defined. The latter controls whether this tool is invoked as part of the preamble in self-executable JARs outputted by java_binary; if this is enabled, none of the build commands executed by (or outputs from) the rules in this plugin require a JRE or JDK to be present in the system path, although self-executable JARs will need to be run with java -jar if they are moved outside of the Please repo. This option causes breaking changes when enabled and is therefore disabled by default.

@chrisnovakovic chrisnovakovic added the enhancement New feature or request label Dec 13, 2023
Certain Java build rules provided by this plugin accept and make use of
a Java toolchain outputted by `java_toolchain` in order to compile Java
code (via `javac`) and run test JARs (via `java`). Extend the rules so
that all JDK tools that they depend upon can be provided by a Java
toolchain; in practice the only additional tool that the toolchain needs
to provide is jlink (for `java_runtime_image`).

This adds two new plugin configuration options, `JavaTool` and
`RunSelfExecutablesWithJavaTool`. The former is used whenever the `java`
binary is required and no toolchain is defined. The latter controls
whether this tool is invoked as part of the preamble in self-executable
JARs outputted by `java_binary`; if this is enabled, none of the build
commands executed by (or outputs from) the rules in this plugin require
a JRE or JDK to be present in the system path, although self-executable
JARs will need to be run with `java -jar` if they are moved outside of
the Please repo. This option causes breaking changes when enabled and is
therefore disabled by default.
@chrisnovakovic chrisnovakovic force-pushed the java_toolchain-everywhere branch from 79644ae to e3f182d Compare December 15, 2023 10:56
@@ -1,5 +1,5 @@
[Please]
version = 17.0.0-beta.6
version = 17.4.0-beta.10
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Version bump required for the new get_entry_points built-in function in Please.

@chrisnovakovic chrisnovakovic merged commit d0b45d5 into please-build:master Dec 15, 2023
@chrisnovakovic chrisnovakovic deleted the java_toolchain-everywhere branch December 15, 2023 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants