Skip to content

Conversation

lisa-croxford-srtmarine
Copy link

@lisa-croxford-srtmarine lisa-croxford-srtmarine commented Aug 25, 2025

Motivation

Our company has a large multi-language gradle project with lots of small sub-projects all of which have associated SonarCloud projects, currently when our developers make any sort of change they follow the normal branch, PR, merge cycle.

I have been tasked with optimising our CI builds but one of the biggest obstacles this amount of time and CPU usage of the analysis steps in our builds, currently all sub-projects are analysed on every build which leads to slow turn around before PRs get the go ahead from the analysis.

We would like that the sonar task would only run when the source files or its dependencies change and that it would use the shared gradle build cache we have. However currently the gradle SonarTask was not implemented in a way that will permit that due to the declared task inputs.

Proposed Changes

Currently SonarTask.getProperties() is marked as @Input which I assume is to satisfy the Gradle API however this contains a lot of computed environment specific values that are tied to the current build agent and working directory. In this PR I have marked this as @Internal and instead explicitly populate the input object with a filtered version of properties. Additionally I have added a SonarTask.getInputFiles() method that shall return a list of all the source and library files used in the build so that it will follow the proper gradle update checks on repeated builds.

Since this will unexpectedly alter the behaviour of the plugin, I have prevented any caching automatically by adding a new sonar.gradle.cache property. Any caching of outputs will be explicitly disabled unless users opt-in

@lisa-croxford-srtmarine lisa-croxford-srtmarine marked this pull request as ready for review August 25, 2025 17:54
@lisa-croxford-srtmarine lisa-croxford-srtmarine changed the title Configure task inputs to permit caching and up-to-date type checks Fix task inputs to permit caching and up-to-date checks Aug 25, 2025
@lisa-croxford-srtmarine lisa-croxford-srtmarine force-pushed the GVC-17314-cache-inputs branch 3 times, most recently from b95a6e4 to 726aa63 Compare August 25, 2025 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants