100% found this document useful (4 votes)
56 views49 pages

Maven: The Complete Reference Edition 0.7, Maven 2.2, Maven 3.0 Tim O'Brien All Chapter Instant Download

ebook

Uploaded by

hoebelhowie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (4 votes)
56 views49 pages

Maven: The Complete Reference Edition 0.7, Maven 2.2, Maven 3.0 Tim O'Brien All Chapter Instant Download

ebook

Uploaded by

hoebelhowie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 49

Full download test bank at ebook textbookfull.

com

Maven: the complete reference


edition 0.7, maven 2.2 , maven 3.0

CLICK LINK TO DOWLOAD

https://textbookfull.com/product/maven-the-
complete-reference-
edition-0-7-maven-2-2-maven-3-0-tim-obrien/

textbookfull
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

Zecri Stolen Warriors 4 1st Edition Ella Maven Maven


Ella

https://textbookfull.com/product/zecri-stolen-warriors-4-1st-
edition-ella-maven-maven-ella/

Biota Grow 2C gather 2C cook Loucas

https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-
loucas/

Introducing Maven A Build Tool for Today s Java


Developers Second Edition Balaji Varanasi

https://textbookfull.com/product/introducing-maven-a-build-tool-
for-today-s-java-developers-second-edition-balaji-varanasi/

Beginning Java and Flex Migrating Java Spring Hibernate


and Maven Developers to Adobe Flex Expert s Voice in
Web Development Di Pisa Filippo

https://textbookfull.com/product/beginning-java-and-flex-
migrating-java-spring-hibernate-and-maven-developers-to-adobe-
flex-expert-s-voice-in-web-development-di-pisa-filippo/
Java: The Complete Reference, Eleventh Edition Herbert
Schildt

https://textbookfull.com/product/java-the-complete-reference-
eleventh-edition-herbert-schildt/

The Complete Rust Programming Reference Guide Rahul


Sharma

https://textbookfull.com/product/the-complete-rust-programming-
reference-guide-rahul-sharma/

Robot Operating System (ROS): The Complete Reference


(Volume 5) Anis Koubaa

https://textbookfull.com/product/robot-operating-system-ros-the-
complete-reference-volume-5-anis-koubaa/

Mastering Delphi Programming A Complete Reference Guide


Primož Gabrijel■i■

https://textbookfull.com/product/mastering-delphi-programming-a-
complete-reference-guide-primoz-gabrijelcic/

The Essential Oils Complete Reference Guide Over 250


Recipes for Natural Wholesome Aromatherapy K.G. Stiles

https://textbookfull.com/product/the-essential-oils-complete-
reference-guide-over-250-recipes-for-natural-wholesome-
aromatherapy-k-g-stiles/
Edition 0.7 Maven 2.2
Maven 3.0

Maven: The Complete Reference


The Complete Reference
Tim O’Brien
Jason van Zyl
Brian Fox
John Casey
Juven Xu
Thomas Locher
Manfred Moser

Contributing Authors:

Dan Fabulich
Eric Redmond
Bruce Snyder
Larry Shatzer
A Sonatype Open Book
Mountain View, CA
Copyright © 2010 Sonatype, Inc.

This work is licensed under a Creative Commons Attribution-Noncommercial-No


Derivative Works 3.0 United States license. For more information about this license,
see http://creativecommons.org/licenses/by-nc-nd/3.0/us/. You are free to share,
copy, distribute, display, and perform the work under the following conditions:

• You must attribute the work to Sonatype, Inc. with a link to


http://www.sonatype.com.
• You may not use this work for commercial purposes.
• You may not alter, transform, or build upon this work.

Nexus™, Nexus Professional™, and all Nexus-related logos are trademarks or registered
trademarks of Sonatype, Inc., in the United States and other countries. Java™ and all
Java-based trademarks and logos are trademarks or registered trademarks of Sun
Microsystems, Inc., in the United States and other countries. IBM® and WebSphere® are
trademarks or registered trademarks of International Business Machines, Inc., in the
United States and other countries. Eclipse™ is a trademark of the Eclipse Foundation,
Inc., in the United States and other countries. Apache and the Apache feather logo are
trademarks of The Apache Software Foundation.

Many of the designations used by manufacturers and sellers to distinguish their prod-
ucts are claimed as trademarks. Where those designations appear in this book, and
Sonatype, Inc. was aware of a trademark claim, the designations have been printed in
caps or initial caps.

While every precaution has been taken in the preparation of this book, the publisher
and authors assume no responsibility for errors or omissions, or for damages resulting
from the use of the information contained herein.

Published by: For online information and ordering of this and other
Sonatype books, please visit www.sonatype.com. The
Sonatype, Inc. publisher offers discounts on this book when ordered in
800 W. El Camino Real quantity. For more information, please contact:
Suite 400 [email protected]
Mountain View, CA 94040.

ISBN 978-0-9842433-4-1 Editor: Tim O’Brien


Nexus Professional
Nexus Professional 1.6 is now available with features to support enterprise software
development. Stage software releases and maintain strict control over proxy repositories.
Download your free trial today.

"We have adopted Maven for all our software development projects and have
started using Nexus to better support our development processes. The support for
promotion and procurement workflows in Nexus Professional now expands Nexus
with a robust set of additional features which make it easier for us to maintain
consistency between our development, testing and production environments."

- Chris Maki, Principal Software Engineer, Overstock.com

"At Intuit, we recognize that as builds grow and the teams who create them change
over time, swift, accurate repository management becomes critical. Nexus provides
a comprehensive, easy-to-use open source solution that lets teams and developers
track, search, organize and access build components."

- Kaizer Sogiawala, Software Configuration Management Engineer, Intuit.

http://www.sonatype.com/products/nexus

Maven Training by Sonatype


With Sonatype training, you will learn Maven fundamentals and best practices directly
from Maven and Nexus experts. If your team is using Nexus, this class is the easiest
way to make sure that everyone starts from the same foundation.

MVN-101 Maven Mechanics


An online instructor-led course of two half-day sessions, ideal for programmers who
work with Maven projects and need to understand how to work with an existing
Maven build. This class is also appropriate for experienced Maven users who are inter-
ested in becoming more familiar with Maven fundamentals.

MVN-201 Development Infrastructure Design


An online instructor-led course of two half-day sessions, ideal for Development Infra-
structure Engineers who are responsible for maintaining enterprise development infra-
structure. This class includes content on advanced repository management using
Nexus and continuous integration using Hudson.

http://www.sonatype.com/training
Copyright ........................................................................................................................................................... xv
Foreword: 0.7 .................................................................................................................................................... xvii
1. Changes in Edition 0.7 ............................................................................................................................ xvii
Preface .............................................................................................................................................................. xix
1. How to Use this Book .............................................................................................................................. xix
2. Your Feedback ........................................................................................................................................ xix
3. Font Conventions .................................................................................................................................... xix
4. Maven Writing Conventions ....................................................................................................................... xx
5. Acknowledgements ................................................................................................................................... xx
1. Introducing Apache Maven .................................................................................................................................. 1
1.1. Maven... What is it? ................................................................................................................................. 1
1.2. Convention Over Configuration ................................................................................................................. 1
1.3. A Common Interface ................................................................................................................................ 2
1.4. Universal Reuse through Maven Plugins ...................................................................................................... 2
1.5. Conceptual Model of a "Project" ................................................................................................................ 3
1.6. Is Maven an alternative to XYZ? ............................................................................................................... 3
1.7. Comparing Maven with Ant ...................................................................................................................... 4
2. Installing Maven ................................................................................................................................................ 7
2.1. Verify your Java Installation ...................................................................................................................... 7
2.2. Downloading Maven ................................................................................................................................ 7
2.2.1. Downloading Maven 2 ................................................................................................................... 7
2.2.2. Downloading Maven 3 ................................................................................................................... 8
2.3. Installing Maven ..................................................................................................................................... 8
2.3.1. Installing Maven on Mac OSX ........................................................................................................ 8
2.3.2. Installing Maven on Microsoft Windows ........................................................................................... 9
2.3.3. Installing Maven on Linux .............................................................................................................. 9
2.3.4. Installing Maven on FreeBSD or OpenBSD ....................................................................................... 9
2.4. Testing a Maven Installation ...................................................................................................................... 9
2.5. Maven Installation Details ....................................................................................................................... 10
2.5.1. User-specific Configuration and Repository ...................................................................................... 10
2.5.2. Upgrading a Maven Installation ..................................................................................................... 11
2.5.3. Upgrading from Maven 1.x to Maven 2.x ........................................................................................ 11
2.6. Uninstalling Maven ................................................................................................................................ 11
2.7. Getting Help with Maven ........................................................................................................................ 12
2.8. About the Apache Software License .......................................................................................................... 12
3. The Project Object Model .................................................................................................................................. 15
3.1. Introduction .......................................................................................................................................... 15
3.2. The POM ............................................................................................................................................. 15
3.2.. The Super POM ........................................................................................................................... 16
3.2.2. The Simplest POM ...................................................................................................................... 19
3.2.3. The Effective POM ..................................................................................................................... 20
3.2.4. Real POMs ................................................................................................................................. 20
3.3. POM Syntax ......................................................................................................................................... 20
3.3.1. Project Versions .......................................................................................................................... 20
3.3.2. Property References ..................................................................................................................... 21
3.4. Project Dependencies .............................................................................................................................. 22
3.4.1. Dependency Scope ...................................................................................................................... 23
3.4.2. Optional Dependencies ................................................................................................................. 24
3.4.3. Dependency Version Ranges ......................................................................................................... 25
3.4.4. Transitive Dependencies ............................................................................................................... 26
3.4.5. Conflict Resolution ...................................................................................................................... 26
3.4.6. Dependency Management ............................................................................................................. 28
3.5. Project Relationships .............................................................................................................................. 29
3.5.1. More on Coordinates ................................................................................................................... 29
3.5.2. Project Inheritance ....................................................................................................................... 30
3.6. POM Best Practices ............................................................................................................................... 31
3.6.1. Grouping Dependencies ................................................................................................................ 31
3.6.2. Multi-module vs. Inheritance ......................................................................................................... 33
4. The Build Lifecycle .......................................................................................................................................... 37
4.1. Introduction .......................................................................................................................................... 37
4.1.1. Clean Lifecycle (clean) ................................................................................................................. 37
4.1.2. Default Lifecycle (default) ............................................................................................................ 39
4.1.3. Site Lifecycle (site) ...................................................................................................................... 40
4.2. Package-specific Lifecycles ..................................................................................................................... 41
4.2.1. JAR .......................................................................................................................................... 41
4.2.2. POM ......................................................................................................................................... 41
4.2.3. Maven Plugin ............................................................................................................................. 42
4.2.4. EJB ........................................................................................................................................... 42
4.2.5. WAR ........................................................................................................................................ 42
4.2.6. EAR .......................................................................................................................................... 43
4.2.7. Other Packaging Types ................................................................................................................. 43
4.3. Common Lifecycle Goals ........................................................................................................................ 44
4.3.1. Process Resources ....................................................................................................................... 44
4.3.2. Compile ..................................................................................................................................... 46
4.3.3. Process Test Resources ................................................................................................................. 47
4.3.4. Test Compile .............................................................................................................................. 47
4.3.5. Test .......................................................................................................................................... 48
4.3.6. Install ........................................................................................................................................ 48
4.3.7. Deploy ...................................................................................................................................... 49
5. Build Profiles .................................................................................................................................................. 51
5.1. What Are They For? .............................................................................................................................. 51
5.1.1. What is Build Portability .............................................................................................................. 51
5.1.2. Selecting an Appropriate Level of Portability ................................................................................... 52
5.2. Portability through Maven Profiles ............................................................................................................ 52
5.2.1. Overriding a Project Object Model ................................................................................................. 54
5.3. Profile Activation ................................................................................................................................... 54
5.3.1. Activation Configuration ............................................................................................................... 55
5.3.2. Activation by the Absence of a Property .......................................................................................... 56
5.4. Listing Active Profiles ............................................................................................................................ 57
5.5. Tips and Tricks ..................................................................................................................................... 57
5.5.1. Common Environments ................................................................................................................ 57
5.5.2. Protecting Secrets ........................................................................................................................ 58
5.5.3. Platform Classifiers ...................................................................................................................... 59
5.6. Summary .............................................................................................................................................. 61
6. Running Maven ............................................................................................................................................... 63
6.1. Maven Command Line Options ................................................................................................................ 63
6.1.1. Defining Properties ...................................................................................................................... 63
6.1.2. Getting Help ............................................................................................................................... 63
6.1.3. Using Build Profiles .................................................................................................................... 64
6.1.4. Displaying Version Information ..................................................................................................... 64
6.1.5. Running in Offline Mode .............................................................................................................. 65
6.1.6. Using a Custom POM or Custom Settings File ................................................................................. 65
6.1.7. Encrypting Passwords .................................................................................................................. 65
6.1.8. Dealing with Failure .................................................................................................................... 65
6.1.9. Controlling Maven's Verbosity ....................................................................................................... 66
6.1.10. Running Maven in Batch Mode .................................................................................................... 66

