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.

猜你喜欢

转载自blog.csdn.net/xhl86xhl/article/details/48244625
今日推荐