I am trying to write a script in gradle that requires opening up a file. I am trying to find the current directory where the project is installed. so I can open a file in my "raw" directory.
Note: I am aware that I can use a temporary file to find the current location of the application. However, I am trying to stay away from that solution.
I am trying to find out if gradle has a buildDir variable that I can use in my task instead.
Normally to get the absolute path of the foo folder I can just simply do new File('foo'). getAbsolutePath() in the root build. gradle file. With the previous command gradle is looking for the foo directory in the parent of the Project, because I started the script from there.
Local variables are declared with the def keyword. They are only visible in the scope where they have been declared. Local variables are a feature of the underlying Groovy language. Local variables are declared with the val keyword.
On android studio just go to File > Settings > Build Execution, Deployment > Gradle > Service directory path choose directory what you want.
Creating directories All core Gradle tasks ensure that any output directories they need are created if necessary using this mechanism. As described in the Apache Ant manual, the mkdir task will automatically create all necessary directories in the given path and will do nothing if the directory already exists.
See the Gradle docs. Specifically, you're interested in projectDir
(The directory containing the build script) or buildDir
(projectDir/build).
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