EMZETT.
Login

Maven and Gradle

In short: Maven and Gradle are the common build tools for Java: they fetch dependencies, compile, test and package the project.

In more detail: Maven describes the project declaratively in a pom.xml, Gradle in a script (Groovy or Kotlin) that is more flexible.

In Depth

  • Maven: Fixed lifecycles (compile, test, package, install) and a standard folder layout (src/main/java). Dependencies with coordinates group:artifact:version from Maven Central, including transitive ones.
  • Gradle: Task graph, incremental builds, build cache and daemon usually make it faster. Standard on Android.
  • Wrapper: mvnw and gradlew download the right tool version themselves so everyone builds the same.
  • Commands: mvn clean package, gradle build, gradle test.
  • Dependency conflicts: mvn dependency:tree and gradle dependencies show where a version comes from.
  • Choice: Maven for simplicity and uniformity, Gradle for large or unusual builds.

See also: javac, JVM