Skip to content

Add Gradle support for proper dependency tracking to app model#52226

Open
reaver585 wants to merge 1 commit intoquarkusio:mainfrom
reaver585:maven-model-in-gradle
Open

Add Gradle support for proper dependency tracking to app model#52226
reaver585 wants to merge 1 commit intoquarkusio:mainfrom
reaver585:maven-model-in-gradle

Conversation

@reaver585
Copy link
Contributor

@reaver585 reaver585 commented Jan 27, 2026

With this change we collect declared and resolved
dependencies for Gradle builds and wire them into
the application model.

A boolean prop 'disableDeclaredDependencyCollector'
is available to disable this feature.

Co-authored-by: Alexey Loubyansky olubyans@redhat.com

@quarkus-bot quarkus-bot bot added area/devtools Issues/PR related to maven, gradle, platform and cli tooling/plugins area/gradle Gradle labels Jan 27, 2026
@reaver585 reaver585 force-pushed the maven-model-in-gradle branch 2 times, most recently from c20f0dd to bfff9f1 Compare January 28, 2026 09:44
@reaver585 reaver585 force-pushed the maven-model-in-gradle branch from bfff9f1 to bf8d2e3 Compare February 4, 2026 10:08
@reaver585 reaver585 changed the title [wip] Resolving maven POMs in Gradle for declared dependency recording Add Gradle support for keeping track of declared dependencies in ApplicationModel Feb 4, 2026
@reaver585 reaver585 force-pushed the maven-model-in-gradle branch from 57570d2 to a81adfc Compare February 16, 2026 16:09
@reaver585 reaver585 marked this pull request as ready for review February 17, 2026 20:20
LaunchMode.DEVELOPMENT);

Provider<DefaultProjectDescriptor> projectDescriptor = ProjectDescriptorBuilder.buildForApp(project);
DependencyDataCollector depDataCollector = new DependencyDataCollector(project);
Copy link
Member

Choose a reason for hiding this comment

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

I am thinking whether we should be creating DependencyDataCollector per task instead. So it could be garbage collected as soon as the task has been configured.

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 could be a benefit to keeping it on the project level.
E.g. :quarkusTest task among its dependencies has both quarkusGenerateAppModel and quarkusGenerateTestAppModel. In this scenario, I can confirm that test app model is significantly faster (40-70 ms) than the regular app model (~1.2s) because we have lots of cache hits in the collector.

task.getProjectDescriptor().set(projectDescriptor);
task.getLaunchMode().set(launchMode);
task.getDeclaredDependencies().set(declaredDepsProvider);
task.getDeclaredDependenciesSnapshot().set(declaredDepsProvider.map(DependencyDataCollector::toSnapshot));
Copy link
Member

Choose a reason for hiding this comment

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

Just to confirm, will the value of declareDepsProvider be resolved only once for this task?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically it's twice, but since everything is cached inside the collector, second time the time it takes is very short (<10ms), and I chose simplicity over performance in this case since performance hit is negligible.

@reaver585 reaver585 force-pushed the maven-model-in-gradle branch from e93f948 to 3f5b1b8 Compare February 18, 2026 09:47
@reaver585 reaver585 changed the title Add Gradle support for keeping track of declared dependencies in ApplicationModel Add Gradle support for proper dependency tracking to app model Feb 18, 2026
@reaver585 reaver585 force-pushed the maven-model-in-gradle branch from 3f5b1b8 to dc83430 Compare February 18, 2026 14:37
.provider(() -> dependencyDataCollector.collectDeclaredDependencies(
project, classpath.getDeploymentConfiguration()));
task.getProjectDescriptor().set(projectDescriptor);
task.getDisableDeclaredDependencyCollector().set(isDisableDeclaredDependencyCollector(project));
Copy link
Member

Choose a reason for hiding this comment

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

Do we need another property for the disable option or we could just not set the property values and check for property.isPresent() in the task?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Leaving a response here as well for historic purposes.
MapProperty as well as ListProperty need to be explicitly set to nulls in order for an isPresent() check to return false. I think it makes the code less clear, so for now I decided to keep what we have here.

But let me know if you feel strongly about it.

@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

With this change we collect declared and resolved
dependencies for Gradle builds and wire them into
the application model.

A boolean prop 'disableDeclaredDependencyCollector'
is available to disable this feature.

Co-authored-by: Alexey Loubyansky <olubyans@redhat.com>
@reaver585 reaver585 force-pushed the maven-model-in-gradle branch from 6370dc9 to 66e2bb8 Compare March 18, 2026 17:53
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 triage/flaky-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants