0
Maven2 101
     Sébastien Arbogast
http://sebastien-arbogast.com




                       March 2nd, 2010
Agenda
Agenda

Generic concepts
Agenda

Generic concepts

Features
Agenda

Generic concepts

Features

Best practices
Agenda

Generic concepts

Features

Best practices

Integration
Agenda

Generic concepts

Features

Best practices

Integration

Demo
Agenda

Generic concepts

Features

Best practices

Integration

Demo
Software Project
    Lifecycle
Build

        Software Project
            Lifecycle
Quality


Build

        Software Project
            Lifecycle
Quality


Build

        Software Project
            Lifecycle
                        Documentation
Quality


Build

        Software Project
            Lifecycle
Deployment              Documentation
Quality


Build

        Software Project
            Lifecycle
Deployment                Documentation



             Re...
Quality


Build                         Website

        Software Project
            Lifecycle
Deployment                ...
Dependency    Quality
         Management

Build                            Website

        Software Project
            ...
Don’t tell me what to do
  Just tell me where
 things are (pom.xml)
Don’t tell me what to do
      Just tell me where
     things are (pom.xml)
<project xmlns="http://maven.apache.org/POM/4....
Convention
    over
Configuration
project structure


         Convention
            over
        Configuration
naming
project structure


         Convention
            over
        Configuration
naming
      project structure


               Convention
versioning        over
              Configuration
naming
      project structure


               Convention
versioning        over
                              build phas...
naming
      project structure


               Convention
versioning        over
                                      bu...
Modular Platform
Modular Platform
Kernel: plugin management
Modular Platform
Kernel: plugin management

Plugins = MOJO’s
Modular Platform
Kernel: plugin management

Plugins = MOJO’s

  Compilers
Modular Platform
Kernel: plugin management

Plugins = MOJO’s

  Compilers

  Server integrations
Modular Platform
Kernel: plugin management

Plugins = MOJO’s

  Compilers

  Server integrations

  Quality tools
Modular Platform
Kernel: plugin management

Plugins = MOJO’s

  Compilers

  Server integrations

  Quality tools

  Etc.
Modular Platform
Kernel: plugin management

Plugins = MOJO’s

  Compilers

  Server integrations

  Quality tools

  Etc.
...
Build Lifecycle (Phases)
Build Lifecycle (Phases)
 Validate

 Compile

 Test

 Package

 Install

 Site

 Deploy
Build Lifecycle (Phases)
 Validate

 Compile

 Test

 Package

 Install

 Site

 Deploy
Build Lifecycle (Phases)
               Plugins+goals
 Validate

 Compile

 Test

 Package

 Install

 Site

 Deploy
Build Lifecycle (Phases)
                 Plugins+goals
 Validate

 Compile    maven-java-plugin:compile
 Test

 Package

...
Build Lifecycle (Phases)
                 Plugins+goals
 Validate

 Compile    maven-java-plugin:compile
 Test        mave...
Build Lifecycle (Phases)
                 Plugins+goals
 Validate

 Compile    maven-java-plugin:compile
 Test        mave...
Build Lifecycle (Phases)
                       Plugins+goals
 Validate

 Compile        maven-java-plugin:compile
 Test  ...
Agenda

Generic concepts

Features

Best practices

Integration

Demo
Repositories



               Epseelon
Repositories   ibiblio
                                 codehaus

                                             java.net


...
Repositories          ibiblio
                                        codehaus

                                          ...
Repositories           ibiblio
                                         codehaus

                                        ...
Repositories             ibiblio
                                           codehaus

                                    ...
Repositories             ibiblio
                                           codehaus

                                    ...
Repositories                 ibiblio
                                                   codehaus

                        ...
Dependency
Management
Dependency
              Management
<project>
    ...
    <dependencies>
        <dependency>
            <groupId>javax.p...
Dependency
                Management
 <project>
     ...
     <dependencies>
         <dependency>
             <groupId>...
Project Structure
Project Structure
src
   main
      java
      resources
   test
      java
target
   generated-sources
pom.xml
POM inheritance
POM inheritance
<project>
    ...
    <parent>
        <groupId>org.eepseelon</groupId>
        <artifactId>todolist</arti...
POM inheritance
<project>
    ...
    <parent>
        <groupId>org.eepseelon</groupId>
        <artifactId>todolist</arti...
Multi-Module
Multi-Module
<project>
    ...
    <modules>
        <module>common</module>
        <module>core</module>
        <module...
Multi-Module
<project>
    ...
    <modules>
        <module>common</module>
        <module>core</module>
        <module...
Resource filtering
<project>         Resource filtering
    ...
    <build>
      <resources>
        <resource>
          <directory>src/main...
<project>             Resource filtering
    ...
    <build>
      <resources>
        <resource>
          <directory>src/...
