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

Resolution of productionRuntimeClasspath configuration may select the wrong variant and contain a dependency's source jar #38209

Closed
cwiejack opened this issue Nov 5, 2023 · 2 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@cwiejack
Copy link

cwiejack commented Nov 5, 2023

Hi,

The configuration productionRuntimeClasspath provided by the spring boot gradle plugin contains the sources jar of the dependency io.github.oshai:kotlin-logging-jvm:5.1.0 instead of the "real" jar.

All other third party jars are correct, only the kotlin-logging-jvm jar seems to be affected. I tested with different versions down to 4.0.0 all with the same result.

I tested with Spring Boot 3.1.5 and 3.2.0-RC2 on Mac M1 macOs 14.1.

You find a demo attached to this issue.
I created a task which copies the dependencies of productionRuntimeClasspath and runtimeClasspath into seperate folders. You can use ./gradlew copyAllDeps to reproduce on attached example project.

In build/allLibs/productionRuntime you find the sources jar of kotlin-logging-jvm and in build/allLibs/runtime everything is as expected.

logging-source.zip

Regards
Christian

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Nov 5, 2023
@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 6, 2023
@wilkinsona wilkinsona added this to the 2.7.x milestone Nov 6, 2023
@wilkinsona wilkinsona self-assigned this Nov 6, 2023
@wilkinsona
Copy link
Member

Thanks for the sample, @cwiejack.

You can work around the problem by adding an attribute to the productionRuntimeClasspath:

configurations {
	"productionRuntimeClasspath" {
		attributes {
			attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category::class, Category.LIBRARY))
		}
	}
}

The underlying bug exists in 2.7.x and later. However, given the ease with which a workaround can be applied, the risk of regression when configuring attributes, and that we're nearing EoL for 2.7.x and 3.0.x, I am going to fix it in 3.1.x and later.

@wilkinsona wilkinsona modified the milestones: 2.7.x, 3.1.x Nov 6, 2023
@wilkinsona wilkinsona changed the title Spring Boot gradle plugin configuration 'productionRuntimeClasspath' contains sources.jar Spring Boot gradle plugin configuration 'productionRuntimeClasspath' may select the wrong variant and contain a dependency's source jar Nov 6, 2023
@wilkinsona wilkinsona changed the title Spring Boot gradle plugin configuration 'productionRuntimeClasspath' may select the wrong variant and contain a dependency's source jar Resolution of productionRuntimeClasspath configuration may select the wrong variant and contain a dependency's source jar Nov 6, 2023
@wilkinsona wilkinsona modified the milestones: 3.1.x, 3.1.6 Nov 6, 2023
@cwiejack
Copy link
Author

cwiejack commented Nov 7, 2023

Hi,
Thanks for your quick response and the fix.

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

No branches or pull requests

3 participants