Maven Flashcards

1
Q

What are Maven Project co-ordinates ?

A

groupId, artifactId and version
they should be unique to a project and all projects require them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a groupId ?

A

often the reverse domain name
e.g. com.company.bank
usually unique to an organisation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a projectId ?

A

the name of the project

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is the version ?

A

It is used within an artifact’s repository to separate versions from each other. For example −

com.company.bank:consumer-banking:1.0

com.company.bank:consumer-banking:1.1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the Super POM ?

A

The Super POM is Maven’s default POM. All POMs inherit from a parent or default (despite explicitly defined or not). This base POM is known as the Super POM, and contains values inherited by default.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an effective POM ?

A

the effective POM is when you combine the project POM with the POM inherited from a Parent POM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a Build Lifecycle ?

A

It is a well defined ordered sequence of phases .
In each phase, goals (means tasks) are executed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a Maven goal ?

A

A goal represents a specific task which contributes to the building and managing of a project.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the three standard Maven Lifecycles ?

A

clean, build (default), site

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the default Maven lifecycle ?

A

build

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

A Lifecycle consists of Phases. What Phases are present in the Clean Lifecycle ?

A

pre-clean
clean
post-clean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is <repositories> used for in the POM ?</repositories>

A

Sometimes, Maven does not find a mentioned dependency in central repository as well. It then stops the build process and output error message to console. To prevent such situation, Maven provides concept of Remote Repository, which is developer’s own custom repository containing required libraries or other project jars.

<repositories>
<repository>
<id>companyname.lib1</id>
<url>http://download.companyname.org/maven2/lib1</url>
</repository>
<repository>
<id>companyname.lib2</id>
<url>http://download.companyname.org/maven2/lib2</url>
</repository>
</repositories>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a Maven Plugin ?

A

The Maven Plugin is what actually executes the Mavel goal (performs the task at hand)
to execute the syntax would be
mvn [plugin-name]:[goal-name]

e.g. mvn compiler:compile

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a Milestone version vs Snapshot version ?

A

Maven versions come in two flavors: snapshots and milestones. Snapshots have a version but end in -SNAPSHOT or -LATEST. Everything else falls into the milestone category. Milestones are unmodifiable. Snapshots can be changed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Explain what is Maven? How does it work?

A

Maven is a project management tool. It provides the developer a complete build lifecycle framework. On executing Maven commands, it will look for POM file in Maven; it will run the command on the resources described in the POM.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

List out what are the aspects does Maven Manages?

A

Maven handles following activities of a developer

Build
Documentation
Reporting
Dependencies
SCMs
Releases
Distribution
Mailing list

17
Q

Mention the three build lifecycle of Maven?

A

Clean: Cleans up artifacts that are created by prior builds
Default (build): Used to create the application
Site: For the project generates site documentation

18
Q

Explain what is Maven artifact?

A

Usually an artifact is a JAR file which gets arrayed to a Maven repository. One or more artifacts a maven build produces such as compiled JAR and a sources JAR.

Each artifact includes a group ID, an artifact ID and a version string.

19
Q

Explain what is Maven Repository? What are their types?

A

A Maven repository is a location where all the project jars, library jars, plugins or any other particular project related artifacts are stored and can be easily used by Maven.

Their types are local, central and remote

20
Q

List out the dependency scope in Maven?

A
  • Compile: It is the default scope, and it indicates what dependency is available in the classpath of the project
  • Provided: It indicates that the dependency is provided by JDK or web server or container at runtime
  • Runtime: This tells that the dependency is not needed for compilation but is required during execution
  • Test: It says dependency is available only for the test compilation and execution phases
  • System: It indicates you have to provide the system path
  • Import: This indicates that the identified or specified POM should be replaced with the dependencies in that POM’s sectio
21
Q

Mention how profiles are specified in Maven?

A

Profiles are specified in Maven by using a subset of the elements existing in the POM itself.

22
Q

Explain how you can exclude dependency?

A

By using the exclusion element, dependency can be excluded

23
Q

In Maven what are the two setting files called and what are their location?

A

In Maven, the setting files are called settings.xml, and the two setting files are located at

Maven installation directory: $M2_Home/conf/settings.xml
User’s home directory: ${ user.home }/ .m2 / settings.xml

24
Q

List out what are the build phases in Maven?

A

Build phases in Maven are

Validate
Compile
Test
Package
Install
Deploy

25
Q

List out the build, source and test source directory for POM in Maven?

A

Build = Target
Source = src/main/java
Test = src/main/test

26
Q

Explain what would the “jar: jar” goal do?

A

jar: jar will not recompile sources; it will imply just create a JAR from the target/classes directory considering that everything else has been done

27
Q

List out what are the Maven’s order of inheritance?

A

The maven’s order of inheritance is

Parent Pom
Project Pom
Settings
CLI parameters

28
Q

Explain how you can produce execution debug output or error messages?

A

To produce execution debug output you could call Maven with X parameter or e parameter.

29
Q

GITExplain how to run test classes in Maven?

A

To run test classes in Maven, you need surefire plugin, check and configure your settings in setting.xml and pom.xml for a property named “test.”