What Is Maven? Purpose, Advantages and Disadvantages - Quiz

Total: 5 questions

1. 

What is Maven, and what does the convention over configuration principle mean?

Maven (Apache Maven) is a build automation and dependency management tool for Java projects. It downloads libraries, compiles the code, runs the tests, packages the result into a jar or war file and generates documentation. The project is described declaratively in pom.xml: you state what you want to get, and Maven knows how. A single command such as mvn package works the same on Windows, Linux and macOS, without platform-specific bat/sh scripts.

Convention over configuration means that if the project follows the standard layout, almost nothing has to be configured: source code goes in src/main/java, resources in src/main/resources, tests in src/test/java, and Maven puts the build output in target. Missing settings (directories, jar packaging, standard plugins) come from the built-in Super POM.

Maven is neither a framework nor a library: it does not end up in the application jar. It is developed by the Apache Software Foundation; the first version was released in 2004.

2. 

What is Maven used for?

Maven covers the whole path from source code to a finished artifact: downloading libraries, compiling, running tests, packaging into a jar or war, installing into the local repository, publishing and generating reports.

  • Dependency management - libraries and their own (transitive) dependencies are downloaded automatically using the coordinates in pom.xml.
  • A uniform build process - mvn test or mvn package works in any Maven project.
  • A standard project layout - in someone else's project you immediately know where the code, resources and tests are.
  • CI automation - Jenkins, GitHub Actions and GitLab CI run exactly the same command as the developer.
  • Reports and quality checks - Javadoc, test coverage and static analysis are added through plugins.
  • Multi-module projects - a parent pom.xml builds related modules in the correct order.
3. 

What do the key Maven concepts mean: POM, artifact, GAV coordinates, repository, dependency, lifecycle and plugin?

  • POM (Project Object Model) - the project description in pom.xml: coordinates, dependencies, plugins, build settings.
  • Artifact - any file Maven produces or downloads: jar, war, pom, sources, Javadoc.
  • GAV coordinates - the triple groupId, artifactId, version that uniquely identifies an artifact, e.g. com.google.code.gson:gson:2.11.0.
  • Repository - storage for artifacts: local (~/.m2/repository), central (Maven Central) or corporate.
  • Dependency - a third-party library declared in pom.xml by its GAV coordinates.
  • Lifecycle - an ordered sequence of build phases (compile → test → package → install); running a phase also runs all the phases before it.
  • Plugin - a module that does the actual work; phases only invoke plugin goals.

Maven itself can do almost nothing: compilation is done by maven-compiler-plugin, tests by maven-surefire-plugin, packaging by maven-jar-plugin.

4. 

What is the Maven Wrapper (mvnw), and why use it?

The Maven Wrapper pins one Maven version for the whole team. The command mvn wrapper:wrapper adds the mvnw and mvnw.cmd scripts and the .mvn/wrapper/maven-wrapper.properties file with the Maven version to the project.

From then on the project is built with ./mvnw package (on Windows, mvnw.cmd package): the required Maven version is downloaded automatically, so there is no need to install Maven by hand. The scripts and the .mvn directory are committed to Git, so the CI server and every developer build the project with the same version.

The current stable line is Maven 3.9.x; running it requires Java 8 or newer, while the Java version used to compile the project is set in pom.xml.

5. 

What are the advantages and disadvantages of Maven, and when should you choose it over Gradle?

Advantages: OS-independent builds; automatic dependency management with version conflict resolution (the version closest to the project in the tree wins - "nearest wins"); one-command builds from the command line and on CI; integration with IntelliJ IDEA, Eclipse and VS Code; a declarative POM; the huge Maven Central repository; a large number of plugins; uniform conventions across projects.

Disadvantages: a learning curve; hidden behavior caused by the Super POM and default plugin bindings (mvn help:effective-pom shows the final configuration); too many plugins of varying quality; hard troubleshooting (the -e and -X flags help); internet access or your own repository is required; verbose XML; limited flexibility for non-standard build logic.

Choosing: Maven fits when the project follows the standard "compile, test, package" flow and predictability and consistency matter. Gradle wins in large multi-module projects where build speed is critical, and in Android development. For a beginner, Maven is a sensible start: Gradle reuses its terminology (GAV, scope, repositories).

Page 1 of 1