I have a task that runs a simple JavaExec.
What I cant seem to get working is the ability to run the JavaExec multiple times while iterating a Filetree object (containing the files) each of while I want to pass into the main JavaExec class one by one. Unfortunately the compiler or code generation tool as it is doesnot accept a directory as an arg so I need to pass the file as an arg per loop. Here's what I have:
task generateClasses(type: JavaExec) {
   description = 'Generates Json Classes...'
   classpath configurations.all
   main = "org.apache.gora.compiler.Compiler"
   FileTree tree = fileTree(dir: 'src/main')
   tree.include '**/*.json'
       tree.each {File file ->
       println file
       args = [ "src/main/json/$file.name", "$buildDir/generated-src/src/main/java" ]
   }    
}
compileJava.source generateClasses.outputs.files, sourceSets.main.java
From the above it works and I get all files listed but the JavaExec is called just the once on the very last file read.
How do I address the above? Please help.
How about using the project.javaexec method?  See the API Documentation or the 
DSL ref.
task generateClasses {
  description = 'Generate Json Classes'
  fileTree(dir: 'src/main', include:'**/*.json').each { file ->
    doLast {
      javaexec {
        classpath configurations.all
        main = 'org.apache.gora.compiler.Compiler'
        args = ["src/main/json/$file.name", "$buildDir/generated-src/src/main/java"]
      }
    }
  }
}
                        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