maven study notes

Part I: Introductory Material

Part II : Maven by Example

Part III : Maven Reference


Chapter1. Introducing Apache Maven

1.    serve as both an authoritative reference and an introduction.

1.1.Maven...Whatisit?

Build and deploy

Project Mgmt tool(Report , generate web site , teamwork)

A set of standards ,

a project lifecycle

A dependency mgmt tool.

Project Object Model.

1.2.ConventionOver Configuration

1.    classpath is src/main/java|resource src/test/java|resource

2.    process jar file in target/classes

3.    byte code location target/classes

4.    Conversions for compiling source code , packaging , testing …

 

5.    can custom these conventions

 

 

1.3.A Common Interface

1.    Before Maven provided a common interface, each project has a custom build system , and developers had to take time to learn the system.

2.    When new testing framework or new source analysis tools are developed, you have to change the build file.

3.    Move to a common view of project builds.

4.    Problems

a)      What dependency project?

b)      What library

c)      Where I put the library

d)      What goal can I execute in the build

5.    Key to Success

a)      Common interface

b)      Dependency management

c)      Reuse of build logic through plugins

6.    Most Importance command

a)    Mvn install

 

1.4       Universal Reuse through Maven Plugins

1.    Core of Maven

a)      How to parsing xml documents

b)      Keeping track of a lifecycle and a few plug-ins.

c)      Delegated most responsibility to plug-ins. The plug-ins affect maven’s lifecycle and offer access to goals.

d)      The first time run mvn install will try to get the latest version of plugins.

2.     

a)      Reuse build logic is achived by retrieves both dependencies and plugins from remote repository.

3.    Maven Surefire plugin is responsible for running unit tests.

a)      When updated the plugin to support testNG or Junit 4.4 , you only need to change a version number in pom.

4.    Jar plugins

5.    JRuby and Groovy plugins

6.    Publish plugins

7.    Maven has abstracted common build tasks into plugins which are maintained centrally and shared universally.

1.5.Conceptual Model of a "Project"

1.    Attribute of a project

a)      License of the project

b)      Who develops and who attributes

c)      The depdending projects

2.    Feature

a)      Dependency Management

                    i.              Group

                ii.              Artifact

            iii.              Version

b)      Remote Repositories

c)      Universal Reuse of Build logic

                    i.              Plugins are coded to work with POM

                ii.              Everything is in the model, plugin configuration and customization happens in the model.

d)      Tool portability / Integration

                    i.              Support IDEs for custom POM infos.

e)      Easy seaching and Filtering of Project Artifacts

                    i.              Nexus

 

1.6. Is Maven an alternative to XYZ?

1.    Convert ant build script to maven build script.

2.    Maven is more like a platform than a build tools.

 

1.7.Comparing Maven with Ant

1.    POM examples

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.sonatype.mavenbook</groupId>
<artifactId>my-project</artifactId>
<version>1.0</version>
</project>

2.    DEMO

a)      Mvn install

b)      Mvn site

c)      Run mvn test

                    i.              Write under src/test/java

                ii.              Add dependency in test scope.

            iii.              Mvn test

d)      Deploy a war

                    i.              Change type to war

                ii.              Put docroot to src/main/webapp

3.    Benefits

a)      Your can get new function of build logic when change the version number.

4.    maven project can run ant scripts


Chapter2.Installing and Running Maven

2.1.Verify your Java Installation

    Java –version

2.2.Downloading Maven

http://maven.apache.org/download.html.[ 2.0.9]

2.3.Installing Maven

2.3.2.Installing Maven on Microsoft Windows

3.    Set envirement:

a)      M2_HOME

b)      PATH

2.4.Testing a Maven Installation

4.    mvn –v

2.5.Maven Installation Details

5.    Files and Directorys

a)      LICENSE.txt

b)      NOTICE.txt

c)      README.txt

d)      bin/

                    i.              mvn

e)      boot/

                    i.              classwords-1.1.jar

f)      conf/

                    i.              Settings.xml (global settings)

                ii.              Override in ~/.m2

g)      lib/

                    i.              maven-core-2.0.9-uber.jar (The core of jar)

2.5.1.User-specificConfiguration and Repository

6.    ~/.m2/settings.xml

a)      User specific config

                    i.              Authentication

                ii.              Repositories

            iii.              Custom Information

7.    ~/.m2/repository/

a)      Local repositories

2.5.2.Upgrading a Maven Installation

    Just change the M2_HOME

 

2.6.Getting Help with Maven

Plugins:

l        http://maven.apache.org

l        MavenUserMailingList

n        http://www.nabble.com/Maven---Users-f178.html

n        http://maven.apache.org/mail-lists.html

n        http://www.sonatype.com

2.7.Using the Maven Help Plugin

l        plugins

l        profile

l        setting file

l        POM files

When:

l        The plugins maven is using

l        List active maven profiles

n        Mvn help:Active-profiles

l        Display an effective POM

n        Mvn help:Effective-pom

l        Print the effective settings

n        Mvn help:Effective-settings

l        List the attribute of a Maven plugin

l        The goal of a particular maven plugin

n        Mvn help:describe –Dplugin=surefire –Dfull

n        mvnhelp:describe -Dplugin=compiler -Dmojo=compile -Dfull

l        In Maven, a Plugin goal is known as a"Mojo".


Part I. Maven by Example

l        Maven: A Developer’s Notebook

Chapter 3. A Simple Maven Project

l        Dd

n        Build lifecycle

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值