Lesson 32 / 38
Maven pom.xml, Lifecycle & Gradle at a Glance
Read a real pom.xml — coordinates, dependencies, plugins — walk the Maven lifecycle phases in order, and see the equivalent Gradle build file.
Anatomy of a pom.xml
groupId:artifactId:version uniquely identify your artifact in a repository. <dependencies> list what you need (with a <scope> — compile default, test, provided, runtime); <plugins> extend the build (compiler settings, packaging, tests).
<project>
<groupId>com.acme</groupId>
<artifactId>orders-service</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>The lifecycle, in order
Maven's default lifecycle runs phases in order, each including everything before it: validate → compile → test → package → verify → install → deploy. Running mvn package also compiles and tests first; mvn install additionally copies the artifact into your local ~/.m2 repository for other local projects to depend on.
Gradle at a glance
Gradle expresses the same dependencies in a shorter Kotlin/Groovy DSL, models tasks as a graph instead of fixed phases, and only re-runs tasks whose inputs actually changed — its incremental build cache is why Gradle builds are typically faster on repeat runs.
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
testImplementation("org.junit.jupiter:junit-jupiter")
}
tasks.test {
useJUnitPlatform()
}