-
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
Quarkus code-gen (Gradle): Fix behavior to filter unavailable services #36800
Merged
aloubyansky
merged 2 commits into
quarkusio:main
from
snazy:gradle-plugin-unavailable-services
Nov 3, 2023
Merged
Quarkus code-gen (Gradle): Fix behavior to filter unavailable services #36800
aloubyansky
merged 2 commits into
quarkusio:main
from
snazy:gradle-plugin-unavailable-services
Nov 3, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Java Services (those in `META-INF/services/*` files) that are defined in the (Gradle) project that uses the Quarkus Gradle plugin, are not available when Quarkus code generation runs. This is simply a task-dependency requirement in Gradle, because Java compilation happens after code generation. If a Java service, for example a Smallrye config sources, is present and the (Smallrye) configuration is needed by a Quarkus extension, the build fails during Quarkus code generation with an error message like this: ``` org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':quarkusGenerateCode'. ... Caused by: org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A failure occurred while executing io.quarkus.gradle.tasks.worker.CodeGenWorker ... Caused by: java.util.ServiceConfigurationError: io.smallrye.config.ConfigSourceFactory: Provider xyz not found ``` `io.quarkus.deployment.CodeGenerator` has a mechanism to filter out unavailable services via `getUnavailableConfigServices()`. However the callback passed to `io.quarkus.paths.PathTree.apply()` can stop before all roots/trees (`io.quarkus.paths.PathTree.getRoots()`) have been "asked" (`MultiRootPathTree`), because the callback can return a non-`null` value. This "early stop" happens before the root/tree containing the source with the `META-INF/services/*` has been processed. The bug is only triggered, if a Java service is defined in the Gradle project using the Quarkus Gradle plugin and if a Quarkus extension using the configuration is a dependency of that project. This change updates the callback implementation to collect all unavailable services from all `PathTree` roots/trees. An integration test using the Gradle plugin is included as well. Two logging/spelling mistakes have been fixed as well. Fixes quarkusio#36716
quarkus-bot
bot
added
area/core
area/devtools
Issues/PR related to maven, gradle, platform and cli tooling/plugins
area/gradle
Gradle
labels
Oct 31, 2023
Hm - the CI failures in the Devtools Tests look unrelated to me. |
This comment has been minimized.
This comment has been minimized.
Let's rebuild again, just in case. Thanks for the PR! |
aloubyansky
approved these changes
Nov 2, 2023
This comment has been minimized.
This comment has been minimized.
✔️ The latest workflow run for the pull request has completed successfully. It should be safe to merge provided you have a look at the other checks in the summary. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area/core
area/devtools
Issues/PR related to maven, gradle, platform and cli tooling/plugins
area/gradle
Gradle
kind/bugfix
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Java Services (those in
META-INF/services/*
files) that are defined in the (Gradle) project that uses the Quarkus Gradle plugin, are not available when Quarkus code generation runs. This is simply a task-dependency requirement in Gradle, because Java compilation happens after code generation. If a Java service, for example a Smallrye config sources, is present and the (Smallrye) configuration is needed by a Quarkus extension, the build fails during Quarkus code generation with an error message like this:io.quarkus.deployment.CodeGenerator
has a mechanism to filter out unavailable services viagetUnavailableConfigServices()
. However the callback passed toio.quarkus.paths.PathTree.apply()
can stop before all roots/trees (io.quarkus.paths.PathTree.getRoots()
) have been "asked" (MultiRootPathTree
), because the callback can return a non-null
value. This "early stop" happens before the root/tree containing the source with theMETA-INF/services/*
has been processed.The bug is only triggered, if a Java service is defined in the Gradle project using the Quarkus Gradle plugin and if a Quarkus extension using the configuration is a dependency of that project.
This change updates the callback implementation to collect all unavailable services from all
PathTree
roots/trees.An integration test using the Gradle plugin is included as well.
Two logging/spelling mistakes have been fixed as well.
Fixes #36716