Home > Net >  sending an input to the gradle file extension when using "apply from:"
sending an input to the gradle file extension when using "apply from:"

Time:12-14

in gradle, you can segregate your main gradle file, for example, in android if you have a big build.gradle file you can divide this big file to small parts and then include them in the target build.gradle file

apply from: "$jacocoDir/jacoco_module.gradle" 

now my question is can we send an argument from the build.gradle file to the jacoco_module.gradle

for the above example imagine I have a jacoco_module.gradle and build.gradle that applies the jacoco_module how can I define the jacoco git ignore in the build.gradle

CodePudding user response:

There are numerous ways to get information into the second script. If you have something like this in build.gradle:

ext {
    someMagicNumber = 42
}
apply from: 'jacoco_module.gradle'

You could have something like this in jacoco_module.gradle:

tasks.register('magic') {
    doLast {
        println "Magic Number Is ${someMagicNumber}"
    }
}
  • Related