Using Maven 2 Andreas Andreou [email_address] amplafi.com, co-founder apache tapestry, committer – PMC
History Alexandria Forrest Gump Maven Turbine Tomcat Ant James Duncan Davidson, Sam Ruby, Jason van Zyl, Bob McWhirter
What is Maven? Project management tool = more than a build tool POM (project object model) Dependency management system Convention over configuration Project lifecycle Execution logic for each phase in lifecycle
POM Project coordinates  groupId artifactId version packaging (jar, war, ear, maven-plugin, …) Project info (developers, website, scm url) Dependencies Plugins
Installing Maven Download / extract zip Set  M2_HOME  env-var  Add M2_HOME/bin to path Folders created when maven is used: USER_HOME/.m2/repository/ USER_HOME/.m2/settings.xml
Simplest pom.xml <project> <modelVersion> 4.0.0 </modelVersion> <groupId> gr.jhug </groupId> <artifactId> javabb </artifactId> <version> 1.0-SNAPSHOT </version> <packaging> jar </packaging> <name> PHPBB-NUKE-killer </name> </project> src/main/ src/main/java/ src/main/resources/ src/test/ src/test/java src/test/resources
Maven Lifecycle validate generate-sources process-resources compile test-compile test package install verify deploy Maven execution needs phase and runs all previous: mvn compile …  or standalone plugin goal: mvn jetty:run mvn scm:update
Some more plugins maven-clean-plugin maven-compiler-plugin maven-jar-plugin maven-war-plugin maven-dependency-plugin maven-release-plugin maven-source-plugin maven-surefire-plugin maven-ant-plugin maven-archetype-plugin maven-checkstyle-plugin maven-pmd-plugin
Dependencies Uses groupId, artifactId, version Supports transitive dependencies Needs correct usage of ‘scope’ compile test provided runtime system Retrieved from public locations (ibiblio, e.t.c.) Stored on local repo (~/.m2/repository/)
Versions in Dependencies <major>.<minor>.<revision> ([ -<qualifier> ] | [ -<build> ]) 4.1.6 4.1.6-SNAPSHOT [4.1.6,5) If same dependency included more than once (how???), biggest wins
Maven & IDEs Supported in all major IDEs From pom.xml generate IDE specific files mvn eclipse:eclipse mvn idea:idea Directly read pom.xml and setup project 2 plugins for eclipse: m2eclipse, q4e Bundled plugin in IDEA Plugin from update center for Netbeans …  but maven is (still) more powerful!
Repository Manager Proxies between your organization and the public Maven repositories Deployment destination for your own generated artifacts Sonatype Nexus Maven Archiva Artifactory
Links http://ant.apache.org/faq.html http://maven.apache.org/background/history-of-maven.html http://jakarta.apache.org/alexandria/legacy/ http://gump.apache.org/why.html http://www.sonatype.com/books/maven-book/index.html http://maven.apache.org/repository-management.html http://delicious.com/andyhot/maven
Demo - Q&A
Companies sonatype.com Jason van Zyl, Mark de Visser, Brian Fox, John Casey Nexus, m2eclipse Exist <- DevZuz <- Mergere Brett Porter, Carlos Sanchez q4e

Using Maven 2

  • 1.
    Using Maven 2Andreas Andreou [email_address] amplafi.com, co-founder apache tapestry, committer – PMC
  • 2.
    History Alexandria ForrestGump Maven Turbine Tomcat Ant James Duncan Davidson, Sam Ruby, Jason van Zyl, Bob McWhirter
  • 3.
    What is Maven?Project management tool = more than a build tool POM (project object model) Dependency management system Convention over configuration Project lifecycle Execution logic for each phase in lifecycle
  • 4.
    POM Project coordinates groupId artifactId version packaging (jar, war, ear, maven-plugin, …) Project info (developers, website, scm url) Dependencies Plugins
  • 5.
    Installing Maven Download/ extract zip Set M2_HOME env-var Add M2_HOME/bin to path Folders created when maven is used: USER_HOME/.m2/repository/ USER_HOME/.m2/settings.xml
  • 6.
    Simplest pom.xml <project><modelVersion> 4.0.0 </modelVersion> <groupId> gr.jhug </groupId> <artifactId> javabb </artifactId> <version> 1.0-SNAPSHOT </version> <packaging> jar </packaging> <name> PHPBB-NUKE-killer </name> </project> src/main/ src/main/java/ src/main/resources/ src/test/ src/test/java src/test/resources
  • 7.
    Maven Lifecycle validategenerate-sources process-resources compile test-compile test package install verify deploy Maven execution needs phase and runs all previous: mvn compile … or standalone plugin goal: mvn jetty:run mvn scm:update
  • 8.
    Some more pluginsmaven-clean-plugin maven-compiler-plugin maven-jar-plugin maven-war-plugin maven-dependency-plugin maven-release-plugin maven-source-plugin maven-surefire-plugin maven-ant-plugin maven-archetype-plugin maven-checkstyle-plugin maven-pmd-plugin
  • 9.
    Dependencies Uses groupId,artifactId, version Supports transitive dependencies Needs correct usage of ‘scope’ compile test provided runtime system Retrieved from public locations (ibiblio, e.t.c.) Stored on local repo (~/.m2/repository/)
  • 10.
    Versions in Dependencies<major>.<minor>.<revision> ([ -<qualifier> ] | [ -<build> ]) 4.1.6 4.1.6-SNAPSHOT [4.1.6,5) If same dependency included more than once (how???), biggest wins
  • 11.
    Maven & IDEsSupported in all major IDEs From pom.xml generate IDE specific files mvn eclipse:eclipse mvn idea:idea Directly read pom.xml and setup project 2 plugins for eclipse: m2eclipse, q4e Bundled plugin in IDEA Plugin from update center for Netbeans … but maven is (still) more powerful!
  • 12.
    Repository Manager Proxiesbetween your organization and the public Maven repositories Deployment destination for your own generated artifacts Sonatype Nexus Maven Archiva Artifactory
  • 13.
    Links http://ant.apache.org/faq.html http://maven.apache.org/background/history-of-maven.htmlhttp://jakarta.apache.org/alexandria/legacy/ http://gump.apache.org/why.html http://www.sonatype.com/books/maven-book/index.html http://maven.apache.org/repository-management.html http://delicious.com/andyhot/maven
  • 14.
  • 15.
    Companies sonatype.com Jasonvan Zyl, Mark de Visser, Brian Fox, John Casey Nexus, m2eclipse Exist <- DevZuz <- Mergere Brett Porter, Carlos Sanchez q4e

Editor's Notes

  • #2 http://www.apache.org/dev/pmc.html – Project Management Committee