Apache Maven is a software project management and comprehension tool. A build automation tool that helps managing the software build lifecycle.
- Maven artifact
Each artifact has a group ID , an artifact ID (artifact name) and a version string.
- Types of maven repository.
- Build phases in Maven
- Explain the highlevel directory structure of a maven project
<b>Source:</b> folder usually src/main/java holds java source codes.
<b>Test:</b> directory is src/main/test that has all the unit testing codes.
- What jar:jar goal does?
- What are the minimum requirements for a POM?
- Can we use different name for POM.xml?
- How do you rename a maven project?
2) Update the artifactId in your pom.xml
- maven repository central
- POM
- Maven Repository
- Why Maven is used?
- Where do we find .class files of a Maven project?
- Difference between compile and install.
- What is a Maven project's fully qualified artifact name?
- Order by which Maven searches for the dependency.
- groupId
- artifactId
- Explain the difference phases in Maven build Lifecycle.
<b>compile</b> - compile the source code of the project.
<b>test</b> - tests the compiled source code using a suitable unit testing framework. These tests does not require the code to be packaged or deployed.
<b>package</b> - take the compiled code and package it to its distributable format, for example, JAR.
<b>verify</b> - runs any checks on results of integration tests to ensure desired quality criteria are met.
<b>install</b> - installs the package into the local repository, for using it as a dependency in other projects locally.
<b>deploy</b> - performed in the build environment, copies the final package to the remote repository for sharing and collaboration with other members of the team and projects.
- How do I specify packaging/distributable format in Maven?
Some of the valid packaging values are jar, war, ear and pom. If no packaging value has been specified, it will default to jar.
<project xmlns="https://maven.apache.org/POM/4.0.0"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
...
<packaging>war</packaging>
...
</project>
- How Maven searches for dependency JAR?
- Explain package phase in Maven build lifecycle.
- What are the build lifecycles of Maven?
- What is local repository in Maven?
- What is Maven Central Repository?
- Explain Maven remote repository
- How do I include dependencies in a jar using Maven?
- Configuring resource directories in Maven.
- Difference between repository and dependency in Maven.
- What is an Archetype in Maven framework?
- What is goal in Maven?
-
package phase pulls the compiled code and package it to a distributable format, such as a JAR.
The below is the command to package a maven project.
mvn -package
The default lifecycle handles your project deployment.
the clean lifecycle handles project cleaning.
the site lifecycle handles the creation of the project's site documentation.
By default, maven local repository is %USER_HOME%/.m2 directory.
We can change the location of maven local repository by changing the settings.xml file. It is located in MAVEN_HOME/conf.
The path of central repository is: https://repo1.maven.org/maven2/.
A "remote" repository may also be an internal repository set up on a file or HTTP server within an organization, used to share private artifacts between development teams and for releases.
mvn archetype:generate