Gradle: Running a jar file

You can get Gradle to run a jar file for you by modifying ‘javaexec’:

javaexec { main='-jar'; args jar.archivePath }

This says the main class is ‘-jar’ and we’re passing our jar archive as the argument. It’s the same as running ‘java -jar YourArchive.jar’.

You an add this onto the end of the jaring process:

task runJar(dependsOn:jar) << {
  javaexec { main="-jar"; args jar.archivePath } 
}

‘gradle runJar’ will now run the jar task and then run the jar afterwards.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章