-
Notifications
You must be signed in to change notification settings - Fork 4.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
Properties defined in 'gradle.properties' should be passed down to child builds #2534
Comments
Hello, Maybe there is workaround for this. Need to pass project property to root composite build and override it included projects. |
another use case. composite builds for android project must all use the same version of the android gradle plugin. I usually setup my projects with |
Properties passed via I have another use case, for which it would be necessary to set a property programmatically. If I guess this isn't possible/supported at the moment? |
Simple workaround for reading properties from root project into included project if anyone needs it:
|
Common Use Case I define the version of my product in Real world occurrence in Spring Boot build. If you change the build into a composite hierarchy, this breaks. To reproduce the issue:
You'll see how it works for
Expected Behavior
|
Another use case similar to @jjohannes and also related to spring boot is when I want to use conventions to author a multi-project build of a spring boot based project. I have 2 main projects I have an dependencies {
implementation "io.spring.gradle:dependency-management-plugin:$springDependencyManagementVersion"
implementation "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion"
} I have to add I also have to set things other properties like urls to my nexus repos in each properties file as well because they are not inherited from the root project. I would be happy with what @jjohannes is proposing as expected behavior. Does gradle know the full project hierarchy so that included composite builds know what project is the parent? |
Just wanted to post the workaround that ended up working best for me. If there is no need to define additional properties at the included composite build, you can just symlink the top-level project EDIT: |
Any fix in sight? |
Sharing my workaround to this. It is not the better approach but works: Tree:
settings.gradle.kts val builds = listOf(
"build-logic",
"domain-model",
"platforms",
)
rootProject.name = "root-project"
// Issue: https://github.com/gradle/gradle/issues/2534
val gradleProperties = "gradle.properties"
builds.forEach { projectName ->
includeBuild(projectName)
val includeGradleProperties = File(rootDir, "$projectName/$gradleProperties")
if (!includeGradleProperties.exists()) {
file(gradleProperties).copyTo(includeGradleProperties)
}
} .gitignore
|
Can composite builds now share a single gradle.properties? |
@Cyberavater they just intentionally won't add this behavior by default |
A simple workaround I'm using is symlinking |
Will you kindly let us see the script? 😜 |
There is no script. Creating a symlink is as simple as: cd my-included-build
ln -s ../gradle.properties |
It's a great solution if the whole team works on MacOS. Unfortunately, this is not possible for Windows users 😢 . |
I've used symlinks for |
To import all properties (based on @Dkhusainov suggestion), I changed it to: buildscript {
Properties properties = new Properties()
file('../gradle.properties').withInputStream {
properties.load(it)
}
properties.forEach { key, val ->
project.ext[key] = val
}
} my 2 cts 😉 |
@oehme commented on Thu Oct 06 2016
Properties (both in gradle.properties and passed via
-P
) should be passed to included builds.@adammurdoch commented on Wed Mar 08 2017
Maybe. The injection of configuration from a containing build needs more discussion. I don't think we necessarily want to automatically inherit everything, but probably want something a bit more declarative to allow a build to push config down.
@adammurdoch commented on Wed Mar 08 2017
As always, we should start with the use cases instead of the implementations.
@eskatos commented on Tue Apr 25 2017
One example use case. I wanted to run the
:install
task of the Gradle build from a composite build and pass it ainstallPath
property. Ideally my composite build would have a bunch of tasks depending on:gradle:install
with differentinstallPath
properties. Maybe it's a bit of a stretch.The text was updated successfully, but these errors were encountered: