Gradle-style task graph with up-to-date checks
A depth-first walk gives a valid order (a topological sort, see the DSA course's graph modules). Real Gradle fingerprints file contents and outputs, not version strings.
Maven and Gradle are build tools: from one file (pom.xml or build.gradle.kts) they download your libraries and the libraries those need, compile your code, run the tests and package a JAR with one command. Maven uses a fixed lifecycle of phases and XML configuration; Gradle uses a task graph, a Kotlin or Groovy script, and skips work whose inputs haven't changed.
Change the code and press Run (Ctrl+Enter). Try to predict the output first, then break it on purpose and read the error. Your edits are saved and match the lesson page.
Practice questions
Write the code in the editor, run it, then open the model answer to compare.
Extend the "nearest wins" program so it also prints the Gradle choice (highest version) for each artifact. Compare versions numerically, part by part.
Write a program that prints the Maven coordinates group:artifact:version split into their three parts, and says whether the version is a SNAPSHOT.
Write the Gradle dependencies { } block for: Jackson databind 2.17.2 for main code, the PostgreSQL JDBC driver 42.7.4 only at runtime, and Mockito 5.12.0 for tests.
Explain it without notes
What does a build tool do for a Java project?
Explain the Maven build lifecycle and the relationship between phases, plugins and goals.
How do Maven and Gradle resolve version conflicts between transitive dependencies?
What are dependency scopes or configurations, and why do they matter?
Why is Gradle often faster than Maven on large projects?
Expected output
first build:
> Task :compileJava
> Task :processResources
> Task :classes
> Task :jar
> Task :compileTestJava
> Task :test
> Task :build
5 actionable tasks: 5 executed
only a test file changed:
> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :jar UP-TO-DATE
> Task :compileTestJava
> Task :test
> Task :build
5 actionable tasks: 2 executed, 3 up-to-date