There is simple Eclipse plugin to run Gradle, that just uses command line way to launch gradle.
What is gradle analog for maven compile and run
mvn compile exec:java -Dexec.mainClass=example.Example
This way any project with gradle.build
could be run.
UPDATE: There was similar question What is the gradle equivalent of maven's exec plugin for running Java apps? asked before, but solution suggested altering every project build.gradle
package runclass;
public class RunClass {
public static void main(String[] args) {
System.out.println("app is running!");
}
}
Then executing gradle run -DmainClass=runclass.RunClass
:run FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':run'.
> No main class specified
You just need to use the Gradle Application plugin:
apply plugin:'application'
mainClassName = "org.gradle.sample.Main"
And then simply gradle run
.
As Teresa points out, you can also configure mainClassName
as a system property and run with a command line argument.