iv
6.1.11. Downloading and Verifying Dependencies ..................................................................................... 66
6.1.12. Controlling Plugin Updates .......................................................................................................... 67
6.1.13. Non-recursive Builds .................................................................................................................. 67
6.2. Using Advanced Reactor Options ............................................................................................................. 67
6.2.1. Advanced Reactor Options Example Project ..................................................................................... 67
6.2.2. Resuming Builds ......................................................................................................................... 69
6.2.3. Specifying a Subset of Projects ...................................................................................................... 69
6.2.4. Making a Subset of Projects .......................................................................................................... 69
6.2.5. Making Project Dependents ........................................................................................................... 70
6.2.6. Resuming a "make" build ............................................................................................................. 70
6.3. Using the Maven Help Plugin .................................................................................................................. 70
6.3.1. Describing a Maven Plugin ........................................................................................................... 71
7. Maven Configuration ........................................................................................................................................ 73
7.1. Configuring Maven Plugins ..................................................................................................................... 73
7.1.1. Plugin Configuration Parameters .................................................................................................... 73
7.1.2. Adding Plugin Dependencies ......................................................................................................... 75
7.1.3. Setting Global Plugin Parameters ................................................................................................... 76
7.1.4. Setting Execution Specific Parameters ............................................................................................. 76
7.1.5. Setting Default Command Line Execution Parameters ........................................................................ 77
7.1.6. Setting Parameters for Goals Bound to Default Lifecycle .................................................................... 77
8. Maven Assemblies ............................................................................................................................................ 79
8.1. Introduction .......................................................................................................................................... 79
8.2. Assembly Basics .................................................................................................................................... 79
8.2.1. Predefined Assembly Descriptors ................................................................................................... 80
8.2.2. Building an Assembly .................................................................................................................. 80
8.2.3. Assemblies as Dependencies ......................................................................................................... 82
8.2.4. Assembling Assemblies via Assembly Dependencies ......................................................................... 82
8.3. Overview of the Assembly Descriptor ....................................................................................................... 85
8.4. The Assembly Descriptor ........................................................................................................................ 86
8.4.1. Property References in Assembly Descriptors ................................................................................... 86
8.4.2. Required Assembly Information ..................................................................................................... 86
8.5. Controlling the Contents of an Assembly ................................................................................................... 87
8.5.1. Files Section ............................................................................................................................ 87
8.5.2. FileSets Section ....................................................................................................................... 88
8.5.3. Default Exclusion Patterns for fileSets ........................................................................................ 89
8.5.4. dependencySets Section ............................................................................................................ 90
8.5.5. moduleSets Sections .................................................................................................................. 97
8.5.6. Repositories Section ................................................................................................................... 101
8.5.7. Managing the Assembly’s Root Directory ...................................................................................... 101
8.5.8. componentDescriptors and containerDescriptorHandlers .................................................... 102
8.6. Best Practices ...................................................................................................................................... 102
8.6.1. Standard, Reusable Assembly Descriptors ...................................................................................... 103
8.6.2. Distribution (Aggregating) Assemblies .......................................................................................... 105
8.7. Summary ............................................................................................................................................ 108
9. Properties and Resource Filtering ...................................................................................................................... 109
9.1. Introduction ......................................................................................................................................... 109
9.2. Maven Properties ................................................................................................................................. 109
9.2.1. Maven Project Properties ............................................................................................................ 109
9.2.2. Maven Settings Properties ........................................................................................................... 111
9.2.3. Environment Variable Properties .................................................................................................. 111
9.2.4. Java System Properties ............................................................................................................... 111
9.2.5. User-defined Properties ............................................................................................................... 112
9.3. Resource Filtering ................................................................................................................................ 113

v
10. Site Generation ............................................................................................................................................. 117
10.1. Introduction ....................................................................................................................................... 117
10.2. Building a Project Site with Maven ....................................................................................................... 117
10.3. Customizing the Site Descriptor ............................................................................................................ 118
10.3.1. Customizing the Header Graphics ............................................................................................... 119
10.3.2. Customizing the Navigation Menu .............................................................................................. 120
10.4. Site Directory Structure ....................................................................................................................... 121
10.5. Writing Project Documentation ............................................................................................................. 121
10.5.1. APT Example .......................................................................................................................... 122
10.5.2. FML Example ......................................................................................................................... 122
10.6. Deploying Your Project Website ........................................................................................................... 123
10.6.1. Configuring Server Authentication .............................................................................................. 123
10.6.2. Configuring File and Directory Modes ......................................................................................... 124
10.7. Customizing Site Appearance ............................................................................................................... 124
10.7.1. Customizing the Site CSS .......................................................................................................... 124
10.7.2. Create a Custom Site Template ................................................................................................... 125
10.7.3. Reusable Website Skins ............................................................................................................ 128
10.7.4. Creating a Custom Theme CSS .................................................................................................. 129
10.8. Tips and Tricks .................................................................................................................................. 130
10.8.1. Inject XHTML into HEAD ........................................................................................................ 130
10.8.2. Add Links under Your Site Logo ................................................................................................ 130
10.8.3. Add Breadcrumbs to Your Site ................................................................................................... 131
10.8.4. Add the Project Version ............................................................................................................ 131
10.8.5. Modify the Publication Date Format and Location ......................................................................... 132
10.8.6. Using Doxia Macros ................................................................................................................. 132
11. Writing Plugins ............................................................................................................................................ 135
11.1. Introduction ....................................................................................................................................... 135
11.2. Programming Maven ........................................................................................................................... 135
11.2.1. What is Inversion of Control? .................................................................................................... 135
11.2.2. Introduction to Plexus ............................................................................................................... 136
11.2.3. Why Plexus? ........................................................................................................................... 136
11.2.4. What is a Plugin? ..................................................................................................................... 137
11.3. Plugin Descriptor ................................................................................................................................ 137
11.3.1. Top-level Plugin Descriptor Elements .......................................................................................... 138
11.3.2. Mojo Configuration .................................................................................................................. 139
11.3.3. Plugin Dependencies ................................................................................................................. 141
11.4. Writing a Custom Plugin ..................................................................................................................... 141
11.4.1. Creating a Plugin Project ........................................................................................................... 141
11.4.2. A Simple Java Mojo ................................................................................................................. 142
11.4.3. Configuring a Plugin Prefix ....................................................................................................... 143
11.4.4. Logging from a Plugin .............................................................................................................. 145
11.4.5. Mojo Class Annotations ............................................................................................................ 145
11.4.6. When a Mojo Fails ................................................................................................................... 147
11.5. Mojo Parameters ................................................................................................................................ 147
11.5.1. Supplying Values for Mojo Parameters ........................................................................................ 147
11.5.2. Multi-valued Mojo Parameters .................................................................................................... 149
11.5.3. Depending on Plexus Components .............................................................................................. 150
11.5.4. Mojo Parameter Annotations ...................................................................................................... 150
11.6. Plugins and the Maven Lifecycle ........................................................................................................... 151
11.6.1. Executing a Parallel Lifecycle .................................................................................................... 151
11.6.2. Creating a Custom Lifecycle ...................................................................................................... 152
11.6.3. Overriding the Default Lifecycle ................................................................................................. 153
12. Using Maven Archetypes ............................................................................................................................... 155

