0% found this document useful (0 votes)
3 views4 pages

Maven and Gradle Build Tools Guide

Maven and Gradle are build automation tools used for managing Java projects, with Maven using XML for configuration and Gradle using Groovy/Kotlin. Key features include dependency management, build lifecycle, and plugin support for Maven, while Gradle offers flexibility and faster performance. JUnit is a testing framework for Java, with annotations for defining tests and features for parameterized testing and integration with both Maven and Gradle.

Uploaded by

rajmayank1121
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Maven and Gradle Build Tools Guide

Maven and Gradle are build automation tools used for managing Java projects, with Maven using XML for configuration and Gradle using Groovy/Kotlin. Key features include dependency management, build lifecycle, and plugin support for Maven, while Gradle offers flexibility and faster performance. JUnit is a testing framework for Java, with annotations for defining tests and features for parameterized testing and integration with both Maven and Gradle.

Uploaded by

rajmayank1121
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

1. What is Maven?

Maven is a build automation and dependency management tool primarily used for Java
projects.

2. What is the [Link] file?


The Project Object Model ([Link]) is the configuration file in a Maven project
that manages dependencies, plugins, and project metadata.

3. What are Maven’s core features?

Dependency management

Build lifecycle

Plugin support

Project management

4. What is a Maven dependency?


A JAR file or library your project needs. Declared in [Link] and automatically
downloaded.

5. What is the Maven repository?


A storage location for project artifacts. Types include:

Local (~/.m2/repository)

Central (Maven Central)

Remote (Custom or third-party)

6. What is the difference between compile, provided, and runtime scopes?

compile: Available at compile and runtime

provided: Provided by container (e.g., servlet API)

runtime: Needed only during runtime

7. How do you run Maven builds?


Use commands like mvn clean install, mvn test, mvn package.

8. What are Maven plugins?


Tools that add capabilities like compilation, packaging, testing, etc. Example:
maven-compiler-plugin.

9. How can you skip tests in Maven?

mvn install -DskipTests

10. What is the Maven build lifecycle?


Phases:

validate

compile

test
package

verify

install

deploy

11. What is Gradle?


Gradle is a flexible, modern build automation tool that supports Java, Kotlin,
Groovy, and more.

12. What is [Link]?


The main configuration file in a Gradle project that defines tasks, dependencies,
and plugins.

13. How does Gradle differ from Maven?

Feature Maven Gradle


Language XML Groovy/Kotlin
Performance Slower Faster (incremental builds)
Flexibility Convention-based Highly customizable

14. What are Gradle tasks?


Units of work (e.g., compile, test) that can be executed independently.

15. How do you run a Gradle build?

gradle build

16. What is the Gradle wrapper?


A script (gradlew) that allows running Gradle builds with a specific Gradle version
without installing it.

17. How do you declare dependencies in Gradle?

dependencies {
implementation '[Link]:spring-boot-starter'
}

18. What is [Link]?


Used in multi-project builds to define included modules.

19. How can you exclude a transitive dependency in Gradle?

implementation('group:module') {
exclude group: '[Link]', module: 'unwanted-module'
}

20. How do you skip tests in Gradle?

gradle build -x test

21. What is JUnit?


A testing framework for Java used to write and run repeatable unit tests.
22. What are the main annotations in JUnit 5?

@Test: Marks a test method

@BeforeEach: Runs before each test

@AfterEach: Runs after each test

@BeforeAll: Static method run before all tests

@AfterAll: Static method run after all tests

23. What is the difference between JUnit 4 and JUnit 5?

JUnit 5 uses [Link]

Supports lambda expressions

Better extension model

24. How do you write a simple JUnit test?

@Test
void testAddition() {
assertEquals(4, 2 + 2);
}

25. What is assertEquals in JUnit?


Asserts that two values are equal:

assertEquals(expected, actual);

26. How can you disable a test?


Use @Disabled annotation.

27. How do you run only specific tests?


Use test filters in build tools or specify method/class in IDE.

28. What is a test suite in JUnit?


A collection of tests that run together.

29. How do you integrate JUnit with Maven or Gradle?

Maven:

<dependency>
<groupId>[Link]</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.9.1</version>
</dependency>

Gradle:

testImplementation '[Link]:junit-jupiter:5.9.1'
30. What is parameterized testing in JUnit?
Allows running the same test with different inputs using @ParameterizedTest.

You might also like