• Save
Maven 2 features
Upcoming SlideShare
Loading in...5
×
 

Maven 2 features

on

  • 4,446 views

This presentation tries to show the main features in Maven 2

This presentation tries to show the main features in Maven 2

Statistics

Views

Total Views
4,446
Views on SlideShare
4,389
Embed Views
57

Actions

Likes
6
Downloads
57
Comments
2

3 Embeds 57

http://www.techiegyan.com 39
http://www.slideshare.net 17
http://static.slideshare.net 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Maven 2 features Maven 2 features Presentation Transcript

  • A Pragmatic View Presentation by Angel Ruiz Calvo
  • Index
    • What is Maven 2?
    • What does it provide?
    • Comparison with Ant.
    • Examples.
    • Installation.
    • Conclusions.
    • References.
    • Questions.
  • What is Maven 2? View slide
    • Formal definition:
      • “ 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 plug-in 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) plug-ins”.
    • My definition:
      • It is a project management tool that helps us in all the stages of the SDLC applying the principle of “Convention over Configuration” that simplifies many common issues involved in the development of any project.
    What is Maven 2? View slide
  • What does it provide?
  • What does it provide?
    • Convention over configuration:
      • Systems, libraries, and frameworks should assume reasonable defaults without requiring unnecessary configuration to " just work ".
    • Under this premise it provides:
      • Conceptual model of a project: P.O.M.
      • Plug-in based extensibility.
      • Standard project structure
      • Standard project identification.
      • Dependency Management
      • Repository Management
      • Project initialization: Archetypes.
      • IDE Portability and Integration.
      • Project configuration (JDK compilation level, SCM, Bug tracking, mailing lists, developers …).
      • Simplify and unify the process for documentation distribution and maintenance.
  • What does it provide?
    • Conceptual model of a project: P.O.M.
      • P.O.M. = Project Object Model.
      • Maven projects are describes using a single file called pom.xml
      • This conceptual model is described using an XMLSchema.
      • Within this P.O.M. file you can define the following project information:
        • General project info: name, artifact, …
        • Customized configuration for each SDLC step: packaging, jdk, …
        • Dependencies.
        • External tools:
          • Mailing lists.
          • S.C,M. tool.
          • Bug tracking
        • Repository configuration: usually delegated on settings.xml file
  • What does it provide?
    • Conceptual model of a project: P.O.M.
  • What does it provide?
    • Plug-in based extensibility
      • 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.
      • mvn war:war
    Plug-in name Goal
  • What does it provide?
    • Plug-in based extensibility
      • The Maven Lifecycle.
  • What does it provide?
    • Plug-in based extensibility
      • The real value.
    Plug-ins Core
    • Clean
    • Compiler
    • Deploy
    • Install
    • Resources
    • Site
    • Surefire
    • Verifier
    Tools
    • Ant
    • Antlr
    • Antrun
    • Archetype
    • Assembly
    • Help
    • Release
    • SCM
    • XDoclet
    • Changelog
    • Changes
    • Checkstyle
    • Clover
    • Javadocs
    • PMD
    • Surefire-reports
    Reporting
    • Cargo
    • Jaxme
    • Jetty
    • Tomcat
    • Ear
    • Ejb
    • Jar
    • Rar
    • War
    • Eclipse
    • IDEA
    Others Packaging Integration
  • What does it provide?
    • Standard project structure :
    • Flexible.
    • Clean
    • Standard.
    • Easy to understand.
  • What does it provide?
    • Standard project identification
      • Artifact = maven project coordinates
      • Essential for dependency management.
    <project> <modelVersion>4.0.0</modelVersion> <groupId> au.com.sra </groupId> <artifactId> sra.commons </artifactId> <version> 0.0.1-SNAPSHOT </version> </project> groupId artifactId version
  • What does it provide?
    • Standard project identification
      • Versioning nomenclature system:
    X Y Z This identifier is used when the project is currently under active development . artifactId version Package (JAR / WAR / EAR) sra-commons - 0.0.1 - SNAPSHOT .jar
    • Bugfixes
    • Minor: fixes and adds
    • Mayor: no backward compatibility
  • What does it provide?
    • Standard project identification
      • How can we look for artifacts: http:// www.mvnrepository.com /
  • What does it provide?
    • Dependency Management
      • Based on maven project coordinates.
      • It also implies a new and important parameter called Dependency Scope
    <project> … <dependencies> <dependency> <groupId> au.com.sra </groupId> <artifactId> sra.commons </artifactId> <version> 0.0.1-SNAPSHOT </version> <scope> compile </scope> </dependency> … </dependencies> </project>
    • compile (default)
    • provided
    • runtime
    • test
    • system
  • What does it provide?
    • Dependency Management
      • There are some other concepts regarding dependency management:
        • Transitive dependencies:
        • Optional dependencies:
    • Conflict resolution and dependency exclusion:
    • Dependency version range:
    • Multi-module projects:
    Dependency A Dependency B Dependency C
  • What does it provide?
    • Repository Management
      • With this feature you won’t have to maintain all the libs you are using in your SCM tool and you will reference them from a single common point.
      • By default Maven uses a local repository that is fed from the Maven Central repository or any other public Maven repository on the Internet, you may have configured in your settings.xml file.
      • By default this local repository is at ${user_home}/.m2/repository , but it is configurable.
      • In order to avoid multiple internet access to download the same file and also to get faster download speed we will use a Repository Manager that acts like a proxy between our office and the public Maven repositories.
      • It also provides a good platform to have all the company releases available and well identified.
  • What does it provide?
    • Repository Management
      • The chosen repository management tool is called NEXUS from Sonatype: http://actdec01:8081/nexus
  • What does it provide?
    • Project initialization: Archetypes
      • An archetype is a template for a Maven project which is used by the Maven Archetype plug-in to create new projects.
      • Archetypes can also be useful within an organization that wants to encourage standards across a series of similar and related projects.
      • mvn archetype:create -DgroupId=org.apache.maven.archetypes
      • -DartifactId=maven-archetype-webapp
  • What does it provide?
    • IDE Portability and 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.
      • Integration can be performed in both ways:
        • Maven plugin:
        • IDE plugin:
      • mvn eclipse:eclipse
    Built-in plug-in Built-in plug-in
  • What does it provide?
    • Simplify and unify the process for documentation distribution and maintenance
      • Maven site plug-in + reports
  • Comparison with Ant
  • Comparison with Ant
    • Two complementary tools
      • Maven is definitely better for all the tasks related to the project building process.
      • Ant is better for all the rest programmatic tasks.
    Maven has conventions, it already knew where your source code was because you followed the convention. It put the bytecode in target/classes, and it produced a JAR file in target. Ant doesn't have formal conventions like a common project directory structure, you have to tell Ant exactly where to find the source and where to put the output. Informal conventions have emerged over time, but they haven't been codified into the product. Maven has a lifecycle, which you invoked when you executed mvn install. This command told Maven to execute the a series of sequence steps until it reached the lifecycle. As a side-effect of this journey through the lifecycle, Maven executed a number of default plugin goals which did things like compile and create a JAR. Ant doesn't have a lifecycle, you had to define goals and goal dependencies. You had to attach a sequence of tasks to each goal manually Maven is declarative . All you had to do was create a pom.xml file and put your source in the default directory. Maven took care of the rest. Ant is procedural , you have to tell Ant exactly hat to do and when to do it. You had to tell it to compile, then copy, then compress …
  • Comparison with Ant
    • Comparison thorough and example to build a jar file
      • mvn package
  • Examples
  • Installation
  • Installation
    • Steps to install Maven
      • Download the latest version of Maven (currently is 2.0.9).
      • Unzip the file.
      • Put the bin folder into the system path variable.
      • Execute the following command to check that the mvn command is available:
      • Download the latest settings.xml file from the SRA wiki and place it at ${user_home}/.m2
      • The repository will be at C:.m2 epository
      • You also can find this instructions at the SRA Wiki.
      • mvn -version
  • Conclusions
  • Conclusions
    • Do not spend too much time defining procedures that are already modeled in Maven.
    • Maven is the result of many experienced professionals.
    • Maven is unquestionably linked to the following concepts:
    methodology standarization productivity agility usability quality control
  • References
  • References
    • Maven portal
    • Maven: The definitive guide
    • Better builds with Maven
    • m2Eclipse plug-in
  • Questions