Sie sind auf Seite 1von 7

MEve

Maven is a build automation tool typically used for Java projects.


Maven uses an XML file to describe the software project being built, its dependencies on other
external modules and components, the build order, directories, and required plug-ins. It comes
with pre-defined targets for performing certain well-defined tasks such as compilation of code
and its packaging.
Apache Maven is a software project management and comprehension tool.
Based on the concept of a project object model (POM), Maven can manage a
project's build, reporting and documentation from a central piece of
information.
The main improvement in Maven 3 is speed. It's been performance tuned to be 50% to 400%
faster.
Below are a number of other changes between Maven 2 and Maven 3.
Syntax: pom.xml still uses <modelVersion>4.0.0</modelVersion> so it can be a drop-in
replacement for Maven 2 projects.
Validations: poms are heavily validated against common mistakes, warns when plugin
versions are not specified (use mvn validate to see issues), blocks duplicate
dependencies (examined in same POM only, conflict resolution used otherwise).
Help URLs: wiki page URLs now shown for all error messages. One of the first Apache
projects to do this.
Removals: profiles.xml external file support removed, Maven 1.0 repository support
removed <layout>legacy</layout> (it's been 5 years since any commits to Maven 1).
Behavior: SNAPSHOTs always deployed with date-stamps, artifact resolution caching
has been improved to do less checking (override with mvn <phase> -U).
Project Object Model
A Project Object Model (POM) provides all the configuration for a single project. General
configuration covers the project's name, its owner and its dependencies on other projects. One
can also configure individual phases of the build process, which are implemented as plugins. For
example, one can configure the compiler-plugin to use Java version 1.5 for compilation, or
specify packaging the project even if some unit test fails.
Larger projects should be divided into several modules, or sub-projects, each with its own POM.
One can then write a root POM through which one can compile all the modules with a single
command. POMs can also inherit configuration from other POMs.
The pom.xml file is the core of a project's configuration in Maven. It is a single
configuration file that contains the majority of information required to build a project in
just the way you want. The POM is huge and can be daunting in its complexity, but it is not
necessary to understand all of the intricacies just yet to use it effectively.
The following are the key features of Maven in a nutshell:
* Simple project setup that follows best practices - get a new project or module started in
seconds
* Consistent usage across all projects means no ramp up time for new developers coming
onto a project
* Able to easily work with multiple projects at the same time
* Extensible, with the ability to easily write plugins in Java or scripting languages
* Instant access to new features with little or no extra configuration
* Ant tasks for dependency management and deployment outside of Maven
* Model based builds: Maven is able to build any number of projects into predefined
output types such as a JAR, WAR, or distribution based on metadata about the project,
without the need to do any scripting in most cases.
Maven's primary goal is to allow a developer:
* Making the build process easy
* Providing a uniform build system
* Providing quality project information
* Providing guidelines for best practices development
* Allowing transparent migration to new features
What is Maven Not?
You may have heard some of the following things about Maven:
* Maven is a site and documentation tool
* Maven extends Ant to let you download dependencies
* Maven is a set of reusable Ant scriptlets
How to install Maven on Windows
1. Add JAVA_HOME
Make sure you had installed JDK, and add a new JAVA_HOME into Windows environment
variable, and point to your JDK folder.

2. Download Apache Maven
Download Apache Maven zip file from this official website, e.g apache-maven-2.2.1-bin.zip.
3. Extract It
Extract the downloaded zip file, for instance, D:\maven.
Note
Thats all , no installation is required on Windows.
4. Add MAVEN_HOME
Now, add Maven folder MAVEN_HOME to Windows environment variable also.

5. Add PATH
Add the Maven bin folder into Windows environment variable, so that you can access Maven
command everywhere.

6. Verification
Done, to verify it, in command prompt, type mvn version to verify the installation detail.
C:\Documents and Settings\mkyong>mvn -version

Install apache-maven-3.0.3
set MVN_HOME & PATH in environment variables

A Build Lifecycle is Made Up of Phases
Each of these build lifecycles is defined by a different list of build phases,
wherein a build phase represents a stage in the lifecycle.
For example, the default lifecycle has the following build phases (for a
complete list of the build phases, refer to the Lifecycle Reference):
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.
Building a Project
The vast majority of Maven-built projects can be built with the following command:
mvn clean install

or

mvn clean install -Dmaven.test.skip=true

This command tells Maven to build all the modules, and to install it in the local repository. The
local repository is created in your home directory (or alternative location that you created it), and
is the location that all downloaded binaries and the projects you built are stored

POM FILE:
E:\01-05-2012\HorizonSnSCommon\code\trunk
1. Do maven build for the HorizonSnsPom
E:\development\workspace\HorizonSnS\HorizonSnSPOM\code\trunk > mvn clean install

2. Do the maven build for the HorizonSchemas
E:\development\workspace\HorizonSnS\HorizonSchemas\code\trunk> mvn clean install

3. Do the maven build for the VoyagerCache
E:\development\workspace\HorizonSnS\VoyagerCache\code\trunk>mvn clean install

4. Do the maven build for the CustomerJourney
E:\development\workspace\HorizonSnS\CustomerJourney\code\trunk>
mvn clean install -Denv=SIT -Dmaven.test.skip=true
- <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>
- <parent>
<artifactId>horizon-sns-pom</artifactId>
<groupId>aero.sita.voyager</groupId>
<version>1.1.0</version>
</parent>
<groupId>aero.sita.voyager</groupId>
<artifactId>Horizon-SnS-Common</artifactId>
<version>4.0.0-S3-SNAPSHOT</version>
<name>Horizon Sales and Service Common</name>
<description>Horizon Sales and Service Common</description>
<packaging>jar</packaging>
- <dependencies>
- <dependency>
<groupId>aero.sita.voyager.common</groupId>
<artifactId>voyager-commons-core</artifactId>
</dependency>
</dependencies>
- <build>
- <plugins>
- <!--
plugin to mangen jar file
-->
- <plugin>
<artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
<manifestFile>${project.build.outputDirectory}/META-
INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
- <plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>1.4.3</version>
<extensions>true</extensions>
- <executions>
- <execution>
- <goals>
<goal>install</goal>
<goal>manifest</goal>
</goals>
</execution>
</executions>
- <configuration>
- <instructions>
<DynamicImport-Package>*</DynamicImport-Package>
<Import-Package>aero.sita.csp.gui.thickclient.coreapi,org.jibx.runtime,*</Import-
Package>
<Export-Package>*</Export-Package>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
</instructions>
</configuration>
</plugin>
- <!--
End of the managen plugin
-->
</plugins>
</build>
</project>

Das könnte Ihnen auch gefallen