Gradle
Gradle is a build automation tool that builds upon the concepts of Apache Ant and Apache Maven and introduces a Groovy-based domain-specific language (DSL) instead of the more traditional XML form of declaring the project configuration.
Installation
First, we need to install Gradle IDE for Eclipse:
Click “Window” and select “Eclipse Marketplace…”
Search for “gradle” and select the first result (“Gradle IDE Pack XXX”), then install and restart Eclipse.
Click “New” and select “Other”, then select “Gradle Project…”
Enter a project name, then select “Java Quickstart” in the sample project dropdown:
Now you have a “build.gradle” file (similar to pom.xml in Maven). Let’s look inside:
We need to add spark-core dependencies to the dependencies{} object. We can leave testCompile as it is, and change the compile field to compile ‘com.sparkjava:spark-core:2.3’.
dependencies {
compile 'com.sparkjava:spark-core:2.3'
testCompile group: 'junit', name: 'junit', version: '4.+'
}
Right click select “Gradle” then “Refresh Dependencies..”
Now we can CODE!
In “src/main/java” you can delete “org.gradle” package, and add a new Class “Main.java”:
import static spark.Spark.*;
public class Main {
public static void main(String[] args) {
get("/hello", (req, res) -> "Hello World");
}
}
Now everything is ready for you to run your application. Enjoy!