Maven Flashcards
What is Maven?
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.
What is the POM?
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
What are the elements of a project’s coordinates?
groupid
artifactid
version
What are the different Maven build lifecycles?
default (aka build), clean, site
What are the phases of the default lifecycle?
validate, compile, test, package, integration-test, verify, install, deploy
What would the command mvn clean do?
This command removes the target directory with all the build data before starting the build process.
What is a goal?
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.
What is an archetype?
Archetype is a Maven plugin whose task is to create a project structure as per its template.
What is a dependency?
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 do you perform a build with Maven?
In command prompt: mvn [options] [goal(s)] [phase(s)]
What is a Maven repository? What are the local and central repositories?
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/.
What is the default location of your local repository?
~/.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.
What is a SNAPSHOT?
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 do you install a JAR file to your local repository?
“mvn install:install-file -Dfile={Path/to/your/jar.jar} -DgroupId=com.example -DartifactId=artifact -Dversion=1.0.0 -Dpackaging=jar”
What is the command to create a new project based on an archetype?
mvn archetype:generate -DgroupId=[your project’s group id] -DartifactId=[your project’s artifact id] -DarchetypeArtifactId=maven-archetype-archetype