Flashcards
Maven
Cards in this deck (30)
- 1What is Maven?Maven is an automation and management tool developed by Apache Software Foundation.
It allows us to create projects, dependency, and documentation using Project Object Model and plugins.
It can also build any number of projects into desired output such as jar, war, metadata. - 2Do you know in which language Maven was written?Maven is a build automation tool used primarily for Java projects.
Maven can also be used to build and manage projects written in C#, Ruby, Scala, and other languages. - 3How do you think Maven helps the developer?It actually helps the developer to create the Java project in an easy way.
Accessibility of new feature created or added in Maven can be easily added to a project in Maven configuration that will increases the performance of project and building process.
Apart from all these the main feature of Maven is that it can download the project dependency libraries automatically. - 4Can you list out the processes which can be managed using Maven?Builds, Documentation, Reporting, Dependencies, SCMs, Releases, Distribution, mailing list
- 5Can u explain a bit about how to use Maven?To configure the Maven in Java, you need to use Project Object Model, which is stored in a pom.xml-file.
POM includes all the configuration setting related to Maven. Plugins can be configured and edit in the tag of a pom.xml file and developer can use any plugin without much detail of each plugin.
When user start working on Maven Project, it provides default setting of configuration, so the user does not need to add every configuration in pom.xml. - 6What is your understanding about the saying Maven uses Convention over Configuration?Maven uses Convention over Configuration which means developers are not required to create build process themselves. and they don’t have to mention each and every configuration details.
- 7What is Maven Build Lifecycle?A Build lifecycle is a well-defined sequence of phases that outline the order in which the goals are to be executed. Here phase represents a stage in the life cycle.
- 8Can you tell me the build lifecycle of Maven?The three build lifecycles are:
Clean: cleans up artifacts created by previous builds.
Default (or build): this can be accustomed to build the appliance.
Site: generates site documentation for the project. - 9Could you tell me a little bit about the Maven artifact?An artifact is a file, usually a JAR that gets deployed to a Maven repository. A Maven build produces one or more artifacts, such as a compiled JAR and a sources JAR.
Each artifact has a group ID, an artifact ID , and a version string. The three together uniquely identify the artifact. A project's dependencies are specified as artifacts. - 10What are the phases of a Maven build lifecycle?validate : the project is correct and all necessary information is available.
compile : compile the source code of the project.
test : test the compiled source code with a suitable unit testing framework. These tests should not require the code be packaged or deployed.
package : take the compiled code and package it in its distributable format, such as a JAR.
integration-test : process and deploy the package if necessary, into an environment where integration tests can be run.
verify : run any checks to verify whether the package is valid and meets quality criteria.
install : install the package into the local repository, for use as a dependency in other projects locally.
deploy : done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects. - 11What phases does a clean lifecycle consist of?The clean lifecycle consists of the following phases:
pre-clean.
clean.
post-clean. - 12What phases does a site lifecycle consist of?The phases in site lifecycle are:
pre-site
site
post-site
site-deploy - 13What are the two setting files called in Maven called and what are their locations?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 - 14Can you tell what the "jar: jar" goal would do?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.
- 15Can you list out what the Maven’s order of inheritance is?The maven’s order of inheritance is
Parent Pom
Project Pom
Settings
CLI parameters - 16Do you know how to run test classes in Maven?To run test classes in Maven, we need surefire plugin, and we need to check and configure our settings in setting.xml and pom.xml for a property named test.
- 17How to install Maven?Make sure JDK is installed, and JAVA_HOME the variable is added as a Windows environment variable. Add both M2_HOME and MAVEN_HOME variable in the Windows environment and point it to your Maven folder.
- 18What are the archetype goals?Four goals associated with archetype plugin:
Create : creates using a quick-start template.
Generate : provide a menu of templates.
Create-from-project creates an archetype from an existing project.
Crawl : searches the repository for archetype and updates catalog. - 19Do you know about Parent POM's?Basically, these are parent projects without code used by companies to define the set of libraries/versions, plugins they want their teams using. It can have dependencies, build plugins, variables definitions, and even their own parent POM, forming a chain.
A great example is Spring Boot. You can extract it to create production-grade web services crazily fast. - 20What is a system dependency?Dependency with reach system is always accessible and is not looked up in the repository. They are regularly used to tell Maven about dependencies that are provided by the JDK. So, system dependencies are mainly useful for resolving dependencies on artefacts that JDK usually provides.
- 21How does Maven looks for a dependency or resource ?It refers to the settings.xml to look for the repositories to look for the resource. It first looks into the configured local repository, then it looks into the configured remote repositories. If the resource is still not found , it looks it within maven repository central i.e., repo1.maven.org. If it’s still not found, it throws the exception saying Unable to find resource in repository central.
- 22How can we look into the Dependencies for the project and where they are defined ?Using mvn dependency:tree
- 23What are the different types of Maven Repositories?There are three types of Maven repositories:
Local Repository:
Local repository refers to the machine of the developer where all the project material is saved. The local repository contains all the dependency jars.
Remote Repository:
The remote repository refers to the repository present on a server usually in company intranet to download dependencies.
The advantage of remote repository is that it can have all publicly available dependencies as well as private dependencies used only in intranet by employees of the enterprise.
Central Repository:
Central repository refers to the Maven community that comes into action when there is a need for dependencies, and those dependencies cannot be found in the local repository.
Maven downloads the dependencies from here in the local repository whenever needed. - 24What are the types of Maven Plugins?There are two types of Maven Plugins:
Build plugins : These plugins are executed during the build and are configured in the element of pom.xml
Reporting plugins : These plugins are executed during the stage generation and are configured in the element of the pom.xml. - 25What is meant by the term Dependencies and Repositories in Maven?Dependencies refer to the Java libraries that are needed for the project. Repositories refer to the directories of packaged JAR files. If the dependencies are not present in your local repository; then Maven downloads them from a central repository and stores them in the local repository.
- 26Why do we need Optional dependencies?Optional dependencies are used to decrease the transitive burden of some libraries.
These dependencies are used when it is not feasible to divide a project into sub-modules.
Some dependencies are only used for a specific feature in the project, and if that feature is not there, then that dependency will not be used. - 27Do you know where the Maven dependencies got stored?All the JARS, dependency files, etc. that are downloaded by Maven are saved in the Maven local repository.
The Maven local repository is a folder location on the local system where all the artifacts are locally stored. - 28How will you install JAR files in the Local Repository?mvn install is used to install JAR files in the local repository. To install the JAR manually into the local Maven repository, the following plugin is used: mvn install:install-file-Dfile=.
- 29How will you create a new project based on an archetype?Creating a project from an archetype consists of four steps:
Refer to the repository.
selecting an archetype.
the configuration of that archetype.
the project’s efficient creation based on the data collected. - 30Can u explain a bit about Snapshot in Maven?Snapshot refers to the version available in the Maven remote repository. It signals the latest development copy. Maven inspects for a new version of Snapshot in the remote repository, for every new build. The snapshot is updated by the data service team with an updated source code every time to the repository for each Maven build.