Skip to content

developmentOnly and testAndDevelopmentOnly configurations do not specify any attributes causing resolution problems - #51493

Open
wakingrufus wants to merge 1 commit into
spring-projects:mainfrom
wakingrufus:fix-configuration-attributes
Open

developmentOnly and testAndDevelopmentOnly configurations do not specify any attributes causing resolution problems#51493
wakingrufus wants to merge 1 commit into
spring-projects:mainfrom
wakingrufus:fix-configuration-attributes

Conversation

@wakingrufus

Copy link
Copy Markdown

copy configuration attributes from runtimeClasspath to developmentOnly and testAndDevelopmentOnly

fixes gh-51492

the developmentOnly and testAndDevelopmentOnly do not specify attributes, which can lead to Gradle selecting the wrong variant, or failing to resolve due to an ambiguity error. This can be avoided by following best practices regarding configuration attributes in gradle:
https://docs.gradle.org/current/userguide/best_practices_dependencies.html#use_attributes_on_configurations

the productionRuntimeClasspath was previously fixed in b01235e so a similar fix is needed for these configurations as well

I also included refactors in the modified code to better comply with Gradle lazy APIs

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 28, 2026
@wakingrufus
wakingrufus force-pushed the fix-configuration-attributes branch from 820e2f8 to 6a432fc Compare August 28, 2026 20:39
@wakingrufus
wakingrufus marked this pull request as ready for review August 28, 2026 20:39
* @param from configuration from which to copy attributes
* @param to configuration to which attributes will be copied
*/
@SuppressWarnings({ "rawtypes", "unchecked", "NullAway" })

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

NullAway warnings should not be suppressed

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

in this case, the key is already verified to be present, so it is null safe code, but nullaway is not able to tell. I am not sure how else to handle this situation

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

in my latest refactor, it is clear that only the legacy implementation requires this supression, if that helps

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Sep 2, 2026
@wakingrufus
wakingrufus force-pushed the fix-configuration-attributes branch 2 times, most recently from 33584ad to 6e20db6 Compare September 2, 2026 14:52
@wakingrufus

Copy link
Copy Markdown
Author

Thanks for the review! I have updated this PR with the feedback.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Sep 2, 2026
@wakingrufus
wakingrufus force-pushed the fix-configuration-attributes branch 6 times, most recently from 908d338 to a9d7ba5 Compare September 2, 2026 15:11
…y and testAndDevelopmentOnly

fixes spring-projectsgh-51492
include refactors in the modified code to better comply with Gradle lazy APIs

Signed-off-by: John Burns <wakingrufus@gmail.com>
@wakingrufus
wakingrufus force-pushed the fix-configuration-attributes branch from a9d7ba5 to 4e024fb Compare September 2, 2026 15:12
@wilkinsona wilkinsona changed the title copy configuration attributes from runtimeClasspath to developmentOnly and testAndDevelopmentOnly developmentOnly and testAndDevelopmentOnly configurations do not specify any attributes causing resolution problems Sep 2, 2026
@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Sep 2, 2026
@wilkinsona wilkinsona added this to the 4.0.x milestone Sep 2, 2026
@wilkinsona wilkinsona self-assigned this Sep 2, 2026

@wilkinsona wilkinsona left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the updates. The change is still a little too broad as it tackles three separate things:

  1. Copying attributes onto the developmentOnly and testDevelopmentOnly configurations
  2. Introducing some laziness when working with configurations (using named instead of getByName
  3. Marking some configurations as not being consumable

There are also some places where a method has changed from private to static that appear unnecessary.

I'd like this PR to focus solely on 1. 2 and 3 are changes that should probably be made but they need to be considered and applied separately. They may also be broader in scope than tackled here as, for example, there are several other places where we call ConfigurationContainer.getByName(String) that may also be candidates for being lazy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resolution of developmentOnly and testAndDevelopmentOnly are not specified

3 participants