I have a build.gradle
file. I need to add a code that executes a python script which I have written.
Can anyone tell me how to do it?
The build.gradle
is written in groovy .
So, please ask more questions if you feel my question is not sufficient.
In a command-line shell, move to the containing directory and execute the build script with gradle -q hello : What does -q do? Most of the examples in this user guide are run with the -q command-line option. This suppresses Gradle's log messages, so that only the output of the tasks is shown.
The "buildscript" configuration section is for gradle itself (i.e. changes to how gradle is able to perform the build). So this section will usually include the Android Gradle plugin.
Running Gradle Commands To run a Gradle command, open a command window on the project folder and enter the Gradle command. Gradle commands look like this: On Windows: gradlew <task1> <task2> … e.g. gradlew clean allTests.
Take a look at the Exec task. It can be used for running command line processes.
You could create a task like:
task runPython(type:Exec) {
workingDir 'path_to_script'
commandLine 'python', 'my_script.py'
}
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