<project>             Resource filtering
    ...
    <build>
      <resources>
        <resource>
          <directory>src/...
Profiles
Profiles
<project>
    ...
  <profiles>
    <profile>
      <id>dev</id>
      <activation>
        <activeByDefault>true</...
Profiles
<project>
    ...
  <profiles>
    <profile>
      <id>dev</id>
      <activation>
        <activeByDefault>true</...
Plugins
<project>
    ...
                      Plugins
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.p...
Documentation
Documentation
+- src/
   +- site/
      +- apt/
      | +- index.apt
      |
      +- xdoc/
      | +- other.xml
      |
 ...
Documentation
+- src/
   +- site/
      +- apt/
      | +- index.apt   Wiki-like
      |
      +- xdoc/
      | +- other.x...
Documentation
+- src/
   +- site/
      +- apt/
      | +- index.apt   Wiki-like
      |
      +- xdoc/
      | +- other.x...
Documentation
+- src/
   +- site/
      +- apt/
      | +- index.apt   Wiki-like
      |
      +- xdoc/
      | +- other.x...
Other features
Testing integration (JUnit, TestNG, Fitnesse, ...)

Reporting (Clover, PMD, ...)

Packaging (IzPack, JNLP, ...
Best Practices
Best Practices
One module, one package!
Best Practices
One module, one package!

There’s a standard place for (almost)
everything => no side structure
Best Practices
One module, one package!

There’s a standard place for (almost)
everything => no side structure

generated ...
Best Practices
One module, one package!

There’s a standard place for (almost)
everything => no side structure

generated ...
Best Practices
One module, one package!

There’s a standard place for (almost)
everything => no side structure

generated ...
Best Practices
One module, one package!

There’s a standard place for (almost)
everything => no side structure

generated ...
Integration
Integration

Sonatype m2eclipse:
http://www.sonatype.com/books/m2eclipse-
book/reference/
Integration

Sonatype m2eclipse:
http://www.sonatype.com/books/m2eclipse-
book/reference/

IntelliJ Idea: native!
Integration

Sonatype m2eclipse:
http://www.sonatype.com/books/m2eclipse-
book/reference/

IntelliJ Idea: native!

Hudson,...
Resources
Resources
Official site:
http://maven.apache.org
Resources
Official site:
http://maven.apache.org

Maven, the Definitive Guide:
http://www.sonatype.com/products/maven/
docum...
Resources
Official site:
http://maven.apache.org

Maven, the Definitive Guide:
http://www.sonatype.com/products/maven/
docum...
Resources
Official site:
http://maven.apache.org

Maven, the Definitive Guide:
http://www.sonatype.com/products/maven/
docum...
Maven2 101
Maven2 101
Maven2 101
Maven2 101
Maven2 101
Maven2 101
Maven2 101
Maven2 101
Maven2 101
Upcoming SlideShare
Loading in...5
×

Maven2 101

2,283

Published on

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,283
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
104
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

















































































  • Transcript of "Maven2 101"

    1. 1. Maven2 101 Sébastien Arbogast http://sebastien-arbogast.com March 2nd, 2010
    2. 2. Agenda
    3. 3. Agenda Generic concepts
    4. 4. Agenda Generic concepts Features
    5. 5. Agenda Generic concepts Features Best practices
    6. 6. Agenda Generic concepts Features Best practices Integration
    7. 7. Agenda Generic concepts Features Best practices Integration Demo
    8. 8. Agenda Generic concepts Features Best practices Integration Demo
    9. 9. Software Project Lifecycle
    10. 10. Build Software Project Lifecycle
    11. 11. Quality Build Software Project Lifecycle
    12. 12. Quality Build Software Project Lifecycle Documentation
    13. 13. Quality Build Software Project Lifecycle Deployment Documentation
    14. 14. Quality Build Software Project Lifecycle Deployment Documentation Reporting
    15. 15. Quality Build Website Software Project Lifecycle Deployment Documentation Reporting
    16. 16. Dependency Quality Management Build Website Software Project Lifecycle Deployment Documentation Reporting
    17. 17. Don’t tell me what to do Just tell me where things are (pom.xml)
    18. 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. 19. Convention over Configuration
    20. 20. project structure Convention over Configuration
    21. 21. naming project structure Convention over Configuration
    22. 22. naming project structure Convention versioning over Configuration
    23. 23. naming project structure Convention versioning over build phases Configuration
    24. 24. naming project structure Convention versioning over build phases Configuration repository layout
    25. 25. Modular Platform
    26. 26. Modular Platform Kernel: plugin management
    27. 27. Modular Platform Kernel: plugin management Plugins = MOJO’s
    28. 28. Modular Platform Kernel: plugin management Plugins = MOJO’s Compilers
    29. 29. Modular Platform Kernel: plugin management Plugins = MOJO’s Compilers Server integrations
    30. 30. Modular Platform Kernel: plugin management Plugins = MOJO’s Compilers Server integrations Quality tools
    31. 31. Modular Platform Kernel: plugin management Plugins = MOJO’s Compilers Server integrations Quality tools Etc.
    32. 32. Modular Platform Kernel: plugin management Plugins = MOJO’s Compilers Server integrations Quality tools Etc. Super POM
    33. 33. Build Lifecycle (Phases)
    34. 34. Build Lifecycle (Phases) Validate Compile Test Package Install Site Deploy
    35. 35. Build Lifecycle (Phases) Validate Compile Test Package Install Site Deploy
    36. 36. Build Lifecycle (Phases) Plugins+goals Validate Compile Test Package Install Site Deploy
    37. 37. Build Lifecycle (Phases) Plugins+goals Validate Compile maven-java-plugin:compile Test Package Install Site Deploy
    38. 38. Build Lifecycle (Phases) Plugins+goals Validate Compile maven-java-plugin:compile Test maven-test-plugin:test Package Install Site Deploy
    39. 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. 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. 41. Agenda Generic concepts Features Best practices Integration Demo
    42. 42. Repositories Epseelon
    43. 43. Repositories ibiblio codehaus java.net Internet creuset Epseelon Vivansa Sébastien Eric David
    44. 44. Repositories ibiblio codehaus java.net No more libs in SVN Internet creuset Epseelon Vivansa Sébastien Eric David
    45. 45. Repositories ibiblio codehaus java.net No more libs in SVN Internet Central repositories creuset Epseelon Vivansa Sébastien Eric David
    46. 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. 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. 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. 49. Dependency Management
    50. 50. Dependency Management <project> ... <dependencies> <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> <version>1.0</version> </dependency> </dependencies> ... </project>
    51. 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. 52. Project Structure
    53. 53. Project Structure src main java resources test java target generated-sources pom.xml
    54. 54. POM inheritance
    55. 55. POM inheritance <project> ... <parent> <groupId>org.eepseelon</groupId> <artifactId>todolist</artifactId> <version>1.0.0-SNAPSHOT</version> </parent> ... </project>
    56. 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. 57. Multi-Module
    58. 58. Multi-Module <project> ... <modules> <module>common</module> <module>core</module> <module>app</module> </modules> ... </project>
    59. 59. Multi-Module <project> ... <modules> <module>common</module> <module>core</module> <module>app</module> </modules> ... </project> Must map directory structure!
    60. 60. Resource filtering
    61. 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. 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. 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. 64. Profiles
    65. 65. Profiles <project> ... <profiles> <profile> <id>dev</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <datasource>todolistDS</datasource> </properties> </profile> </profiles> ... </project>
    66. 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. 67. Plugins
    68. 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. 69. Documentation
    70. 70. Documentation +- src/ +- site/ +- apt/ | +- index.apt | +- xdoc/ | +- other.xml | +- fml/ | +- general.fml | +- faq.fml | +- site.xml
    71. 71. Documentation +- src/ +- site/ +- apt/ | +- index.apt Wiki-like | +- xdoc/ | +- other.xml | +- fml/ | +- general.fml | +- faq.fml | +- site.xml
    72. 72. Documentation +- src/ +- site/ +- apt/ | +- index.apt Wiki-like | +- xdoc/ | +- other.xml Docbook-like | +- fml/ | +- general.fml | +- faq.fml | +- site.xml
    73. 73. Documentation +- src/ +- site/ +- apt/ | +- index.apt Wiki-like | +- xdoc/ | +- other.xml Docbook-like | +- fml/ | +- general.fml | +- faq.fml | => mvn site +- site.xml
    74. 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. 75. Best Practices
    76. 76. Best Practices One module, one package!
    77. 77. Best Practices One module, one package! There’s a standard place for (almost) everything => no side structure
    78. 78. Best Practices One module, one package! There’s a standard place for (almost) everything => no side structure generated => target
    79. 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. 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. 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. 82. Integration
    83. 83. Integration Sonatype m2eclipse: http://www.sonatype.com/books/m2eclipse- book/reference/
    84. 84. Integration Sonatype m2eclipse: http://www.sonatype.com/books/m2eclipse- book/reference/ IntelliJ Idea: native!
    85. 85. Integration Sonatype m2eclipse: http://www.sonatype.com/books/m2eclipse- book/reference/ IntelliJ Idea: native! Hudson, JIRA, Subversion: native
    86. 86. Resources
    87. 87. Resources Official site: http://maven.apache.org
    88. 88. Resources Official site: http://maven.apache.org Maven, the Definitive Guide: http://www.sonatype.com/products/maven/ documentation/book-defguide
    89. 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. 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
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×