-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
Gradle plugin does not provided public constant for the productionRuntimeClasspath configuration #26686
Comments
SpringBootPlugin.PRODUCTION_RUNTIME_CLASSPATH_NAME
public
Thanks for the report. I agree that the constant should be public. |
Huh, that was surprisingly easy. One should keep in mind that this configuration is now public api, even though the plugin tried to hide it before: Line 222 in 47516b5
Maybe the configuration Anyway, thank you for this quick response! |
Rename the now public constant for consistency with the JavaPlugin. See gh-26686
I missed that we previously kept the configuration open. I've flagged this issue for further team discussion because I'd like a second opinion on the change. |
Alright, thanks so far! I again want to stress the fact that there are real use cases for this configuration. Jib is hardly the only tool that consumes the runtimeClasspath configuration but would be better off consuming productionRuntimeClasspath. |
We've decided to make the constant public but keep |
When using the gradle plugin
org.springframework.boot
, it creates a configuration calleddevelopmentOnly
and also changes the configurationruntimeClasspath
to extend fromdevelopmentOnly
.Minimal example:
This effectively puts the devtools onto the runtime classpath, as can be verified by running
./gradlew -i dependencies --configuration runtimeClasspath
.We are building our projects as Docker images by using Google Jib. Jib blindly (but correctly) includes the complete runtimeClasspath into the image. This behavior is discussed here:
To exclude the devtools, there is an official jib extension: https://github.com/GoogleContainerTools/jib-extensions/tree/master/first-party/jib-spring-boot-extension-gradle . But this extension feels a bit cumbersome to use and really feels like a hacky workaround.
While researching other solutions to this issue, I've found out that the spring boot gradle plugin actually creates another gradle configuration called
productionRuntimeClasspath
that excludes the dependencies of thedevelopmentOnly
configuration. This is great and exactly what we need, because Jib can easily configured to use another configuration thanruntimeClasspath
.Minimal example:
As you can see, I reference
org.springframework.boot.gradle.plugin.SpringBootPlugin.PRODUCTION_RUNTIME_CLASSPATH_NAME
as the configuration name that Jib should consume.This works, because this is Groovy, and Groovy doesn't care about modifiers. In the source file at
spring-boot/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/SpringBootPlugin.java
Line 79 in 47516b5
I hope that I could explain my use-case sufficiently. I think the constant
PRODUCTION_RUNTIME_CLASSPATH_NAME
should be made public. Other constants likeBOM_COORDINATES
are already public for (as I assume) similar reasons.The text was updated successfully, but these errors were encountered: