Maven Interview Questions And Answers
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 are the aspects Maven manages?
Maven provides developers ways to manage following:
- Mailing list
What are the phases of a Maven Build Lifecycle?
|validate||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 using 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 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.|
What is difference between Snapshot and Version?
In case of Version, if Maven once downloaded the mentioned version say data-service:1.0, it will never try to download a newer 1.0 available in repository. To download the updated code, data-service version is be upgraded to 1.1.
In case of SNAPSHOT, Maven will automatically fetch the latest SNAPSHOT (data-service:1.0-SNAPSHOT) everytime app-ui team build their project.
What are the advantages of Maven?
- No need to add jar file in each project
- Creates right directory structure
- Builds and deploys the project
What it does?
Maven simplifies the above mentioned problems. It does mainly following tasks.
It makes a project easy to build
It provides uniform build process (maven project can be shared by all the maven projects)
It provides project information (log document, cross referenced sources, mailing list, dependency list, unit test reports etc.)
It is easy to migrate for new features of Maven
Apache Maven helps to manage
What features should a build tool have?
A build tool should have:
- Compile java code and build jar, war and ear files for deployment and release.
- Versioning and dependency management
- Run tests and report test results
- Run code quality check with Sonar, Checkstyle, Findbugs, etc.
- Environment property substitution
- Files generations ( wsdl, AspectJ, XSL,etc)
- Support for cross platform (UNIX Windows) and IDEs(eclipse, Netbeasn, Intellij)
- Proper documentation and support.
What is a transitive dependency in Maven?
Transitive dependency in Maven means that it is not necessary to discover and specify the libraries that our own dependencies require, Maven includes them automatically.
What is the difference between version and SNAPSHOT ?
Maven will download always the specified version. In case of SNAPSHOT Maven will download the latest SNAPSHOT.
What is a Mojo?
A mojo is a Maven plain Old Java Object . Mojo is associated with a Maven goal. A custom plugin is a set of related Mojos (or goals) in a single plugin artifact.
What does the Maven command mvn clean do?
This command erase the target directory with all the build data before starting the building process.