We use some Gradle base scripts on an central point. This scripts are included with "apply from:" from a large count of scripts. This base scripts need access to files relative to the script. How can I find the location of the base scripts?
Sample for one build.gradle:
apply from: "../../gradlebase/base1.gradle"
Sample for base1.gradle
println getScriptLocation()
The global properties file should be located in your home directory: On Windows: C:\Users\<you>\. gradle\gradle.
Located in the project/module directory of the project this Gradle script is where all the dependencies are defined and where the SDK versions are declared.
The Gradle user home directory ( $USER_HOME/.gradle by default) is used to store global configuration properties and initialization scripts as well as caches and log files.
I'm still not sure if I understood the question well but You can find path of current gradle script using following piece of code:
println project.buildscript.sourceFile
It gives the full path of the script that is currently running. Is that what You're looking for?
I'm not sure if this is considered an internal interface, but DefaultScriptHandler
has a getSourceFile()
method, and the current instance is accessible via the buildscript
property, so you can just use buildscript.sourceFile
. It's a File
instance pointing at the current script
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