I have project ("backend") configuration:
dependencies {
compile project(':model') //I would like to pass some params into this being build.
...
And other project ("frontend") configuration is very similar:
dependencies {
compile project(':model') //but from this project I will not pass params.
...
And when I build the dependant project model- I need to pass a parameter to it's build parameter and do something on condition. So for all projects who needs the sub-projects it will be built according to their needs.
To be more specific: When I build "backtend" - "model"'s project should run some task, but when I build "frontend" I don't.
Is it possible to force clean the sub-project as well?
You can easily pass parameters from command line, or by properties defined in gradle.properties
or in ext
. Here's a little project:
/build.gradle
ext {
var = "alpha"
}
task hello {
println "Name: $project.name"
println "Var: $var"
println "Param: $param"
println "Prop: $prop"
}
/gradle.properties
prop=gama
/settings.gradle
project.name = 'foo'
include 'bar'
/bar/build.gradle
task hello {
println "Name: $project.name"
println "Var: $var"
println "Param: $param"
println "Prop: $prop"
}
If you run gradle hello -Pparam=beta
it will print:
Name: foo
Var: alpha
Param: beta
Prop: gama
Name: bar
Var: alpha
Param: beta
Prop: gama
:hello UP-TO-DATE
:bar:hello UP-TO-DATE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With