0

I have my java class files under build/deploy folder. To execute this locally, I will open cmd in this path and run command

java -classpath .;lib/* mainClass args

Now, I need to achieve same behaviour thru gradle task. My task supposed to run with predefined data and assert the output of this class files. I tried something like

task runWithExec(type: JavaExec) {
    group = "Execution"
    description = "Run the main class with JavaExecTask"
    classpath = files("build/install/lib/*").getAsPath()
    main = "mainClass"
}

but I am facing classNotfound exception. And also, how i can assert the output here.

  • A common way to achieve this goal ("run with predefined data and assert the output of this class files") is to use unit tests. But if you are committed to using a `JavaExec` task, see this other question: – dnault Jul 09 '20 at 18:15
  • Does this answer your question? [Gradle: how to make JavaExec task use configuration classpath?](https://stackoverflow.com/questions/13683613/gradle-how-to-make-javaexec-task-use-configuration-classpath) – dnault Jul 09 '20 at 18:15
  • Actually, I have already ran unit tests on my project before building it. After It successfully build the class files, I need to ran regression test on my deployment file locally. Thats why i wanted to use JavaExec task. – Deenadhayalan M Jul 10 '20 at 04:41

0 Answers0