vi
12.1. Introduction to Maven Archetypes ......................................................................................................... 155
12.2. Using Archetypes ............................................................................................................................... 155
12.2.1. Using an Archetype from the Command Line ................................................................................ 155
12.2.2. Using the Interactive generate Goal ............................................................................................. 156
12.2.3. Using an Archetype from m2eclipse ............................................................................................ 157
12.3. Available Archetypes .......................................................................................................................... 157
12.3.1. Common Maven Archetypes ...................................................................................................... 158
12.3.2. Notable Third-Party Archetypes .................................................................................................. 158
12.4. Publishing Archetypes ......................................................................................................................... 160
13. Developing with Flexmojos ............................................................................................................................ 163
13.1. Introduction ....................................................................................................................................... 163
13.2. Configuring Build Environment for Flexmojos ......................................................................................... 163
13.2.1. Referencing a Repository with the Flex Framework ........................................................................ 163
13.2.2. Configuring Environment to Support Flex Unit Tests ...................................................................... 167
13.2.3. Adding FlexMojos to Your Maven Settings' Plugin Groups .............................................................. 168
13.3. Creating a Flex Mojos Project from an Archetype .................................................................................... 168
13.3.1. Creating a Flex Library ............................................................................................................. 168
13.3.2. Creating a Flex Application ....................................................................................................... 172
13.3.3. Creating a Multi-module Project: Web Application with a Flex Dependency ........................................ 175
13.4. The FlexMojos Lifecycle ..................................................................................................................... 180
13.4.1. The SWC Lifecycle .................................................................................................................. 181
13.4.2. The SWF Lifecycle .................................................................................................................. 182
13.5. FlexMojos Plugin Goals ...................................................................................................................... 182
13.5.1. Generating Actionscript Documentation ....................................................................................... 183
13.5.2. Compiling Flex Source ............................................................................................................. 184
13.5.3. Generating Flex Builder Project Files .......................................................................................... 184
13.6. FlexMojos Plugin Reports .................................................................................................................... 184
13.6.1. Generating Actionscript Documentation Report ............................................................................. 185
13.7. Developing and Customizing Flexmojos ................................................................................................. 186
13.7.1. Get the Flexmojos Source Code .................................................................................................. 186
14. Android Application Development with Maven .................................................................................................. 187
14.1. Introduction ....................................................................................................................................... 187
14.2. Configuring Build Environment for Android Development ......................................................................... 187
14.2.1. Installing the Android SDK ....................................................................................................... 187
14.2.2. Android artifact install into Maven repository ................................................................................ 187
14.2.3. Configuring Maven for usage of the Maven Android Plugin ............................................................. 188
14.3. Android Application Development with the Maven Android Plugin ............................................................. 189
14.3.1. HelloFlashlight Example ........................................................................................................... 189
14.3.2. Testing Android Application Code .............................................................................................. 190
14.3.3. Using Add Ons like the Google Maps Extension ............................................................................ 191
14.3.4. Multi Module Maven Android Projects ........................................................................................ 191
14.3.5. Using external dependencies ...................................................................................................... 191
14.4. Maven Android Plugin Details .............................................................................................................. 192
14.4.1. Maven Android Plugin Lifecycle ................................................................................................ 192
14.4.2. Maven Android Plugin Goals ..................................................................................................... 192
A. Appendix: Settings Details ............................................................................................................................... 195
A.1. Quick Overview .................................................................................................................................. 195
A.2. Settings Details ................................................................................................................................... 195
A.2.1. Simple Values .......................................................................................................................... 195
A.2.2. Servers .................................................................................................................................... 196
A.2.3. Mirrors .................................................................................................................................... 197
A.2.4. Proxies .................................................................................................................................... 197
A.2.5. Profiles .................................................................................................................................... 198

vii
A.2.6. Activation ................................................................................................................................ 198
A.2.7. Properties ................................................................................................................................ 199
A.2.8. Repositories ............................................................................................................................. 200
A.2.9. Plugin Repositories .................................................................................................................... 201
A.2.10. Active Profiles ........................................................................................................................ 201
A.2.11. Encrypting Passwords in Maven Settings ..................................................................................... 202
B. Appendix: Sun Specification Alternatives ........................................................................................................... 205
C. Creative Commons License .............................................................................................................................. 207
C.1. Creative Commons BY-NC-ND 3.0 US License ........................................................................................ 207
D. Book Revision History .................................................................................................................................... 211
D.1. Changes in Edition 0.6 ......................................................................................................................... 211
D.2. Changes in Edition 0.5 ......................................................................................................................... 211
D.3. Changes in Edition 0.4 ......................................................................................................................... 211
D.4. Changes in Edition 0.2.1 ....................................................................................................................... 212
D.5. Changes in Edition 0.2 ......................................................................................................................... 212
D.6. Changes in Edition 0.1 ......................................................................................................................... 212
Index ................................................................................................................................................................ 215

viii
List of Figures
2.1. Downloading Maven 2 from the Apache Maven web site ....................................................................................... 7
2.2. Downloading Maven 3 from the Apache Maven web site ....................................................................................... 8
3.1. The Project Object Model ............................................................................................................................... 16
3.2. The Super POM is always the base Parent ......................................................................................................... 19
3.3. Project Inheritance for a-parent and project-a ...................................................................................................... 30
3.4. maven-book Multi-module vs. Inheritance .......................................................................................................... 33
3.5. Enterprise Multi-module vs. Inheritance ............................................................................................................. 34
6.1. Directory Structure of Sample Multi-module Project ............................................................................................ 68
6.2. Dependencies within Sample Multi-module Project .............................................................................................. 68
10.1. Simple Generated Maven Site ....................................................................................................................... 118
10.2. Customized Sample Project Web Site ............................................................................................................. 119
13.1. Adding a Proxy Repository to Sonatype Nexus ................................................................................................ 164
13.2. Configuring the Sonatype Flexmojos Proxy Repository ..................................................................................... 165
13.3. Adding the Sonatype Flexmojos Proxy to the Public Repositories Group .............................................................. 166
13.4. Flexmojo Library Archetype File Structure ..................................................................................................... 169
13.5. Directory Structure for Flex Application Archetype .......................................................................................... 173
13.6. Directory Structure for Flex Multimodule Archetype ......................................................................................... 176
13.7. The FlexMojos SWC Lifecycle ..................................................................................................................... 181
13.8. The FlexMojos SWF Lifecycle ..................................................................................................................... 182
13.9. Actionscript Documentation Generated by the FlexMojos Plugin ......................................................................... 183
13.10. Actionscript Documentation Report on Maven Site ......................................................................................... 185
13.11. Flexmojos Subversion Repository ................................................................................................................ 186
A.1. Storing Unencrypted Passwords in Maven Settings ............................................................................................ 202
A.2. Storing Encrypted Passwords in Maven Settings ............................................................................................... 202
List of Examples
1.1. A Simple Ant build.xml file .............................................................................................................................. 4
1.2. A Sample Maven pom.xml ................................................................................................................................ 5
3.1. The Super POM ............................................................................................................................................ 16
3.2. The Simplest POM ........................................................................................................................................ 19
3.3. Project Dependencies ...................................................................................................................................... 22
3.4. Declaring Optional Dependencies ..................................................................................................................... 24
3.5. Specifying a Dependency Range: JUnit 3.8 - JUnit 4.0 ......................................................................................... 25
3.6. Specifying a Dependency Range: JUnit <= 3.8.1 ................................................................................................. 25
3.7. Excluding a Transitive Dependency .................................................................................................................. 26
3.8. Excluding and Replacing a Transitive Dependency .............................................................................................. 27
3.9. Defining Dependency Versions in a Top-level POM ............................................................................................ 28
3.10. Project Inheritance ........................................................................................................................................ 30
3.11. Consolidating Dependencies in a Single POM Project ......................................................................................... 32
3.12. Declaring a Dependency on a POM ................................................................................................................. 32
4.1. Triggering a Goal on pre-clean ......................................................................................................................... 37
4.2. Customizing Behavior of the Clean Plugin ......................................................................................................... 39
4.3. Custom Packaging Type for Adobe Flex (SWF) .................................................................................................. 43
4.4. Using Properties in Project Resources ............................................................................................................... 44
4.5. default.properties in src/main/filters ................................................................................................................... 45
4.6. Filter Resources (Replacing Properties) .............................................................................................................. 45
4.7. Configuring Additional Resource Directories ...................................................................................................... 45
4.8. Filtering Script Resources ................................................................................................................................ 46
4.9. Setting the Source and Target Versions for the Compiler Plugin ............................................................................. 46
4.10. Overriding the Default Source Directory .......................................................................................................... 47
4.11. Overriding the Location of Test Source and Output ............................................................................................ 48
4.12. Configuring Surefire to Ignore Test Failures ..................................................................................................... 48
5.1. Using a Maven Profile to Override Production Compiler Settings ........................................................................... 52
5.2. Elements Allowed in a Profile ......................................................................................................................... 54
5.3. Dynamic Inclusion of Submodules Using Profile Activation .................................................................................. 55
5.4. Profile Activation Parameters: JDK Version, OS Parameters, and Properties ............................................................. 56
5.5. Activating Profiles in the Absence of a Property ................................................................................................. 56
5.6. Project Profile Activated by setting environment.type to 'dev' ................................................................................ 57
5.7. Storing Secrets in a User-specific Settings Profile ................................................................................................ 59
5.8. Qualifying Artifacts with Platform Activated Project Profiles ................................................................................. 59
5.9. Qualifying Artifacts with Platform Activated Project Profiles and Variable Substitution .............................................. 60
5.10. Depending on a Qualified Artifact ................................................................................................................... 61
6.1. Maven Version Information ............................................................................................................................. 65
6.2. Order of Project Builds in Maven Reactor .......................................................................................................... 69
7.1. Adding Dependencies to a Plugin ..................................................................................................................... 75
7.2. Configuring a Maven Plugin ............................................................................................................................ 76
7.3. Setting Configuration Parameters in an Execution ................................................................................................ 76
7.4. Configuring Plugin Parameters for Command Line Execution ................................................................................ 77
7.5. Setting a Parameter for a Default Goal Execution ................................................................................................ 77
7.6. Setting Two Default Goal Plugin Configuration Parameters ................................................................................... 78
8.1. Assembly Descriptor for Executable JAR ........................................................................................................... 81
8.2. Configuring the project assembly in top-level POM ............................................................................................. 83
8.3. Activating the Assembly Plugin Configuration in Child Projects ............................................................................. 83
8.4. POM for the Assembly Bundling Project ........................................................................................................... 84
8.5. Required Assembly Descriptor Elements ............................................................................................................ 86
8.6. Including a JAR file in an Assembly using files ............................................................................................... 87
8.7. Including Files with fileSet .......................................................................................................................... 88
8.8. Definition of Default Exclusion Patterns from Plexus Utils .................................................................................... 90
8.9. Defining Dependency Sets Using Scope ............................................................................................................. 93
8.10. Using Dependency Excludes and Includes in dependencySets ........................................................................... 94
8.11. Excluding Files from a Dependency Unpack ..................................................................................................... 96
8.12. Includes and Excluding Modules with a moduleSet .......................................................................................... 98
8.13. Including JavaDoc from Modules in an Assembly ............................................................................................ 100
8.14. Including Module Artifacts and Dependencies in an Assembly ............................................................................ 100
9.1. User-defined Properties in a POM ................................................................................................................... 112
9.2. User-defined Properties in a Profile in a POM ................................................................................................... 112
9.3. Referencing Maven Properties from a Resource ................................................................................................. 113
9.4. Defining Variables and Activating Resource Filtering ......................................................................................... 114
10.1. An Initial Site Descriptor ............................................................................................................................. 118
10.2. Adding a Banner Left and Banner Right to Site Descriptor ................................................................................ 119
10.3. Creating Menu Items in a Site Descriptor ....................................................................................................... 120
10.4. Adding a Link to the Site Menu .................................................................................................................... 120
10.5. APT Document .......................................................................................................................................... 122
10.6. FAQ Markup Language Document ................................................................................................................ 122
10.7. Configuring Site Deployment ....................................................................................................................... 123
10.8. Storing Server Authentication in User-specific Settings ..................................................................................... 123
10.9. Configuring File and Directory Modes on Remote Servers ................................................................................. 124
10.10. Customizing the Page Template in a Project's POM ........................................................................................ 127
10.11. Adding a Menu Item to a Site Descriptor ...................................................................................................... 128
10.12. Configuring a Custom Site Skin in Site Descriptor .......................................................................................... 130
10.13. Injecting HTML into the HEAD element ...................................................................................................... 130
10.14. Adding Links Under Your Site Logo ............................................................................................................ 130
10.15. Configuring the Site's Breadcrumbs .............................................................................................................. 131
10.16. Positioning the Version Information ............................................................................................................. 131
10.17. Positioning the Publish Date ....................................................................................................................... 132
10.18. Configuring the Publish Date Format ........................................................................................................... 132
10.19. Output of the Snippet Macro in XHTML ...................................................................................................... 132
11.1. Plugin Descriptor ........................................................................................................................................ 137
11.2. A Plugin Project's POM .............................................................................................................................. 141
11.3. A Simple EchoMojo ................................................................................................................................... 142
11.4. Maven Metadata for the Maven Plugin Group ................................................................................................. 143
11.5. Customizing the Plugin Groups in Maven Settings ........................................................................................... 144
11.6. Configuring a Plugin Prefix .......................................................................................................................... 144
11.7. A Plugin with Multi-valued Parameters .......................................................................................................... 149
11.8. Depending on a Plexus Component ............................................................................................................... 150
11.9. Define a Custom Lifecycle in lifecycles.xml .................................................................................................... 152
11.10. Forking a Custom Lifecycle from a Mojo ..................................................................................................... 152
11.11. Overriding the Default Lifecycle ................................................................................................................. 153
11.12. Configuring a Plugin as an Extension ........................................................................................................... 153
12.1. Archetype Catalog for the Apache Cocoon Project ........................................................................................... 160
13.1. Adding a Reference to Sonatype's FlexMojos Repository in a POM ..................................................................... 163
13.2. Settings XML for Local Nexus Instance ......................................................................................................... 166
13.3. Adding Sonatype Plugins to Maven Settings ................................................................................................... 168
13.4. Project Object Model for Flex Library Archetype ............................................................................................. 169
13.5. Flex Library Archetype's Sample App Class .................................................................................................... 171
13.6. Unit Test for Library Archetype's App Class ................................................................................................... 171
13.7. POM for Flex Application Archetype ............................................................................................................. 173
13.8. Sample Application Main.mxml .................................................................................................................... 175
13.9. Unit Test for Main.mxml ............................................................................................................................. 175

xii
13.10. Top-level POM Created by Modular Web Application Archetype ...................................................................... 176
13.11. swc Module POM ..................................................................................................................................... 176
13.12. swf module POM ...................................................................................................................................... 178
13.13. war module POM ..................................................................................................................................... 179
13.14. Setting Plugin Extensions to True for Custom Flex Lifecycle ............................................................................ 181
13.15. Customizing the Compiler Plugin ................................................................................................................ 184
13.16. Configuring the Actionscript Documentation Report ........................................................................................ 185
13.17. Configuring the asdoc-report ....................................................................................................................... 185
14.1. Snippet for settings.xml for the repository server access credentials ..................................................................... 188
14.2. Snippet for settings.xml to enable short plugin name usage ................................................................................ 188
14.3. The HelloFlashlight pom.xml file .................................................................................................................. 189
14.4. Adding the test folder to the build configuration .............................................................................................. 190
14.5. The dependency to the Google Maps API ....................................................................................................... 191
A.1. Overview of top-level elements in settings.xml ................................................................................................. 195
A.2. Simple top-level elements in settings.xml ........................................................................................................ 195
A.3. Server configuration in settings.xml ................................................................................................................ 196
A.4. Mirror configuration in settings.xml ................................................................................................................ 197
A.5. Proxy configuration in settings.xml ................................................................................................................. 197
A.6. Defining Activation Parameters in settings.xml ................................................................................................. 198
A.7. Setting the ${user.install} property in settings.xml ............................................................................................. 199
A.8. Repository Configuration in settings.xml ......................................................................................................... 200
A.9. Plugin Repositories in settings.xml ................................................................................................................. 201
A.10. Setting active profiles in settings.xml ............................................................................................................ 201
A.11. settings-security.xml with Master Password .................................................................................................... 203
A.12. Storing an Encrypted Password in Maven Settings (~/.m2/settings.xml) ............................................................... 203
A.13. Configuring Relocation of the Master Password .............................................................................................. 203
B.1. Adding JTA 1.0.1B to a Maven Project ........................................................................................................... 206

xiii
Copyright
Copyright © 2010 Sonatype, Inc.

Online version published by Sonatype, Inc., 800 W. El Camino Real, Suite 400, Mountain View, CA, 94040.

This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 United States license. For
more information about this license, see http://creativecommons.org/licenses/by-nc-nd/3.0/us/.

Nexus™, Nexus Professional™, and all Nexus-related logos are trademarks or registered trademarks of Sonatype, Inc., in the United
States and other countries.

Java™ and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc., in the United
States and other countries.

IBM® and WebSphere® are trademarks or registered trademarks of International Business Machines, Inc., in the United States and
other countries.

Eclipse™ is a trademark of the Eclipse Foundation, Inc., in the United States and other countries.

Apache and the Apache feather logo are trademarks of The Apache Software Foundation.

Linux® is the registered trademark of Linus Torvalds in the U.S. and other countries.

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those
designations appear in this book, and Sonatype, Inc. was aware of a trademark claim, the designations have been printed in caps
or initial caps.

While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors
or omissions, or for damages resulting from the use of the information contained herein.
Foreword: 0.7
In this edition of Maven: The Complete Reference, we are beginning our transition to Maven 3.0. Maven 3.0 is approaching the end
of a lengthy beta testing period, and it has already been in wide use by very large, mission-critical projects. We feel the Maven 3.0
is ready to for use, and this edition has added some supplemental information for developers who are looking to use Maven 3.0.

We've had some great feedback so far, please keep it coming. Your feedback is greatly appreciated, send it to [email protected].
To keep yourself informed of updates, read the book blog at: http://blogs.sonatype.com/book. Everyone at Sonatype has had a hand
in this version of the book, so the author is officially "Sonatype".

Please report any bugs or issues on this book's GetSatisfaction page, here: http://www.getsatisfaction.com/sonatype/products/
sonatype_maven_the_complete_reference.

Tim O'Brien ([email protected])

September, 2010

1. Changes in Edition 0.7


The following changes were made in September, 2010:

• Added Maven 3.0 to the cover of the ePub and PDF. (MVNREF-1632)

• Added Maven 3.0 download instructions to Section 2.2, “Downloading Maven”.(MVNREF-1643)

• Fixed a typo in Section 3.6.2.1, “Simple Project”, "change" -> "chance" (MVNREF-1504)

• Fixed some wording issues with optional dependencies in Section 3.4.2, “Optional Dependencies”. (MVNREF-1375)

• Adding a missing label to Example 7.2, “Configuring a Maven Plugin”, Example 7.4, “Configuring Plugin Parameters
for Command Line Execution”, and Example 7.5, “Setting a Parameter for a Default Goal Execution”. (MVNREF-1656,
MVNREF-1497)

• Removed blank label attribute from Section 1.7, “Comparing Maven with Ant”. (MVNREF-1668)

• Fixed a run-on sentence in Section 11.4.5, “Mojo Class Annotations”. (MVNREF-1519)

• Changed the tense of a cross-reference in Section 3.2.3, “The Effective POM”. (MVNREF-14710)

• Changed the name of the property in Section 5.3.1, “Activation Configuration” for clarity. (MVNREF-12911)

• Clarified language about grouping dependencies in Section 3.6.1, “Grouping Dependencies”. (MVNREF-13412)

