简体   繁体   中英

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

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

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}"
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM