What is the gradle equivalent of maven's exec plugin for running Java apps? -
with maven can create project, set pom dependencies, write class main method , run type:
mvn compile exec:java -dexec.mainclass=thornydev.app
what gradle equivalent of doing this?
i can gradle build
, builds jar file me, if main class has dependencies on other jars, running jar won't work without setting classpath. can gradle java plugin run app , set classpath me?
i'm looking command line solution simple one-off uses, not ide integration (i know how that).
the easiest solution use application plugin, among other things provides run
task. make main class configurable command line, you'll have set mainclassname
value of system (or project) property, , pass property command line:
apply plugin: "application" mainclassname = system.getproperty("mainclass")
now can run application gradle run -dmainclass=thornydev.app
.
Comments
Post a Comment