Thanks to Florian Brunner for reporting a typo in the book. Thanks to David M. Karr for suggesting improvements to the description
of optional dependencies. Thanks to Mark Vedder for finding run-on sentences in the book. Thanks to Cedric Girard for finding
examples with missing labels. Thanks to Benjamin Bentmann for identifying an issue in the profiles chapter.

1
mailto:[email protected]
Preface
Maven is a build tool, a project management tool, an abstract container for running build tasks. It is a tool that has shown itself
indispensable for projects that graduate beyond the simple and need to start finding consistent ways to manage and build large
collections of interdependent modules and libraries which make use of tens or hundreds of third-party components. It is a tool that
has removed much of the burden of 3rd party dependency management from the daily work schedule of millions of engineers, and
it has enabled many organizations to evolve beyond the toil and struggle of build management into a new phase where the effort
required to build and maintain software is no longer a limiting factor in software design.

This work is the first attempt at a comprehensive title on Maven. It builds upon the combined experience and work of the authors of all
previous Maven titles, and you should view it not as a finished work but as the first edition in a long line of updates to follow. While
Maven has been around for a few years, the authors of this book believe that it has just begun to deliver on the audacious promises
it makes. The authors, and company behind this book, Sonatype1, believe that the publishing of this book marks the beginning of a
new phase of innovation and development surrounding Maven and the software ecosystem that surrounds it.

1. How to Use this Book


Pick it up, read some of the text on the pages. Once you reach the end of a page, you'll want to either click on a link if you are looking
at the HTML version, or, if you have the printed book, you'll lift up a corner of a page and turn it. If you are sitting next to a computer,
you can type in some of the examples and try to follow along. Please don't throw a book this large at anyone in anger.

This book introduces Maven by developing some real examples and walking you through the structure of those examples providing
motivation and explanation along the way.

2. Your Feedback
We didn't write this book so we could send off a Word document to our publisher and go to a launch party to congratulate ourselves on
a job well done. This book isn't "done"; in fact, this book will never be completely "done". The subject it covers is constantly changing
and expanding, and we consider this work an ongoing conversation with the community. Publishing the book means that the real work
has just begun, and you, as a reader, play a pivotal role to helping to maintain and improve this book. If you see something in this book
that is wrong: a spelling mistake, some bad code, a blatant lie, then you should tell us, send us an email at: [email protected].

The ongoing relevance of this book depends upon your feedback. We want to know what works and what doesn't work. We want to
know if there is any information you couldn't understand. We especially want to know if you think that the book is awful. Positive
or negative comments are all welcome. Of course, we reserve the right to disagree, but all feedback will be rewarded with a gracious
response.

3. Font Conventions
This book follows certain conventions for font usage. Understanding these conventions up-front makes it easier to use this book.

Italic
Used for filenames, file extensions, URLs, application names, emphasis, and new terms when they are first introduced.

Constant width
Used for Java class names, methods, variables, properties, data types, database elements, and snippets of code that appear
in text.

Constant width bold


Used for commands you enter at the command line and to highlight new code inserted in a running example.

1
http://www.sonatype.com
2
mailto:[email protected]
Constant width italic
Used to annotate output.

4. Maven Writing Conventions


The book follows certain conventions for naming and font usage in relation to Apache Maven. Understanding these conventions up-
front makes it easier to read this book.

Compiler plugin
Maven plugins are capitalized.

create goal
Maven goal names are displayed in a constant width font.

"plugin"
While "plug-in" (with hyphen) would be the grammatically correct form, this book writes the term as "plugin" both because
it is easier to read and write and because it is a standard throughout the Maven community.

Maven Lifecycle, Maven Standard Directory Layout, Maven Plugin, Project Object Model
Core Maven concepts are capitalized whenever they are being referenced in the text.

goalParameter
A Maven goal parameter is displayed in a constant width font.

compile phase
Lifecycle phases are displayed in a constant width font.

5. Acknowledgements
Sonatype would like to thank the following contributors. The people listed below have provided feedback which has helped improve
the quality of this book. Thanks to Raymond Toal, Steve Daly, Paul Strack, Paul Reinerfelt, Chad Gorshing, Marcus Biel, Brian
Dols, Mangalaganesh Balasubramanian, Marius Kruger, and Mark Stewart. Special thanks to Joel Costigliola for helping to debug
and correct the Spring web chapter. Stan Guillory was practically a contributing author given the number of corrections he posted
to the book's Get Satisfaction. Thank you Stan. Special thanks to Richard Coasby of Bamboo for acting as the provisional grammar
consultant.

Thanks to our contributing authors including Eric Redmond.

Thanks to the following contributors who reported errors either in an email or using the Get Satisfaction site: Paco Soberón, Ray
Krueger, Steinar Cook, Henning Saul, Anders Hammar, "george_007", "ksangani", Niko Mahle, Arun Kumar, Harold Shinsato,
"mimil", "-thrawn-", Matt Gumbley. If you see your Get Satisfaction username in this list, and you would like it replaced with your
real name, send an email to [email protected].

Special thanks to Grant Birchmeier for taking the time to proofread portions of the book and file extremely detailed feedback via
GetSatisfaction.

3
mailto:[email protected]

xx
Chapter 1. Introducing Apache Maven
Although there are a number of references for Maven online, there is no single, well-written narrative for introducing Maven that
can serve as both an authoritative reference and an introduction. What we’ve tried to do with this effort is provide such a narrative
coupled with useful reference material.

1.1. Maven... What is it?


The answer to this question depends on your own perspective. The great majority of Maven users are going to call Maven a “build
tool”: a tool used to build deployable artifacts from source code. Build engineers and project managers might refer to Maven as
something more comprehensive: a project management tool. What is the difference? A build tool such as Ant is focused solely on
preprocessing, compilation, packaging, testing, and distribution. A project management tool such as Maven provides a superset of
features found in a build tool. In addition to providing build capabilities, Maven can also run reports, generate a web site, and facilitate
communication among members of a working team.

A more formal definition of Apache Maven1: Maven is a project management tool which encompasses a project object model, a
set of standards, a project lifecycle, a dependency management system, and logic for executing plugin goals at defined phases in a
lifecycle. When you use Maven, you describe your project using a well-defined project object model, Maven can then apply cross-
cutting logic from a set of shared (or custom) plugins.

Don't let the fact that Maven is a "project management" tool scare you away. If you were just looking for a build tool, Maven will
do the job. In fact, the first few chapters of this book will deal with the most common use case: using Maven to build and distribute
your project.

1.2. Convention Over Configuration


Convention over configuration is a simple concept. Systems, libraries, and frameworks should assume reasonable defaults. Without
requiring unnecessary configuration, systems should "just work". Popular frameworks such as Ruby on Rails2 and EJB3 have started
to adhere to these principles in reaction to the configuration complexity of frameworks such as the initial EJB 2.1 specifications.
An illustration of convention over configuration is something like EJB3 persistence: all you need to do to make a particular bean
persistent is to annotate that class with @Entity. The framework assumes table and column names based on the name of the class
and the names of the properties. Hooks are provided for you to override these default, assumed names if the need arises, but, in most
cases, you will find that using the framework-supplied defaults results in a faster project execution.

Maven incorporates this concept by providing sensible default behavior for projects. Without customization, source code is assumed to
be in ${basedir}/src/main/java and resources are assumed to be in ${basedir}/src/main/resources. Tests are assumed
to be in ${basedir}/src/test, and a project is assumed to produce a JAR file. Maven assumes that you want the compile byte
code to ${basedir}/target/classes and then create a distributable JAR file in ${basedir}/target. While this might seem
trivial, consider the fact that most Ant-based builds have to define the locations of these directories. Ant doesn't ship with any built-
in idea of where source code or resources might be in a project; you have to supply this information. Maven's adoption of convention
over configuration goes farther than just simple directory locations, Maven's core plugins apply a common set of conventions for
compiling source code, packaging distributions, generating web sites, and many other processes. Maven's strength comes from the
fact that it is "opinionated", it has a defined life-cycle and a set of common plugins that know how to build and assemble software.
If you follow the conventions, Maven will require almost zero effort - just put your source in the correct directory, and Maven will
take care of the rest.

One side-effect of using systems that follow "convention over configuration" is that end-users might feel that they are forced to use a
particular methodology or approach. While it is certainly true that Maven has some core opinions that shouldn't be challenged, most
of the defaults can be customized. For example, the location of a project's source code and resources can be customized, names of
JAR files can be customized, and through the development of custom plugins, almost any behavior can be tailored to your specific

1
http://maven.apache.org
2
http://www.rubyonrails.org/
environment's requirements. If you don't care to follow convention, Maven will allow you to customize defaults in order to adapt
to your specific requirements.

1.3. A Common Interface


Before Maven provided a common interface for building software, every single project had someone dedicated to managing a fully
customized build system. Developers had to take time away from developing software to learn about the idiosyncrasies of each new
project they wanted to contribute to. In 2001, you'd have a completely different approach to building a project like Turbine3 than you
would to building a project like Tomcat4. If a new source code analysis tool came out that would perform static analysis on source
code, or if someone developed a new unit testing framework, everybody would have to drop what they were doing and figure out
how to fit it into each project's custom build environment. How do you run unit tests? There were a thousand different answers. This
environment was characterized by a thousand endless arguments about tools and build procedures. The age before Maven was an
age of inefficiency, the age of the "Build Engineer".

Today, most open source developers have used or are currently using Maven to manage new software projects. This transition is less
about developers moving from one build tool to another and more about developers starting to adopt a common interface for project
builds. As software systems have become more modular, build systems have become more complex, and the number of projects
has sky-rocketed. Before Maven, when you wanted to check out a project like Apache ActiveMQ5 or Apache ServiceMix6 from
Subversion and build it from source, you really had to set aside about an hour to figure out the build system for each particular project.
What does the project need to build? What libraries do I need to download? Where do I put them? What goals can I execute in the
build? In the best case, it took a few minutes to figure out a new project's build, and in the worst cases (like the old Servlet API
implementation in the Jakarta Project), a project's build was so difficult it would take multiple hours just to get to the point where a
new contributor could edit source and compile the project. These days, you check it out from source, and you run mvn install.

While Maven provides an array of benefits including dependency management and reuse of common build logic through plugins,
the core reason why it has succeeded is that it has defined a common interface for building software. When you see that a project like
Apache ActiveMQ7 uses Maven, you can assume that you'll be able to check it out from source and build it with mvn install without
much hassle. You know where the ignition keys goes, you know that the gas pedal is on the right-side, and the brake is on the left.

1.4. Universal Reuse through Maven Plugins


The core of Maven is pretty dumb, it doesn't know how to do much beyond parsing a few XML documents and keeping track of
a lifecycle and a few plugins. Maven has been designed to delegate most responsibility to a set of Maven Plugins which can affect
the Maven Lifecycle and offer access to goals. Most of the action in Maven happens in plugin goals which take care of things
like compiling source, packaging bytecode, publishing sites, and any other task which need to happen in a build. The Maven you
download from Apache doesn't know much about packaging a WAR file or running JUnit tests; most of the intelligence of Maven
is implemented in the plugins and the plugins are retrieved from the Maven Repository. In fact, the first time you ran something like
mvn install with a brand-new Maven installation it retrieved most of the core Maven plugins from the Central Maven Repository.
This is more than just a trick to minimize the download size of the Maven distribution, this is behavior which allows you to upgrade
a plugin to add capability to your project's build. The fact that Maven retrieves both dependencies and plugins from the remote
repository allows for universal reuse of build logic.

The Maven Surefire plugin is the plugin that is responsible for running unit tests. Somewhere between version 1.0 and the version
that is in wide use today someone decided to add support for the TestNG unit testing framework in addition to the support for JUnit.
This upgrade happened in a way that didn't break backwards compatibility. If you were using the Surefire plugin to compile and
execute JUnit 3 unit tests, and you upgraded to the most recent version of the Surefire plugin, your tests continued to execute without
fail. But, you gained new functionality, if you want to execute unit tests in TestNG you now have that ability. You also gained the
ability to run annotated JUnit 4 unit tests. You gained all of these capabilities without having to upgrade your Maven installation or

3
http://turbine.apache.org/
4
http://tomcat.apache.org
5
http://activemq.apache.org
6
http://servicemix.apache.org
7
http://wicket.apache.org

2
install new software. Most importantly, nothing about your project had to change aside from a version number for a plugin a single
Maven configuration file called the Project Object Model (POM).

It is this mechanism that affects much more than the Surefire plugin. Maven has plugins for everything from compiling Java code, to
generating reports, to deploying to an application server. Maven has abstracted common build tasks into plugins which are maintained
centrally and shared universally. If the state-of-the-art changes in any area of the build, if some new unit testing framework is released
or if some new tool is made available, you don't have to be the one to hack your project's custom build system to support it. You benefit
from the fact that plugins are downloaded from a remote repository and maintained centrally. This is what is meant by universal
reuse through Maven plugins.

1.5. Conceptual Model of a "Project"


Maven maintains a model of a project. You are not just compiling source code into bytecode, you are developing a description of a
software project and assigning a unique set of coordinates to a project. You are describing the attributes of the project. What is the
project's license? Who develops and contributes to the project? What other projects does this project depend upon? Maven is more
than just a "build tool", it is more than just an improvement on tools like make and Ant, it is a platform that encompasses a new
semantics related to software projects and software development. This definition of a model for every project enables such features as:

Dependency Management
Because a project is defined by a unique set of coordinates consisting of a group identifier, an artifact identifier, and a version,
projects can now use these coordinates to declare dependencies.

Remote Repositories
Related to dependency management, we can use the coordinates defined in the Maven Project Object Model (POM) to create
repositories of Maven artifacts.

Universal Reuse of Build Logic


Plugins contain logic that works with the descriptive data and configuration parameters defined in Project Object Model
(POM); they are not designed to operate upon specific files in known locations.

Tool Portability / Integration


Tools like Eclipse, NetBeans, and IntelliJ now have a common place to find information about a project. Before the advent
of Maven, every IDE had a different way to store what was essentially a custom Project Object Model (POM). Maven has
standardized this description, and while each IDE continues to maintain custom project files, they can be easily generated
from the model.

Easy Searching and Filtering of Project Artifacts


Tools like Nexus allow you to index and search the contents of a repository using the information stored in the POM.

1.6. Is Maven an alternative to XYZ?


So, sure, Maven is an alternative to Ant, but Apache Ant8 continues to be a great, widely-used tool. It has been the reigning champion
of Java builds for years, and you can integrate Ant build scripts with your project's Maven build very easily. This is a common usage
pattern for a Maven project. On the other hand, as more and more open source projects move to Maven as a project management
platform, working developers are starting to realize that Maven not only simplifies the task of build management, it is helping to
encourage a common interface between developers and software projects. Maven is more of a platform than a tool, while you could
consider Maven an alternative to Ant, you are comparing apples to oranges. "Maven" includes more than just a build tool.

This is the central point that makes all of the Maven vs. Ant, Maven vs. Buildr, Maven vs. Gradle arguments irrelevant. Maven isn't
totally defined by the mechanics of your build system. It isn't about scripting the various tasks in your build as much as it is about
encouraging a set of standards, a common interface, a life-cycle, a standard repository format, a standard directory layout, etc. It
certainly isn't about what format the POM happens to be in (XML vs. YAML vs. Ruby). Maven is much larger than that, and Maven
refers to much more than the tool itself. When this book talks of Maven, it is referring to the constellation of software, systems, and

8
http://ant.apache.org

3
standards that support it. Buildr, Ivy, Gradle, all of these tools interact with the repository format that Maven helped create, and you
could just as easily use a repository manager like Nexus to support a build written entirely in Ant.

While Maven is an alternative to many of these tools, the community needs to evolve beyond seeing technology as a zero-sum game
between unfriendly competitors in a competition for users and developers. This might be how large corporations relate to one another,
but it has very little relevance to the way that open source communities work. The headline "Who's winning? Ant or Maven?" isn't
very constructive. If you force us to answer this question, we're definitely going to say that Maven is a superior alternative to Ant
as a foundational technology for a build; at the same time, Maven's boundaries are constantly shifting and the Maven community is
constantly trying to seek out new ways to become more ecumenical, more inter-operable, more cooperative. The core tenets of Maven
are declarative builds, dependency management, repository managers, universal reuse through plugins, but the specific incarnation
of these ideas at any given moment is less important than the sense that the open source community is collaborating to reduce the
inefficiency of "enterprise-scale builds".

1.7. Comparing Maven with Ant


The authors of this book have no interest in creating a feud between Apache Ant and Apache Maven, but we are also cognizant of
the fact that most organizations have to make a decision between the two standard solutions: Apache Ant and Apache Maven. In
this section, we compare and contrast the tools.

Ant excels at build process, it is a build system modeled after make with targets and dependencies. Each target consists of a set of
instructions which are coded in XML. There is a copy task and a javac task as well as a jar task. When you use Ant, you supply
Ant with specific instructions for compiling and packaging your output. Look at the following example of a simple build.xml file:

Example 1.1. A Simple Ant build.xml file

<project name="my-project" default="dist" basedir=".">


<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="src" location="src/main/java"/>
<property name="build" location="target/classes"/>
<property name="dist" location="target"/>

<target name="init">
<!-- Create the time stamp -->
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
</target>

<target name="compile" depends="init"


description="compile the source " >
<!-- Compile the java code from ${src} into ${build} -->
<javac srcdir="${src}" destdir="${build}"/>
</target>

<target name="dist" depends="compile"


description="generate the distribution" >
<!-- Create the distribution directory -->
<mkdir dir="${dist}/lib"/>

<!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->


<jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>
</target>

<target name="clean"
description="clean up" >
<!-- Delete the ${build} and ${dist} directory trees -->
<delete dir="${build}"/>
<delete dir="${dist}"/>
</target>

4
Another random document with
no related content on Scribd:
the lake to the merciful goodness of that Providence who is "the God of the
fatherless and the widow."

Meanwhile the little vessel was battling with the angry waves in a place
where there was a narrow passage, some fifty yards broad, between two
dangerous shelving sandbanks, well known to the master of the Katharine
and his crew. The sandbanks themselves, as it happened, lay partly under
the lee of one of the little islands which stud the coast near Lachta; and the
current was bearing strong upon the bank upon the leeward. At this moment
the Katharine shipped a large quantity of water; as ill-luck would have it,
the tiller broke, and before the boat's head could be righted she had drifted
upon the edge of the bar of sand, and there she stuck fast. The little bark
would have been overwhelmed by the breakers but for the shelter afforded
by the corner of the island and the shifting of the wind a point or two round
to the north; indeed she was fast filling with water, in spite of the efforts of
the passengers to keep her afloat by bailing. To add to the general confusion
on board, it now turned out that several of the passengers, who had been
drinking at the village inn before starting from Lachta, were fairly
intoxicated, and the rest were sinking down bewildered into the apathy of
despair, so that only Stephen and two of the boatmen had their wits about
them. But though they strove with all their might, they were unable to move
the boat from off the sandbank. At this moment, when the waves were
breaking over the little Katharine, and had already swept off into deep
water one or two hapless passengers, who had lost all heart and courage, a
sail was seen approaching.

It was rather a large vessel, with a gallant crew of some twenty men,
who had been inspecting a portion of the coast. They had seen the perilous
position of old Paul and his boat, and had borne down to his assistance, for
in spite of the terrible raging of the wind and waves the captain could not
see the poor fellows swept away one by one and drowned without at least
making an effort to save them.

The vessel neared the sandbank; but how may she approach close
enough to rescue the unfortunate fellows on board the Katharine? A boat is
lowered from the vessel, and four as gallant Russian sailors as ever
ploughed the fresh waters of Ladoga or the Baltic have rowed up to the
spot; but the strength of two of the crew, added to the exertions of Stephen
and the boatmen of the Katharine, are not sufficient to move the boat from
the firm grasp with which the sand held her keel. They were, therefore,
beginning to relax their efforts, when a second boat, with a crew of six
stout-hearted fellows, neared the bank, and by vigorous efforts reached the
spot in time to reinforce their comrades. Without the loss of a moment, one
of the crew, a fine tall muscular Russian, some six feet five inches high,
stripped off his outer garments, leaped into the sea, and after swimming a
few sharp strokes gained a footing on the sand. This was heavy work
indeed, as the sand was not hard and firm, but mixed with mud and slime;
but the giant strength of the new arrival turned the scale, and after a few
short and sharp heaves the Katharine moved once more. In a few moments
she was afloat again, and taken in tow by the other boat.

And where was Stephen all this time? Worn out with fatigue and cold,
for he had been immersed some two hours in the chilly waves, and standing
in deep water and nearly exhausted by their violence, he had lost his footing
on the slippery bank, and having got in a moment beyond his depth was
vainly attempting to keep his head above water by swimming in his
drenched and dripping clothes, the weight of which in a few minutes more
would have carried him down.

"Oh! Steenie, Steenie!" cried the old boatman, Paul, with a loud voice of
agony, which would make itself heard even above the roaring of the angry
wind and waves; "can none of you save my poor Stephen, the bravest lad
that ever trod a deck! He's gone now; and but for his help this day my boat
would have been lost."

"He's not lost yet!" cried the tall seaman; and, plunging into the waves,
he caught him by the hair of the head just as he was sinking a third time; the
next wave would have carried him fairly down, and his life would have
been gone beyond recall.

It was but the work of a moment for the strong, tall stranger to swim
with the lad towards the boat, which was hovering near; and in another
second the gallant crew had lifted him in over the gunwale and laid him at
the bottom of the boat. As soon as he showed signs of life, and began to
open his eyes, a flask of brandy was applied to his mouth, and he soon
revived. The tall man, too, got in, and leaving two of his crew to help old
Paul to tow the Katharine ashore, he gave the signal to his men, and they
pulled off with all their might in the direction of Lachta. Though the waves
were still running high, yet, fortunately, the wind was astern; so the sharp,
quick strokes of the crew soon brought the boat to a landing-place from
which, a few hours before, poor Stephen had departed in such high spirits,
and with such confidence in Paul's seamanship and the ability of the
Katharine to make the passage.

As soon as the boat came to the sheltered nook where the steps of the
landing-place led up from the sea, Stephen was put ashore, and partly led
and partly carried he reached the cottage of his mother. At the sight of her
son the poor widow burst into a flood of tears, and began to give way to an
agony of joy and grief. A warm bath was soon prepared for her son; and
after the application of some gentle restoratives poor Stephen was able to sit
up and thank his kind preserver, the tall stranger, who, with his two men
behind him, just now lifted up the latch of the cottage-door and had entered
the room.

"Gracious Heaven!" exclaimed the grateful mother; "why, sir, you are in
wet clothes too! Sit down, sir, by the fire, and accept of my humble fare,
while I go and find some of my Steenie's clothes for you to put on, and I dry
those dripping garments."

The tall stranger sat down, and, as the widow left the room, gave his two
followers a hint not to make known to the boy or his mother who he was. In
a few minutes the stranger had retired, and assumed a plain old suit
belonging to the young man whose life he had saved, and was engaged in
eating some hot bacon which the widow had just placed on the table before
him, with many protestations of her eternal gratitude to the saviour of her
son.

"May the King of Heaven, who never turns a deaf ear to the widow's
prayer, mercifully reward you for saving my Steenie's life! It is not many a
sailor, or merchant either, that would have done as you did to-day. Heaven
speed you; and may you never forget that the poor widow of Lachta is
praying for you night and morning, that the Almighty may increase your
store, whenever you are sailing over the stormy sea, or the lakes of Onega
and Ladoga."

The tall stranger was about to rise and depart, when suddenly the door
opened, and a naval officer entered with a crowd of attendants. It was the
captain and mate of the barque which Paul and Steenie had seen in the
offing, and which had sent her boats to the rescue of the Katharine.

"My noble master, may it please your majesty," he said, falling on one
knee, "the Royal Peter has come safe, and she has towed the Katharine too
into the little port of Lachta."

The poor widow fell down upon her knees in astonishment, and faltered
forth her apologies for not having recognized his majesty, and for having
treated him with such apparent disrespect.

"Nay, nay, my good woman," said the czar, smiling, "how could you
know the emperor thus disguised in mud and dirt. But you will know him
henceforth. I shall keep your son's clothes in remembrance of this day; and
when your boy 'Steenie,' as you call him, wakes up from the sound sleep
into which he has fallen, tell him that he will always find a true friend in
Peter Alexovitch."

Our readers when they learn that the foregoing story is founded upon a
plain historical fact—as they will find upon reading for themselves the
"Life of Peter the Great,"—will be grieved to hear that the noble conduct of
the emperor on this occasion cost him his life. He had for a long time
suffered under a chronic internal disease, which none of the court
physicians could effectually combat; and in the month of November, 1724,
in which our story is laid, having gone, contrary to the advice of his
physicians, to inspect the works on Lake Ladoga, his exposure to the wet
and cold, in rescuing the poor ferryman and his crew in the manner related,
affected him so seriously that he never afterwards recovered. The emperor
went home to his palace at St. Petersburg without loss of time, but his
malady increased in spite of all the remedies which the medical skill of
Russia could furnish; and gradually he sank under the disease, till death put
an end to his sufferings towards the close of the following January.

Such was the end of Peter I. of Russia, deservedly named the "Great;"
though he was the strangest compound of contradictions, perhaps, that the
world has ever seen. In him the most ludicrous undertakings were mingled
with the grandest political schemes. Benevolence and humanity were as
conspicuous in his character as a total disregard of human life. He was at
once kind-hearted and severe, even to the extent of ferocity. Without
education himself he promoted arts, sciences, and literature. "He gave,"
says one of his biographers, "a polish to his people, and yet he was himself
a savage; he taught them the art of war, of which, however, he was himself
ignorant; from the sight of a small boat on the river Moskwa he created a
powerful fleet, and made himself an expert and active shipwright, sailor,
pilot, and commander; he changed the manners, customs, and laws of the
Russians, and lives in their memory, not merely as the founder of their
empire, but as the father of his country."

Yes; the memory of Peter the Great to this day is dear among all classes
of the Russians, from the noblest of the Boyards down to the meanest
peasant. But if among the towns and villages of his vast empire there be one
in which his name is cherished with especial honour, it is that little fishing
town of Lachta; and in proof of our assertion we may add, that the cottage
in which "Steenie" and his mother lived and died is still familiarly known to
every traveller in those parts as "Peter's House."
*** END OF THE PROJECT GUTENBERG EBOOK SASHA THE
SERF, AND OTHER STORIES OF RUSSIAN LIFE ***

Updated editions will replace the previous one—the old editions will
be renamed.

Creating the works from print editions not protected by U.S.


copyright law means that no one owns a United States copyright in
these works, so the Foundation (and you!) can copy and distribute it
in the United States without permission and without paying copyright
royalties. Special rules, set forth in the General Terms of Use part of
this license, apply to copying and distributing Project Gutenberg™
electronic works to protect the PROJECT GUTENBERG™ concept
and trademark. Project Gutenberg is a registered trademark, and
may not be used if you charge for an eBook, except by following the
terms of the trademark license, including paying royalties for use of
the Project Gutenberg trademark. If you do not charge anything for
copies of this eBook, complying with the trademark license is very
easy. You may use this eBook for nearly any purpose such as
creation of derivative works, reports, performances and research.
Project Gutenberg eBooks may be modified and printed and given
away—you may do practically ANYTHING in the United States with
eBooks not protected by U.S. copyright law. Redistribution is subject
to the trademark license, especially commercial redistribution.

START: FULL LICENSE


THE FULL PROJECT GUTENBERG LICENSE
PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK

To protect the Project Gutenberg™ mission of promoting the free


distribution of electronic works, by using or distributing this work (or
any other work associated in any way with the phrase “Project
Gutenberg”), you agree to comply with all the terms of the Full
Project Gutenberg™ License available with this file or online at
www.gutenberg.org/license.

Section 1. General Terms of Use and


Redistributing Project Gutenberg™
electronic works
1.A. By reading or using any part of this Project Gutenberg™
electronic work, you indicate that you have read, understand, agree
to and accept all the terms of this license and intellectual property
(trademark/copyright) agreement. If you do not agree to abide by all
the terms of this agreement, you must cease using and return or
destroy all copies of Project Gutenberg™ electronic works in your
possession. If you paid a fee for obtaining a copy of or access to a
Project Gutenberg™ electronic work and you do not agree to be
bound by the terms of this agreement, you may obtain a refund from
the person or entity to whom you paid the fee as set forth in
paragraph 1.E.8.

1.B. “Project Gutenberg” is a registered trademark. It may only be


used on or associated in any way with an electronic work by people
who agree to be bound by the terms of this agreement. There are a
few things that you can do with most Project Gutenberg™ electronic
works even without complying with the full terms of this agreement.
See paragraph 1.C below. There are a lot of things you can do with
Project Gutenberg™ electronic works if you follow the terms of this
agreement and help preserve free future access to Project
Gutenberg™ electronic works. See paragraph 1.E below.
1.C. The Project Gutenberg Literary Archive Foundation (“the
Foundation” or PGLAF), owns a compilation copyright in the
collection of Project Gutenberg™ electronic works. Nearly all the
individual works in the collection are in the public domain in the
United States. If an individual work is unprotected by copyright law in
the United States and you are located in the United States, we do
not claim a right to prevent you from copying, distributing,
performing, displaying or creating derivative works based on the
work as long as all references to Project Gutenberg are removed. Of
course, we hope that you will support the Project Gutenberg™
mission of promoting free access to electronic works by freely
sharing Project Gutenberg™ works in compliance with the terms of
this agreement for keeping the Project Gutenberg™ name
associated with the work. You can easily comply with the terms of
this agreement by keeping this work in the same format with its
attached full Project Gutenberg™ License when you share it without
charge with others.

1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the terms
of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.

1.E. Unless you have removed all references to Project Gutenberg:

