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.
In case of multiple development teams environment, Maven can set-up the way to work as per standards in a very short time.
1) Maven provides developers ways to manage following:
Builds
Documentation
Reporting
Dependencies
SCMs
Releases
Distribution
mailing list
2) Maven Objective :
A comprehensive model for projects which is reusable, maintainable, and easier to comprehend.
Plugins or tools that interact with this declarative model.
3) Convention over Configuration:
Maven uses Convention over Configuration which means developers are not required to create build process themselves.
Developers do not have to mention each and every configuration detail.
Maven provides sensible default behavior for projects.
When a Maven project is created, Maven creates default project structure.
Developer is only required to place files accordingly and he/she need not to define any configuration in pom.xml.
4) 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.
POM file containing.
project dependencies
plugins
goals
build profiles
project version
developers
mailing list
Before creating a POM, We should first decide the project group (groupId),
Its name(artifactId) and its version as these attributes help in uniquely identifying the project in repository.
Example POM
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.companyname.project-group</groupId>
<artifactId>project</artifactId>
<version>1.0</version>
</project>
All POM files require the project element and three mandatory fields: groupId, artifactId,version.
Projects notation in repository is groupId:artifactId:version.
Root element of POM.xml is project and it has three major sub-nodes :
GroupId
This is an Id of project's group. This is generally unique amongst an organization or a project.
For example, a banking group com.company.bank has all bank related projects.
ArtifactId
This is an Id of the project.This is generally name of the project.
For example, consumer-banking. Along with the groupId, the artifactId defines the artifact's location within the repository.
Version
This is the version of the project.Along with the groupId, It is used within an artifact's repository to separate versions from each other. For example: com.company.bank:consumer-banking:1.0
com.company.bank:consumer-banking:1.1.
mvn help:effective-pom --> Super POM
5) Example for POM:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/
2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 h
ttp://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.companyname.project-group</groupId>
<artifactId>project</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>C:\MVN\project\src\main\java</sourceDirectory>
<scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
<testSourceDirectory>C:\MVN\project\src\test\java</testSourceDirectory>
<outputDirectory>C:\MVN\project\target\classes</outputDirectory>
<testOutputDirectory>C:\MVN\project\target\test-classes</testOutputDirectory>
<resources>
<resource>
<mergeId>resource-0</mergeId>
<directory>C:\MVN\project\src\main\resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<mergeId>resource-1</mergeId>
<directory>C:\MVN\project\src\test\resources</directory>
</testResource>
</testResources>
<directory>C:\MVN\project\target</directory>
<finalName>project-1.0</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
</plugin>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-help-plugin</artifactId>
<version>2.1.1</version>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<reporting>
<outputDirectory>C:\MVN\project\target/site</outputDirectory>
</reporting>
</project>
In above pom.xml , you can see the default project source folders structure,output directory, plug-ins required, repositories, reporting directory which Maven will be using while executing the desired goals.
6) What is Build Lifecycle?
prepare-resources
compile
package
install
Maven has following three standard lifecycles:
clean
default(or build)
site
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.
In case of multiple development teams environment, Maven can set-up the way to work as per standards in a very short time.
1) Maven provides developers ways to manage following:
Builds
Documentation
Reporting
Dependencies
SCMs
Releases
Distribution
mailing list
2) Maven Objective :
A comprehensive model for projects which is reusable, maintainable, and easier to comprehend.
Plugins or tools that interact with this declarative model.
3) Convention over Configuration:
Maven uses Convention over Configuration which means developers are not required to create build process themselves.
Developers do not have to mention each and every configuration detail.
Maven provides sensible default behavior for projects.
When a Maven project is created, Maven creates default project structure.
Developer is only required to place files accordingly and he/she need not to define any configuration in pom.xml.
4) 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.
POM file containing.
project dependencies
plugins
goals
build profiles
project version
developers
mailing list
Before creating a POM, We should first decide the project group (groupId),
Its name(artifactId) and its version as these attributes help in uniquely identifying the project in repository.
Example POM
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.companyname.project-group</groupId>
<artifactId>project</artifactId>
<version>1.0</version>
</project>
All POM files require the project element and three mandatory fields: groupId, artifactId,version.
Projects notation in repository is groupId:artifactId:version.
Root element of POM.xml is project and it has three major sub-nodes :
GroupId
This is an Id of project's group. This is generally unique amongst an organization or a project.
For example, a banking group com.company.bank has all bank related projects.
ArtifactId
This is an Id of the project.This is generally name of the project.
For example, consumer-banking. Along with the groupId, the artifactId defines the artifact's location within the repository.
Version
This is the version of the project.Along with the groupId, It is used within an artifact's repository to separate versions from each other. For example: com.company.bank:consumer-banking:1.0
com.company.bank:consumer-banking:1.1.
mvn help:effective-pom --> Super POM
5) Example for POM:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/
2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 h
ttp://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.companyname.project-group</groupId>
<artifactId>project</artifactId>
<version>1.0</version>
<build>
<sourceDirectory>C:\MVN\project\src\main\java</sourceDirectory>
<scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
<testSourceDirectory>C:\MVN\project\src\test\java</testSourceDirectory>
<outputDirectory>C:\MVN\project\target\classes</outputDirectory>
<testOutputDirectory>C:\MVN\project\target\test-classes</testOutputDirectory>
<resources>
<resource>
<mergeId>resource-0</mergeId>
<directory>C:\MVN\project\src\main\resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<mergeId>resource-1</mergeId>
<directory>C:\MVN\project\src\test\resources</directory>
</testResource>
</testResources>
<directory>C:\MVN\project\target</directory>
<finalName>project-1.0</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.3</version>
</plugin>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-help-plugin</artifactId>
<version>2.1.1</version>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Repository Switchboard</name>
<url>http://repo1.maven.org/maven2</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
</pluginRepository>
</pluginRepositories>
<reporting>
<outputDirectory>C:\MVN\project\target/site</outputDirectory>
</reporting>
</project>
In above pom.xml , you can see the default project source folders structure,output directory, plug-ins required, repositories, reporting directory which Maven will be using while executing the desired goals.
6) What is Build Lifecycle?
prepare-resources
compile
package
install
Maven has following three standard lifecycles:
clean
default(or build)
site
No comments:
Post a Comment