Maven Flashcards

1
Q

What is Maven?

A

Maven is a project management and comprehension tool. Maven provides developers a complete build lifecycle framework. Development team can automate the project’s build infrastructure in almost no time as Maven uses a standard directory layout and a default build lifecycle.

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

What is the POM?

A

POM stands for Project Object Model. It is fundamental Unit of Work in Maven. It is an XML file. It always resides in the base directory of the project as pom.xml. It contains information about the project and various configuration details used by Maven to build the project(s). POM contains the some of the following configuration information − project dependencies, plugins, goals, build profiles, project version, developers, mailing list

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

What are the elements of a project’s coordinates?

A

groupid
artifactid
version

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

What are the different Maven build lifecycles?

A

default (aka build), clean, site

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

What are the phases of the default lifecycle?

A

validate, compile, test, package, integration-test, verify, install, deploy

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

What would the command mvn clean do?

A

This command removes the target directory with all the build data before starting the build process.

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

What is a goal?

A

A goal represents a specific task which contributes to the building and managing of a project. It may be bound to zero or more build phases. A goal not bound to any build phase could be executed outside of the build lifecycle by direct invocation.

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

What is an archetype?

A

Archetype is a Maven plugin whose task is to create a project structure as per its template.

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

What is a dependency?

A

A dependency is an artifact that Maven will include as part of the build. This is analogous to including JAR files in your classpath in an Eclipse build.

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

How do you perform a build with Maven?

A

In command prompt: mvn [options] [goal(s)] [phase(s)]

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

What is a Maven repository? What are the local and central repositories?

A

A repository is a place i.e. directory where all the project jars, library jar, plugins or any other project specific artifacts are stored and can be used by Maven easily. Maven local repository is a folder location on your machine. It gets created when you run any maven command for the first time. Maven local repository keeps your project’s all dependencies (library jars, plugin jars etc). It is repository provided by Maven community. It contains a large number of commonly used libraries. When Maven does not find any dependency in local repository, it starts searching in central repository using following URL: http://repo1.maven.org/maven2/.

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

What is the default location of your local repository?

A

~/.m2/repository. This can be changed by editing the conf/settings.xml file in the Maven directory and changing the value in the tag to a custom location.

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

What is a SNAPSHOT?

A

SNAPSHOT is a special version that indicates a current development copy. Unlike regular versions, Maven checks for a new SNAPSHOT version in a remote repository for every build.

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

How do you install a JAR file to your local repository?

A

“mvn install:install-file -Dfile={Path/to/your/jar.jar} -DgroupId=com.example -DartifactId=artifact -Dversion=1.0.0 -Dpackaging=jar”

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

What is the command to create a new project based on an archetype?

A

mvn archetype:generate -DgroupId=[your project’s group id] -DartifactId=[your project’s artifact id] -DarchetypeArtifactId=maven-archetype-archetype

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

What is the use of the execution element in the POM file?

A

The execution element contains information’s required for the execution of a plugin.

17
Q

In what order does Maven resolve dependencies?

A

“1 − Search dependency in local repository, if not found, move to step 2 else if found then do the further processing. 2 − Search dependency in central repository, if not found and remote repository is mentioned then move to step 4 else if found, then it is downloaded to local repository for future reference. 3 − If a remote repository has not been mentioned, Maven simply stops the processing and throws error 4 − Search dependency in remote repository or repositories, if found then it is downloaded to local repository for future reference “