1.E.1. The following sentence, with active links to, or other


immediate access to, the full Project Gutenberg™ License must
appear prominently whenever any copy of a Project Gutenberg™
work (any work on which the phrase “Project Gutenberg” appears, or
with which the phrase “Project Gutenberg” is associated) is
accessed, displayed, performed, viewed, copied or distributed:
This eBook is for the use of anyone anywhere in the United
States and most other parts of the world at no cost and with
almost no restrictions whatsoever. You may copy it, give it away
or re-use it under the terms of the Project Gutenberg License
included with this eBook or online at www.gutenberg.org. If you
are not located in the United States, you will have to check the
laws of the country where you are located before using this
eBook.

1.E.2. If an individual Project Gutenberg™ electronic work is derived


from texts not protected by U.S. copyright law (does not contain a
notice indicating that it is posted with permission of the copyright
holder), the work can be copied and distributed to anyone in the
United States without paying any fees or charges. If you are
redistributing or providing access to a work with the phrase “Project
Gutenberg” associated with or appearing on the work, you must
comply either with the requirements of paragraphs 1.E.1 through
1.E.7 or obtain permission for the use of the work and the Project
Gutenberg™ trademark as set forth in paragraphs 1.E.8 or 1.E.9.

1.E.3. If an individual Project Gutenberg™ electronic work is posted


with the permission of the copyright holder, your use and distribution
must comply with both paragraphs 1.E.1 through 1.E.7 and any
additional terms imposed by the copyright holder. Additional terms
will be linked to the Project Gutenberg™ License for all works posted
with the permission of the copyright holder found at the beginning of
this work.

1.E.4. Do not unlink or detach or remove the full Project


Gutenberg™ License terms from this work, or any files containing a
part of this work or any other work associated with Project
Gutenberg™.

1.E.5. Do not copy, display, perform, distribute or redistribute this


electronic work, or any part of this electronic work, without
prominently displaying the sentence set forth in paragraph 1.E.1 with
active links or immediate access to the full terms of the Project
Gutenberg™ License.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or expense
to the user, provide a copy, a means of exporting a copy, or a means
of obtaining a copy upon request, of the work in its original “Plain
Vanilla ASCII” or other form. Any alternate format must include the
full Project Gutenberg™ License as specified in paragraph 1.E.1.

1.E.7. Do not charge a fee for access to, viewing, displaying,


performing, copying or distributing any Project Gutenberg™ works
unless you comply with paragraph 1.E.8 or 1.E.9.

1.E.8. You may charge a reasonable fee for copies of or providing


access to or distributing Project Gutenberg™ electronic works
provided that:

• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”

• You provide a full refund of any money paid by a user who


notifies you in writing (or by e-mail) within 30 days of receipt that
s/he does not agree to the terms of the full Project Gutenberg™
License. You must require such a user to return or destroy all
copies of the works possessed in a physical medium and
discontinue all use of and all access to other copies of Project
Gutenberg™ works.

• You provide, in accordance with paragraph 1.F.3, a full refund of


any money paid for a work or a replacement copy, if a defect in
the electronic work is discovered and reported to you within 90
days of receipt of the work.

• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.

1.E.9. If you wish to charge a fee or distribute a Project Gutenberg™


electronic work or group of works on different terms than are set
forth in this agreement, you must obtain permission in writing from
the Project Gutenberg Literary Archive Foundation, the manager of
the Project Gutenberg™ trademark. Contact the Foundation as set
forth in Section 3 below.

1.F.

1.F.1. Project Gutenberg volunteers and employees expend


considerable effort to identify, do copyright research on, transcribe
and proofread works not protected by U.S. copyright law in creating
the Project Gutenberg™ collection. Despite these efforts, Project
Gutenberg™ electronic works, and the medium on which they may
be stored, may contain “Defects,” such as, but not limited to,
incomplete, inaccurate or corrupt data, transcription errors, a
copyright or other intellectual property infringement, a defective or
damaged disk or other medium, a computer virus, or computer
codes that damage or cannot be read by your equipment.

1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except


for the “Right of Replacement or Refund” described in paragraph
1.F.3, the Project Gutenberg Literary Archive Foundation, the owner
of the Project Gutenberg™ trademark, and any other party
distributing a Project Gutenberg™ electronic work under this
agreement, disclaim all liability to you for damages, costs and
expenses, including legal fees. YOU AGREE THAT YOU HAVE NO
REMEDIES FOR NEGLIGENCE, STRICT LIABILITY, BREACH OF
WARRANTY OR BREACH OF CONTRACT EXCEPT THOSE
PROVIDED IN PARAGRAPH 1.F.3. YOU AGREE THAT THE
FOUNDATION, THE TRADEMARK OWNER, AND ANY
DISTRIBUTOR UNDER THIS AGREEMENT WILL NOT BE LIABLE
TO YOU FOR ACTUAL, DIRECT, INDIRECT, CONSEQUENTIAL,
PUNITIVE OR INCIDENTAL DAMAGES EVEN IF YOU GIVE
NOTICE OF THE POSSIBILITY OF SUCH DAMAGE.

1.F.3. LIMITED RIGHT OF REPLACEMENT OR REFUND - If you


discover a defect in this electronic work within 90 days of receiving it,
you can receive a refund of the money (if any) you paid for it by
sending a written explanation to the person you received the work
from. If you received the work on a physical medium, you must
return the medium with your written explanation. The person or entity
that provided you with the defective work may elect to provide a
replacement copy in lieu of a refund. If you received the work
electronically, the person or entity providing it to you may choose to
give you a second opportunity to receive the work electronically in
lieu of a refund. If the second copy is also defective, you may
demand a refund in writing without further opportunities to fix the
problem.

1.F.4. Except for the limited right of replacement or refund set forth in
paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.

1.F.5. Some states do not allow disclaimers of certain implied


warranties or the exclusion or limitation of certain types of damages.
If any disclaimer or limitation set forth in this agreement violates the
law of the state applicable to this agreement, the agreement shall be
interpreted to make the maximum disclaimer or limitation permitted
by the applicable state law. The invalidity or unenforceability of any
provision of this agreement shall not void the remaining provisions.
1.F.6. INDEMNITY - You agree to indemnify and hold the
Foundation, the trademark owner, any agent or employee of the
Foundation, anyone providing copies of Project Gutenberg™
electronic works in accordance with this agreement, and any
volunteers associated with the production, promotion and distribution
of Project Gutenberg™ electronic works, harmless from all liability,
costs and expenses, including legal fees, that arise directly or
indirectly from any of the following which you do or cause to occur:
(a) distribution of this or any Project Gutenberg™ work, (b)
alteration, modification, or additions or deletions to any Project
Gutenberg™ work, and (c) any Defect you cause.

Section 2. Information about the Mission of


Project Gutenberg™
Project Gutenberg™ is synonymous with the free distribution of
electronic works in formats readable by the widest variety of
computers including obsolete, old, middle-aged and new computers.
It exists because of the efforts of hundreds of volunteers and
donations from people in all walks of life.

Volunteers and financial support to provide volunteers with the


assistance they need are critical to reaching Project Gutenberg™’s
goals and ensuring that the Project Gutenberg™ collection will
remain freely available for generations to come. In 2001, the Project
Gutenberg Literary Archive Foundation was created to provide a
secure and permanent future for Project Gutenberg™ and future
generations. To learn more about the Project Gutenberg Literary
Archive Foundation and how your efforts and donations can help,
see Sections 3 and 4 and the Foundation information page at
www.gutenberg.org.

Section 3. Information about the Project


Gutenberg Literary Archive Foundation
The Project Gutenberg Literary Archive Foundation is a non-profit
501(c)(3) educational corporation organized under the laws of the
state of Mississippi and granted tax exempt status by the Internal
Revenue Service. The Foundation’s EIN or federal tax identification
number is 64-6221541. Contributions to the Project Gutenberg
Literary Archive Foundation are tax deductible to the full extent
permitted by U.S. federal laws and your state’s laws.

The Foundation’s business office is located at 809 North 1500 West,


Salt Lake City, UT 84116, (801) 596-1887. Email contact links and up
to date contact information can be found at the Foundation’s website
and official page at www.gutenberg.org/contact

Section 4. Information about Donations to


the Project Gutenberg Literary Archive
Foundation
Project Gutenberg™ depends upon and cannot survive without
widespread public support and donations to carry out its mission of
increasing the number of public domain and licensed works that can
be freely distributed in machine-readable form accessible by the
widest array of equipment including outdated equipment. Many small
donations ($1 to $5,000) are particularly important to maintaining tax
exempt status with the IRS.

The Foundation is committed to complying with the laws regulating


charities and charitable donations in all 50 states of the United
States. Compliance requirements are not uniform and it takes a
considerable effort, much paperwork and many fees to meet and
keep up with these requirements. We do not solicit donations in
locations where we have not received written confirmation of
compliance. To SEND DONATIONS or determine the status of
compliance for any particular state visit www.gutenberg.org/donate.

While we cannot and do not solicit contributions from states where


we have not met the solicitation requirements, we know of no
prohibition against accepting unsolicited donations from donors in
such states who approach us with offers to donate.

International donations are gratefully accepted, but we cannot make


any statements concerning tax treatment of donations received from
outside the United States. U.S. laws alone swamp our small staff.

Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.

Section 5. General Information About Project


Gutenberg™ electronic works
Professor Michael S. Hart was the originator of the Project
Gutenberg™ concept of a library of electronic works that could be
freely shared with anyone. For forty years, he produced and
distributed Project Gutenberg™ eBooks with only a loose network of
volunteer support.

Project Gutenberg™ eBooks are often created from several printed


editions, all of which are confirmed as not protected by copyright in
the U.S. unless a copyright notice is included. Thus, we do not
necessarily keep eBooks in compliance with any particular paper
edition.

Most people start at our website which has the main PG search
facility: www.gutenberg.org.

This website includes information about Project Gutenberg™,


including how to make donations to the Project Gutenberg Literary
Archive Foundation, how to help produce our new eBooks, and how
to subscribe to our email newsletter to hear about new eBooks.

You might also like