Professional Documents
Culture Documents
RT Maven PDF
RT Maven PDF
In Maven, there is no need to store the binary libraries (third party) within the source
control.
It provides better co-operation among the source code, plugin, libraries, and the IDE.
Maven can add all the dependencies required for the project automatically by reading
pom file.
One can easily build their project to jar,war etc. as per their requirements using Maven.
Maven makes easy to start project in different environments and one doesn’t needs to
handle the dependencies injection, builds, processing, etc.
Adding a new dependency is very easy. One has to just write the dependency code in
pom file
When there are a lot of dependencies for the project. Then it is easy to handle those
dependencies using maven.
When dependency version update frequently. Then one has to only update version ID in
pom file to update dependencies.
Continuous builds, integration, and testing can be easily handled by using maven.
When one needs an easy way to Generating documentation from the source code,
Compiling source code, Packaging compiled code into JAR files or ZIP files.
Maven Repositories
A maven repository is a directory of packaged JAR file with pom.xml file. Maven searches for
dependencies in the repositories. There are 3 types of maven repository:
1. Local Repository
2. Central Repository
3. Remote Repository
Local Repository: Local repository is a directory on the developer's device. The local
repository contains all of Maven's dependencies. Even though several projects rely on
dependencies, Maven only needs to download them once.
Central Repository: The Maven community has built the central Maven repository. Maven
searches this central repository for any dependencies that aren't available in your local
repository. The dependencies are subsequently downloaded into your local repository by
Maven.
Remote Repository: Maven may download dependencies from a remote repository hosted
on a web server. It is frequently used to host internal organization projects. The
dependencies are subsequently downloaded into your local repository by Maven
groupId a unique base name of the company or group that created the project
artifactId a unique name of the project. It specifies the id for the artifact (project). An artifact
is something that is either produced or used by a project. Examples of artifacts
produced by Maven for a project include: JARs, source and binary distributions, and
WARs.
version a version of the project. It specifies the version of the artifact under given group.
we can execute several build lifecycles goals, including the ones to compile the project’s
code, create a package, and install the archive file in the local Maven dependency
repository.
Lifecycle Phases
The following list shows the most important Maven lifecycle phases:
Maven is actually a plugin execution framework where every task is actually done by
plugins.
Maven Plugins are generally used to –
create jar file
create war file
compile code files
unit testing of code
create project documentation
create project reports
The directory structure of a normal idiomatic Maven project has the following directory entries:
The directory structure of a normal idiomatic Maven project has the following directory entries:
src/main/java Contains the deliverable Java source code for the project.
src/main/resources Contains the deliverable resources for the project, such as property files.
Contains the testing Java source code (JUnit or TestNG test cases, for
src/test/java
example) for the project.
The target folder is the maven default output folder. When a project is
build or packaged, all the content of the sources, resources and web files
Target
will be put inside of it, it will be used for construct the artifacts and for
run tests
Artifact in maven
Artifact: An artifact is something that is either produced or used by a project.
Artifact is the final application which has created from source code in the form of .JAR file
Examples of artifacts produced by Maven for a project include: JARs, source and binary
distributions, WARs. Dependency: A typical Java project relies on libraries to build and/or
run. Those are called “dependencies” inside Maven
Jenkins Maven
Jenkins is an open-source continuous A Maven is a build tool which helps in build and
integration software tool. It was written for version control.
testing and reporting.
Jenkins is integrated with Slack, Datadog, Maven is integrated with tools Buddy, Flyway,
BrowserStack, etc. tools. JitPack, SonarQube, etc.
Gradle Maven
It is a build automation system that uses a It is a software project management system that is
Groovy-based DSL (domain-specific language ) primarily used for java projects.
It does not use an XML file for declaring the It uses an XML file for declaring the project, its
project configuration. dependencies, the build order, and its required plugin.
It is based on a graph of task dependencies It is based on the phases of the fixed and linear model.
that do the work.
In Gradle, the main goal is to add functionality In maven, the main goal is related to the project phase.
to the project.
It avoids the work by tracking input and It does not use the build cache; thus, its build time is
output tasks and only runs the tasks that have slower than Gradle.
been changed. Therefore it gives a faster
performance.
Gradle is highly customizable; it provides a Maven has a limited number of parameters and
wide range of IDE support custom builds. requirements, so customization is a bit complicated.
Ant Maven
Ant doesn't has formal conventions, so we Maven has a convention to place source code,
need to provide information of the project compiled code etc. So we don't need to provide
structure in build.xml file. information about the project structure in
pom.xml file.
Ant is procedural, you need to provide Maven is declarative, everything you define in
information about what to do and when to do the pom.xml file.
through code. You need to provide order.
It is a toolbox It is a framework
The ant scripts are not reusable The maven plugins are reusable
Maven Commands
mvn clean. This command cleans the maven project by deleting the target directory
mvn compiler:compile. This command compiles the java source classes of the maven
project
mvn compiler:testCompile
mvn package
mvn install
mvn deploy
mvn validate
mvn dependency:tree
Shubhankar Pawar
+ 91-8828360046