spring-gradle-plugins / dependency-management-plugin

A Gradle plugin that provides Maven-like dependency management functionality
690 stars 88 forks source link

Exclusions are calculated unnecessarily for non-transitive configurations #372

Closed fp7 closed 5 months ago

fp7 commented 9 months ago

All direct dependencies of a configuration are included by default and all other are excluded by default for non transitive configurations. It is therefore unnecessary to calculate exclusions.

wilkinsona commented 9 months ago

Thanks for the proposal. What's the motivation for this change? Is it purely an optimisation to improve performance or have you seen incorrect behavior with non-transitive configurations? If it's the former, can you please describe the performance problem that you were facing?

fp7 commented 8 months ago

(Sorry for the delay.)

It is neither performance nor incorrect behaviour. The dependency-management-plugin logged the following message in combination with spotless and eclipse groovy based formatting.

Errors occurred while building effective model from /home/repro/.gradle/caches/modules-2/files-2.1/org.eclipse.platform/org.eclipse.swt/3.124.100/95a7ddc41b5a1771a7b69a47e9488a2c09ef5098/org.eclipse.swt-3.124.100.pom:
        'dependencies.dependency.artifactId' for org.eclipse.platform:org.eclipse.swt.${osgi.platform}:jar with value 'org.eclipse.swt.${osgi.platform}' does not match a valid id pattern. in org.eclipse.platform:org.eclipse.swt:3.124.100

The placeholder can not be resolved is in this pom: https://repo1.maven.org/maven2/org/eclipse/platform/org.eclipse.swt/3.124.100/org.eclipse.swt-3.124.100.pom

The message gets logged here: https://github.com/spring-gradle-plugins/dependency-management-plugin/blob/c8d0dcfa9573e786fe0d4a247291358317064d69/src/main/java/io/spring/gradle/dependencymanagement/internal/maven/EffectiveModelBuilder.java#L103C4-L103C4

This did not lead to errors, but was a little bit annoying, especially because it was logged for every subproject.

To remove the logged message, as a workaround I added systemProp.osgi.platform=foo to the gradle.properties in my project.

But I also realized that this message would go away when ignoring transitive dependencies in the dependency-management-plugin on non transitive configurations because that is happening eventually anyway. And that it would also prevent some unnecessary work to be done during dependency resolution.

I created a reproduction repository if needed: https://github.com/fp7/sdm-spotless-logging-repro. With ./gradlew spotlessApply you see the message.

wilkinsona commented 5 months ago

Thanks very much, @fp7.