Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android gradle project directory variable

Tags:

android

gradle

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.

like image 422
ahmad Avatar asked Jul 07 '14 14:07

ahmad


People also ask

How do I find the project directory in Gradle?

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.

How do I declare a variable in Gradle?

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.

How do I change the home directory in Gradle?

On android studio just go to File > Settings > Build Execution, Deployment > Gradle > Service directory path choose directory what you want.

How do I create a directory in Gradle?

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.


1 Answers

See the Gradle docs. Specifically, you're interested in projectDir (The directory containing the build script) or buildDir (projectDir/build).

like image 120
Jeff Brateman Avatar answered Sep 27 '22 18:09

Jeff Brateman