Skip to content
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

Declaring explicitly the build service in the QuarkusBuildTask #44399

Merged

Conversation

cdsap
Copy link
Contributor

@cdsap cdsap commented Nov 9, 2024

#44367 describes the issue of the task quarkusAppPartsBuild in a project applying quarkus in multiple modules.
The issue is reproducible in any project with the following configuration:

//module a
plugins {
    `java-library`
    id("io.quarkus")
    id("com.github.ben-manes.versions") version "0.51.0"
}

//module b
plugins {
    `java-library`
    id("io.quarkus")
    id("com.github.ben-manes.versions") version "0.51.0"
}

The property failing is additionalForcedProperties, which represents a BuildSerivice with the forced properties used by different tasks. The build service uses the @ServiceReference annotation that eliminates the need to declare the association between the task and the service explicitly. This is the part that is failing and I need to confirm with the Build Tool team If it's an expected behavior.
This PR implements the explicit declaration between the task and the service:

        task.getAdditionalForcedProperties().set(serviceProvider);
        task.usesService(serviceProvider)

https://docs.gradle.org/current/userguide/build_services.html#sec:service_references

@quarkus-bot quarkus-bot bot added area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/gradle Gradle labels Nov 9, 2024
@geoand
Copy link
Contributor

geoand commented Nov 11, 2024

cc @aloubyansky

@cdsap
Copy link
Contributor Author

cdsap commented Nov 12, 2024

I'm still working on a reproducer (without the QuarkusPlugin) for the Build Tool team, a simple:

public abstract class FooAbstractTask extends DefaultTask {
    @ServiceReference("forcedPropertiesService")
    abstract Property<ForcedPropertieBuildService> getAdditionalForcedProperties();

with the same configuration as the reproducer is not triggering the issue.

@cdsap cdsap force-pushed the build_service_provider_explicitly_task branch 2 times, most recently from d74c319 to d0ae6d4 Compare November 13, 2024 23:11
@cdsap cdsap marked this pull request as ready for review November 14, 2024 01:22
@cdsap
Copy link
Contributor Author

cdsap commented Nov 14, 2024

Hi @aloubyansky, after discussing this issue with the Build tool team I'm opening for review this PR.
The original issue is described here gradle/gradle#17559

When registering a build service, due to how classloaders are shared or not among projects (essentially, projects with the same set of plugins applied share a classloader, though project hierarchies add additional variations), the class backing a shared build service registered by a plugin against a project may be incompatible with the class available under some other project.

The original idea was to remove the BuildService, but first, we need to address the issue where the actions nativeArgs and manifest need to be extracted from QuarkusBuild and included in the Quarkus extension to later be wired as inputs (I will create an issue soon). This PR addresses the issue by declaring a build service for each project where the Quarkus plugin is applied and explicitly declaring the build service in the task.

Copy link
Member

@aloubyansky aloubyansky left a comment

Choose a reason for hiding this comment

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

Thanks a lot @cdsap for all the details and the patch

@geoand geoand added triage/waiting-for-ci Ready to merge when CI successfully finishes triage/backport-3.16 triage/backport labels Nov 14, 2024

This comment has been minimized.

@aloubyansky
Copy link
Member

The CI seems to be stuck again

@geoand
Copy link
Contributor

geoand commented Nov 14, 2024

Yeah, really weird. I would just rebase and force push if I were you @aloubyansky

@aloubyansky aloubyansky force-pushed the build_service_provider_explicitly_task branch from d0ae6d4 to b6324cd Compare November 14, 2024 08:41
@geoand
Copy link
Contributor

geoand commented Nov 14, 2024

👍🏽

Seems to be good now

Copy link

quarkus-bot bot commented Nov 14, 2024

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit b6324cd.

✅ 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.

You can consult the Develocity build scans.

@aloubyansky aloubyansky merged commit 8a57c8f into quarkusio:main Nov 14, 2024
21 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.18 - main milestone Nov 14, 2024
@quarkus-bot quarkus-bot bot added kind/bugfix and removed triage/waiting-for-ci Ready to merge when CI successfully finishes labels Nov 14, 2024
@gsmet gsmet modified the milestones: 3.18 - main, 3.16.4 Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/gradle Gradle kind/bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gradle 3.16 fails with missing required property additionalForcedProperties
4 participants