Build Automation Basics: Maven, Gradle u0026 npm Essentials Quiz

Explore core concepts of build automation tools, focusing on Maven, Gradle, and npm. This quiz evaluates your understanding of dependency management, configuration files, build lifecycles, and typical commands for streamlined software development.

  1. Dependency Management in Maven

    Which file is used by Maven to manage a project's dependencies and configuration settings?

    1. package.json
    2. pom.xml
    3. build.gradle
    4. Makefile

    Explanation: Maven uses the pom.xml file to handle project dependencies, plugins, and other configuration settings. build.gradle is specific to Gradle, and package.json is used for npm-based projects. Makefile is associated with a different build tool altogether and is not used by Maven.

  2. Gradle Build Scripts

    When using Gradle for Java project builds, what is the default name of the build script file?

    1. npmfile.json
    2. pom.xml
    3. build.gradle
    4. build.maven

    Explanation: The build.gradle file contains instructions for building and managing Gradle projects, including dependencies and build tasks. pom.xml is for Maven, npmfile.json is not a standard file, and build.maven is not a recognized build script filename.

  3. npm Package Management

    Which file must exist in an npm project to declare metadata, scripts, and dependencies?

    1. project.xml
    2. build.npm
    3. package.json
    4. npm.config

    Explanation: npm relies on package.json to define metadata, dependencies, and scripts for a project. npm.config is not an official declaration file, project.xml is unrelated, and build.npm is not a recognized configuration file.

  4. Lifecycle Phases in Maven

    What phase in Maven's default lifecycle compiles the source code of the project?

    1. install
    2. make
    3. compile
    4. execute

    Explanation: The compile phase in Maven's lifecycle is responsible for compiling the source code. execute is not a Maven phase, make refers to a different tool, and install is a later Maven phase that installs the built artifact into the local repository.

  5. Gradle Wrapper Purpose

    What is the primary purpose of the Gradle Wrapper in a project?

    1. To define npm scripts
    2. To store project dependencies
    3. To ensure builds use a specific Gradle version
    4. To generate lock files

    Explanation: The Gradle Wrapper helps ensure that all users and automation servers use the exact Gradle version required for the project. Storing dependencies is managed separately, npm scripts are unrelated, and lock files are not the main focus of the wrapper.

  6. Updating npm Dependencies

    Which command is typically used to update all dependencies in an npm project to their latest versions?

    1. npm update
    2. npm install
    3. npm upgrade
    4. npm refresh

    Explanation: The npm update command updates packages in the node_modules folder to the latest satisfying versions defined by package.json. npm install installs missing or updated dependencies, npm upgrade is not a valid command, and npm refresh does not exist.

  7. Gradle Build Configuration Language

    What language is typically used for writing build scripts in Gradle by default?

    1. XML
    2. Ruby
    3. Groovy
    4. JSON

    Explanation: Gradle build scripts are commonly written in Groovy, a dynamic language for the Java platform. XML is used in Maven, JSON is used in npm, and Ruby is not a default scripting language for Gradle.

  8. Project Initialization with Maven

    Which command initializes a new Java project with Maven using a predefined template (archetype)?

    1. mvn archetype:generate
    2. maven setup
    3. mvn install
    4. build init

    Explanation: The mvn archetype:generate command initializes a new Maven project using a specified archetype as a template. mvn install is for building and installing artifacts, build init is used by Gradle, and maven setup is not a standard command.

  9. Role of package-lock.json

    What is the main purpose of the package-lock.json file in an npm project?

    1. To contain code formatting rules
    2. To document the usage of all packages
    3. To ensure consistent dependency versions are installed
    4. To store deployment scripts

    Explanation: package-lock.json locks the exact versions of installed dependencies, providing consistency across environments. Code formatting rules are stored elsewhere, and deployment scripts or package usage documentation are not functions of this file.

  10. Gradle Build Task Execution

    If you want to clean compiled files before building in Gradle, which command sequence should you use?

    1. gradle install compile
    2. build clean gradle
    3. gradle clean build
    4. gradle build clean

    Explanation: The correct sequence is gradle clean build, which first removes build outputs and then rebuilds the project. gradle install compile is not standard and may not exist, build clean gradle is misordered, and gradle build clean reverses the intended order.