-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add support for Java Toolchains in Quarkus Gradle plugin #44392
base: main
Are you sure you want to change the base?
Conversation
Thanks for your pull request! Your pull request does not follow our editorial rules. Could you have a look?
This message is automatically generated by a bot. |
3673d23
to
fb911c8
Compare
c5184c5
to
369adff
Compare
@gsmet Maybe you could kindly ping the right people to review the PR? 😇 |
Yeah sorry, we are a bit short of reviewers/owners for the Gradle plugin unfortunately. Let's at least see if CI is happy :). |
BTW, if you're willing to contribute in the Gradle area, we have some issues that need fixing and that would help a lot :). |
This comment has been minimized.
This comment has been minimized.
ceb94c1
to
f672ef4
Compare
@@ -58,4 +64,13 @@ public static List<Dependency> listProjectBoms(Project project) { | |||
return boms; | |||
} | |||
|
|||
@Nullable | |||
public static JavaToolchainSpec getExecutableOverrideToolchainSpec(ObjectFactory objectFactory) { | |||
String customExecutable = objectFactory.newInstance(DefaultJavaExecSpec.class).getExecutable(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just passing by:
JavaExec is doing that because for JavaExec you can set java as executable. For your task that doesn't make a lot of sense and objectFactory.newInstance(DefaultJavaExecSpec.class).getExecutable();
will always return null anyway. Also you are referencing internal type, it would be great if you could avoid that :)
I assume you want to achieve logic like:
if (quarkusTask has set toolchain) {
use that
} else {
use toolchains from JavaExtension
}
You can achieve that with something like:
Provider<JavaLauncher> javaExtensionToolchainLauncher = getToolchainService().launcherFor(getJavaPluginExtension().getToolchain());
task.getJavaLauncher().convention(javaExtensionToolchainLauncher);
See also https://docs.gradle.org/current/userguide/toolchains.html#sec:plugins_toolchains
I hope that helps! 👋
@@ -60,14 +92,18 @@ WorkQueue workQueue(Map<String, String> configMap, List<Action<? super JavaForkO | |||
} | |||
|
|||
return workerExecutor.processIsolation(processWorkerSpec -> configureProcessWorkerSpec(processWorkerSpec, | |||
configMap, forkOptionsSupplier)); | |||
configMap, forkOptionsSupplier, getJavaLauncher().get())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling .get()
will throw exeption if value is null. But launcher here will never be null, since it's not marked as @Optional
. And if user sets it to null (they need to also unset convention on the property) then this task will fail already at validation.
What I am trying to say is: It seems in this case you don't need to check launcher != null
later on, unless you mark getJavaLauncher()
as @Optional @Nested
, but then you also need to call .getOrNull()
here. But I think it makes more sense that getJavaLauncher() is not allowed to be null and with that you can remove null check later on
Status for workflow
|
Status | Name | Step | Failures | Logs | Raw logs | Build scan |
---|---|---|---|---|---|---|
✖ | Initial JDK 17 Build | Build |
Failures | Logs | Raw logs | 🔍 |
You can consult the Develocity build scans.
Failures
⚙️ Initial JDK 17 Build #
- Failing: devtools/gradle/gradle-application-plugin
! Skipped: integration-tests/gradle
📦 devtools/gradle/gradle-application-plugin
✖ Failed to execute goal net.revelc.code:impsort-maven-plugin:1.12.0:check (check-imports) on project io.quarkus.gradle.plugin: Imports are not sorted in /home/runner/work/quarkus/quarkus/devtools/gradle/gradle-application-plugin/src/main/java/io/quarkus/gradle/GradleUtils.java
Add support for Toolchains for JVM projects to the Quarkus Gradle plugin.
The implementation tries to be close to the one used in the Gradle
JavaExec
task, assuming this is The Way™ since that isn't always quite clear in Gradle. 😓Closes #20452