How to make ./gradlew buld execute other terminal commands

77 Views Asked by At

I am building a gradle project which has a javacc parser file (i.e a file with .jj extension) Therefore, to execute this .jj file we need to run 3 commands in the terminal as javacc filename.jj javac *.java java parsername

However, I want to know how to edit the build.gradle, so that whenever the user enters ./gradlew build all the above mentioned commands would be automatically executed.

1

There are 1 best solutions below

0
George On BEST ANSWER

Have you consider declaring your own task to do so ?

task executeCMD(type:Exec) {
  workingDir '.'
  commandLine 'cmd', 'echo', 'Hello world!'
     doLast {
         println "Executed!"
     }
 }

Am not sure how to link with the build command , maybe this can be helpful build.dependsOn project(':ProjectName').task('build') .