Your SlideShare is downloading. ×
Maven2 101
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Maven2 101

2,230
views

Published on

A small presentation I made at Vivansa to introduce Maven 2 to my colleagues

A small presentation I made at Vivansa to introduce Maven 2 to my colleagues

Published in: Technology

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,230
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
103
Comments
0
Likes
2
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

















































































  • Transcript

    • 1. Maven2 101 Sébastien Arbogast http://sebastien-arbogast.com March 2nd, 2010
    • 2. Agenda
    • 3. Agenda Generic concepts
    • 4. Agenda Generic concepts Features
    • 5. Agenda Generic concepts Features Best practices
    • 6. Agenda Generic concepts Features Best practices Integration
    • 7. Agenda Generic concepts Features Best practices Integration Demo
    • 8. Agenda Generic concepts Features Best practices Integration Demo
    • 9. Software Project Lifecycle
    • 10. Build Software Project Lifecycle
    • 11. Quality Build Software Project Lifecycle
    • 12. Quality Build Software Project Lifecycle Documentation
    • 13. Quality Build Software Project Lifecycle Deployment Documentation
    • 14. Quality Build Software Project Lifecycle Deployment Documentation Reporting
    • 15. Quality Build Website Software Project Lifecycle Deployment Documentation Reporting
    • 16. Dependency Quality Management Build Website Software Project Lifecycle Deployment Documentation Reporting
    • 17. Don’t tell me what to do Just tell me where things are (pom.xml)
    • 18. Don’t tell me what to do Just tell me where things are (pom.xml) <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/ POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.epseelon</groupId> <artifactId>todolist</artifactId> <packaging>pom</packaging> <version>1.2.2-SNAPSHOT</version> <name>Epseelon TodoList</name> </project>
    • 19. Convention over Configuration
    • 20. project structure Convention over Configuration
    • 21. naming project structure Convention over Configuration
    • 22. naming project structure Convention versioning over Configuration
    • 23. naming project structure Convention versioning over build phases Configuration
    • 24. naming project structure Convention versioning over build phases Configuration repository layout
    • 25. Modular Platform
    • 26. Modular Platform Kernel: plugin management
    • 27. Modular Platform Kernel: plugin management Plugins = MOJO’s
    • 28. Modular Platform Kernel: plugin management Plugins = MOJO’s Compilers
    • 29. Modular Platform Kernel: plugin management Plugins = MOJO’s Compilers Server integrations
    • 30. Modular Platform Kernel: plugin management Plugins = MOJO’s Compilers Server integrations Quality tools
    • 31. Modular Platform Kernel: plugin management Plugins = MOJO’s Compilers Server integrations Quality tools Etc.
    • 32. Modular Platform Kernel: plugin management Plugins = MOJO’s Compilers Server integrations Quality tools Etc. Super POM
    • 33. Build Lifecycle (Phases)
    • 34. Build Lifecycle (Phases) Validate Compile Test Package Install Site Deploy
    • 35. Build Lifecycle (Phases) Validate Compile Test Package Install Site Deploy
    • 36. Build Lifecycle (Phases) Plugins+goals Validate Compile Test Package Install Site Deploy
    • 37. Build Lifecycle (Phases) Plugins+goals Validate Compile maven-java-plugin:compile Test Package Install Site Deploy
    • 38. Build Lifecycle (Phases) Plugins+goals Validate Compile maven-java-plugin:compile Test maven-test-plugin:test Package Install Site Deploy
    • 39. Build Lifecycle (Phases) Plugins+goals Validate Compile maven-java-plugin:compile Test maven-test-plugin:test Package maven-jar-plugin:jar Install Site Deploy
    • 40. Build Lifecycle (Phases) Plugins+goals Validate Compile maven-java-plugin:compile Test maven-test-plugin:test Package maven-jar-plugin:jar Install <project> Site ... <packaging>jar</packaging> Deploy ... </project>
    • 41. Agenda Generic concepts Features Best practices Integration Demo
    • 42. Repositories Epseelon
    • 43. Repositories ibiblio codehaus java.net Internet creuset Epseelon Vivansa Sébastien Eric David
    • 44. Repositories ibiblio codehaus java.net No more libs in SVN Internet creuset Epseelon Vivansa Sébastien Eric David
    • 45. Repositories ibiblio codehaus java.net No more libs in SVN Internet Central repositories creuset Epseelon Vivansa Sébastien Eric David
    • 46. Repositories ibiblio codehaus java.net No more libs in SVN Internet Central repositories Internal proxy (Nexus) creuset Epseelon Vivansa Sébastien Eric David
    • 47. Repositories ibiblio codehaus java.net No more libs in SVN Internet Central repositories Internal proxy (Nexus) creuset Local repositories Epseelon Vivansa Sébastien Eric David
    • 48. Repositories ibiblio codehaus java.net No more libs in SVN Internet Central repositories Internal proxy (Nexus) creuset Local repositories Epseelon Vivansa <project> Sébastien David Eric ... <repositories> <repository> <id>nexus_epseelon</id> <url>${epseelon.repo.public}</url> </repository> </repositories> ... </project>
    • 49. Dependency Management
    • 50. Dependency Management <project> ... <dependencies> <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0</version> </dependency> </dependencies> ... </project>
    • 51. Dependency Management <project> ... <dependencies> <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0</version> </dependency> </dependencies> ... </project> http://mirrors.ibiblio.org/pub/mirrors/maven2/javax/ persistence/persistence-api/1.0/persistence-api-1.0.jar
    • 52. Project Structure
    • 53. Project Structure src main java resources test java target generated-sources pom.xml
    • 54. POM inheritance
    • 55. POM inheritance <project> ... <parent> <groupId>org.eepseelon</groupId> <artifactId>todolist</artifactId> <version>1.0.0-SNAPSHOT</version> </parent> ... </project>
    • 56. POM inheritance <project> ... <parent> <groupId>org.eepseelon</groupId> <artifactId>todolist</artifactId> <version>1.0.0-SNAPSHOT</version> </parent> ... </project> If no parent is specified, parent is the Super-POM!
    • 57. Multi-Module
    • 58. Multi-Module <project> ... <modules> <module>common</module> <module>core</module> <module>app</module> </modules> ... </project>
    • 59. Multi-Module <project> ... <modules> <module>common</module> <module>core</module> <module>app</module> </modules> ... </project> Must map directory structure!
    • 60. Resource filtering
    • 61. <project> Resource filtering ... <build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </build> <properties> <datasource>todolistDS</datasource> </properties> ... </project>
    • 62. <project> Resource filtering ... <build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </build> <properties> <datasource>todolistDS</datasource> </properties> ... </project> => src/main/resources/META-INF/persistence.xml
    • 63. <project> Resource filtering ... <build> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </build> <properties> <datasource>todolistDS</datasource> </properties> ... </project> => src/main/resources/META-INF/persistence.xml <non-jta-data-source> ${datasource} </non-jta-data-source>
    • 64. Profiles
    • 65. Profiles <project> ... <profiles> <profile> <id>dev</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <datasource>todolistDS</datasource> </properties> </profile> </profiles> ... </project>
    • 66. Profiles <project> ... <profiles> <profile> <id>dev</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <datasource>todolistDS</datasource> </properties> </profile> </profiles> ... </project> => mvn -Denv=prod install
    • 67. Plugins
    • 68. <project> ... Plugins <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-ejb-plugin</artifactId> <configuration> <ejbVersion>3.0</ejbVersion> <archive> <manifestEntries> <Todolist-Version> ${project.version} </Todolist-Version> </manifestEntries> </archive> </configuration> </plugin> </plugins> </build> ... </project>
    • 69. Documentation
    • 70. Documentation +- src/ +- site/ +- apt/ | +- index.apt | +- xdoc/ | +- other.xml | +- fml/ | +- general.fml | +- faq.fml | +- site.xml
    • 71. Documentation +- src/ +- site/ +- apt/ | +- index.apt Wiki-like | +- xdoc/ | +- other.xml | +- fml/ | +- general.fml | +- faq.fml | +- site.xml
    • 72. Documentation +- src/ +- site/ +- apt/ | +- index.apt Wiki-like | +- xdoc/ | +- other.xml Docbook-like | +- fml/ | +- general.fml | +- faq.fml | +- site.xml
    • 73. Documentation +- src/ +- site/ +- apt/ | +- index.apt Wiki-like | +- xdoc/ | +- other.xml Docbook-like | +- fml/ | +- general.fml | +- faq.fml | => mvn site +- site.xml
    • 74. Other features Testing integration (JUnit, TestNG, Fitnesse, ...) Reporting (Clover, PMD, ...) Packaging (IzPack, JNLP, ...) Continuous integration (Continuum, Hudson, ...) SCM (Subversion, Mercurial, ...) Release management (Maven Release Plugin) Compiler integration (Groovy, Flex, ...)
    • 75. Best Practices
    • 76. Best Practices One module, one package!
    • 77. Best Practices One module, one package! There’s a standard place for (almost) everything => no side structure
    • 78. Best Practices One module, one package! There’s a standard place for (almost) everything => no side structure generated => target
    • 79. Best Practices One module, one package! There’s a standard place for (almost) everything => no side structure generated => target Factor up dependency versions
    • 80. Best Practices One module, one package! There’s a standard place for (almost) everything => no side structure generated => target Factor up dependency versions Specify plugin versions!
    • 81. Best Practices One module, one package! There’s a standard place for (almost) everything => no side structure generated => target Factor up dependency versions Specify plugin versions! RTF(S)M!
    • 82. Integration
    • 83. Integration Sonatype m2eclipse: http://www.sonatype.com/books/m2eclipse- book/reference/
    • 84. Integration Sonatype m2eclipse: http://www.sonatype.com/books/m2eclipse- book/reference/ IntelliJ Idea: native!
    • 85. Integration Sonatype m2eclipse: http://www.sonatype.com/books/m2eclipse- book/reference/ IntelliJ Idea: native! Hudson, JIRA, Subversion: native
    • 86. Resources
    • 87. Resources Official site: http://maven.apache.org
    • 88. Resources Official site: http://maven.apache.org Maven, the Definitive Guide: http://www.sonatype.com/products/maven/ documentation/book-defguide
    • 89. Resources Official site: http://maven.apache.org Maven, the Definitive Guide: http://www.sonatype.com/products/maven/ documentation/book-defguide Maven repository browser: http://mvnrepository.com
    • 90. Resources Official site: http://maven.apache.org Maven, the Definitive Guide: http://www.sonatype.com/products/maven/ documentation/book-defguide Maven repository browser: http://mvnrepository.com Miscellaneous: http://delicious.com/daneel_r_olivaw/maven