I am trying to use gradle tasks as kind of "OS agnostic shell-script". I have no problems in writing the logic of the build file, but I would like to be able to run it from any folder.
My first attempt was to put a folder with my build.gradle file on the path, and then try to execute:
gradle myMask
from a folder that doesn't contain build.gradle - but that doesn't work.
My next attempt was:
gradle -b /folder/containing/build.gradle myTask
But that worked only to some extend. In my task I would like to find all files in CURRENT DIRECTORY. current - meaning not the one that contains build.gradle but the one from within which I am executing "gradle ....."
I have tried:
file(".")
and
file("$projectDir")
and some more, but all of them point to the folder containing build script, no the one from which I am executing it.
Any ideas how can I do that?
The global properties file should be located in your home directory: On Windows: C:\Users\<you>\. gradle\gradle.
gradle folder location for Android studio, you must: Define the GRADLE_USER_HOME environment variable to point to C:\WorkFolder\ . gradle. You can read more in the Configure the IDE docs.
In Android Studio, go to File > Project Structure. Then select the "project" tab on the left. Your Gradle version will be displayed here. If you are using the Gradle wrapper, then your project will have a gradle/wrapper/gradle-wrapper.
gradle file is located inside your project folder under app/build. gradle.
and the winner is:
System.getProperty("user.dir")
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