-
Notifications
You must be signed in to change notification settings - Fork 10
Load the root gradle.properties only for properties not already set in buildSrc #602
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the buildSrc Gradle script to pull the Grails version from the root gradle.properties file instead of hardcoding via VersionInfo.
- Loads
gradle.propertiesintoproject.ext.gradleProperties - Switches the
grails-gradle-bomplatform dependency to interpolategradleProperties.grailsVersion
Comments suppressed due to low confidence (1)
grails-forge-core/src/main/java/org/grails/forge/feature/build/gradle/templates/buildSrcBuildGradle.rocker.raw:35
- Gradle automatically loads
gradle.propertiesinto project properties, so you can drop the manual file read block and useproject.property('grailsVersion')directly for cleaner and more idiomatic code.
file('../gradle.properties').withInputStream {
...src/main/java/org/grails/forge/feature/build/gradle/templates/buildSrcBuildGradle.rocker.raw
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
jdaugherty
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are downsides to importing properties... for us it did not matter, but for end grails applications it means they can't set properties via environment variables. Shouldn't projects make this decision theirselves?
…dSrc/build.gradle
# Conflicts: # grails-forge-core/src/main/java/org/grails/forge/feature/build/gradle/templates/buildSrcBuildGradle.rocker.raw
|
@jdaugherty I updated this to a goldilocks setup which supports buildSrc/gradle.properties, environment variables and /gradle.properties with /gradle.properties only applied when the variable does not exist in the others. Having a single location defining versions is a HUGE win and this enables it for users that want to use buildSrc. I also think this should be the default in Gradle, but that is another conversation. |
I had no idea the environment variables work for properties in buildSrc. That even makes this problem even more confusing because the gradle.properties do not. It seems gradle/gradle#1001 indicated that buildSrc should be treated like a child build and there is also a separate gradle ticket covering this scenario for child builds: gradle/gradle#2534 So I guess this is still an upstream todo? Your change appears to work for both variables & gradle.properties, so I'm ok with this. |
...src/main/java/org/grails/forge/feature/build/gradle/templates/buildSrcBuildGradle.rocker.raw
Show resolved
Hide resolved
jdaugherty
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's at least reference the upstream gradle issue so people know why we made this change?
This matches the code from grails-core: https://github.com/apache/grails-core/blob/7.0.x/buildSrc/build.gradle#L24-L28