Explore the key concepts, structure, and features of Apache Maven, including POM elements, conventions, dependency management, and multi-module builds.
Where does Maven expect your main source code to be located by default?
Explanation: Maven relies on conventions, placing main source code in 'src/main/java' by default. The other listed directories do not match Maven's standard structure and would require special configuration.
Which file acts as the blueprint and core configuration file for a Maven project?
Explanation: The 'pom.xml' file defines the Maven project's configuration. 'build.gradle' belongs to Gradle, and 'settings.cfg' and 'manifest.json' are unrelated to Maven.
What does 'artifactId' represent in the Maven POM's GAV coordinates?
Explanation: 'artifactId' specifies the base name of the main output artifact. 'groupId' is for the organization, 'version' is the artifact version, and test resources have their own configuration.
In Maven, what does setting a dependency's scope to 'test' mean?
Explanation: A 'test' scope makes the dependency available only during the test phase. Production builds exclude these. Dependencies are not unused or overriding all scopes.
What is the default directory where Maven places compiled build output?
Explanation: By default, Maven puts compiled classes and packaged artifacts into 'target/'. The other directory names are common in other tools but not in Maven's conventions.
Which XML tag wraps the complete set of libraries a Maven project relies on?
Explanation: <dependencies> is the container for all external libraries. <plugins> is for build tools, <modules> for subprojects, and <properties> for variable values.
How can you re-use a version number across different dependencies in the Maven POM?
Explanation: Using <properties> lets you define a version once and reference it throughout. Hard-coding loses maintainability, <module> is unrelated to versions, and Maven needs explicit setup for this feature.
Which tag in the build section of the POM allows you to set the output file's name?
Explanation: <finalName> customizes the generated artifact's name. <id> is used elsewhere, <scope> is for dependency usage, and <phase> relates to lifecycle execution.
Which tag lists all sub-projects in a Maven multi-module build?
Explanation: <modules> enumerates child modules to be built together. <parent> declares inheritance, <artifactId> is for naming, and <plugin> is for build tools.
How can a parent POM control dependency versions for its child modules without including the dependencies themselves?
Explanation: <dependencyManagement> centrally defines versions for dependencies used by child modules. <dependencies> actually includes libraries, <resource> and <build> are not for managing versions.