Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding script to build.gradle

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.

like image 500
Curious Guy 007 Avatar asked Aug 01 '12 21:08

Curious Guy 007


People also ask

How do I add a build script in Gradle?

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.

What is build script in Gradle?

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.

How do I run a script in Gradle?

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.


1 Answers

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'
} 
like image 159
adamoldak Avatar answered Nov 08 '22 20:11

adamoldak