Introduction in Apache Maven2

1,469 views

Published on

A brief overview on Apache Maven2. About the lifecycle, core concepts and how to setup a project. Presented with demos about Eclipse integration and reporting customization.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,469
On SlideShare
0
From Embeds
0
Number of Embeds
31
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Introduction in Apache Maven2

  1. 1. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer
  2. 2. What is Maven? • A build tool like Apache Ant but: ● Configure your build, dont script it ● Define what you build, not how! • A dependency management tool ● Coherent organization of dependencies • A project management tool Take back control!Heiko Scherrer
  3. 3. What is Maven? • Currently using Maven2. Maven3 is almost backward compatible • Benefit of a wide range of plugins to setup your build and reporting • Maven repository server, e.g. Sonatypes NexusHeiko Scherrer
  4. 4. Maven vs. Ant – Why not Ant? • “Convention over Configuration” • Appreciate for building complex modularized applications • Based on a repository to store and resolve artifacts • Maven doesnt have to know about directory structures (use defaults)Heiko Scherrer
  5. 5. Downside of Maven • “Convention over Configuration” • Exceptions are less meaningful and configuration errors hard to find • Plugins are less documentedHeiko Scherrer
  6. 6. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer
  7. 7. What represents a project ? • Each project has a project descriptor (pom.xml) • A project is determined using Maven coordinates groupId:artifactId:version:classifier:type • Project Object Model (POM) files support inheritanceHeiko Scherrer
  8. 8. Standard directory layout • Take advantage of Mavens default configuration - setup a standard directory layout • Maven Archtype plugin creates project structure • The target directory is generated after the first build runHeiko Scherrer
  9. 9. POM – Project Object Model (I) • Define your project <project ...> coordinates <modelVersion>4.0.0</modelVersion> <groupId>org.openwms</groupId> • Set a packaging type <artifactId>org.openwms.core</artifactId> <version>1.0.1-SNAPSHOT</version> -> what to build <packaging>jar</packaging> List dependencies, <dependencies> • <dependency> you need for your <groupId>junit</groupId> <artifactId>junit</artifactId> project in different <version>${junit.version}</version> <scope>test</scope> scopes </dependency> </dependencies> • Use custom </project> propertiesHeiko Scherrer
  10. 10. POM - Scopes • COMPILE Included in compilation, packaged and delivered • PROVIDED Included in compilation, but not packaged. Expected to be provided at runtime • RUNTIME Not included in compilation classpath, but expected at runtime (Class.forName...) • TEST Only included in test classpath and test phase; not delivered • SYSTEM Like provided, but must be referenced directly. Used for non Maven artifactsHeiko Scherrer
  11. 11. POM Inheritance • A super POM comes with your local Maven installation (maven2.jar#pom-4.0.0.xml) • POM files inherit configuration from a parent project • Common used dependencies or configuration snippets shall be moved to a parent project • That way it is possible to build complex inheritance strategies • Find the effective POM: mvn help:effective-pomHeiko Scherrer
  12. 12. Grouping & Inheritance • Building modules to group projects • Use the packaging type pom and define submodules • Group modules and configure build with Profiles • Use inheritance to follow DRY principleHeiko Scherrer
  13. 13. POM – Project Object Model (II) <project ...> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.openwms</groupId> <artifactId>org.openwms</artifactId> • Define a parent <version>1.0.1-SNAPSHOT</version> </parent> project <artifactId>org.openwms.core</artifactId> <packaging>pom</packaging> • Project coordinates <name>OpenWMS CORE module</name> <modules> <module>org.openwms.core.domain</module> Project name and a </modules> • <build> list of submodules <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler- • Override plugin <configuration> plugin</artifactId> <source>1.6</source> configuration <target>1.6</target> </configuration> </plugin> </plugins> </build> </project>Heiko Scherrer
  14. 14. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer
  15. 15. Lifecycle, Phases, Plugins and Goals • Maven uses plugins to accomplish its work • Each plugin offers one or more goals • A goal is specific to a plugin - comparable to an Ant target • Most plugins are developed and driven by the community • Plugin goals are documented on the generated Maven site Plugin Goal • Calling a single plugin goal: mvn compiler:compileHeiko Scherrer
  16. 16. Lifecycles, Phases, Plugins and Goals • The Lifecycle is a pre-defined procedural process for building and distributing a particular artifact • A Phase is one step in Mavens Build Lifecycle ● Plugin goals are attached to an execution Phase ● Each Phase can perform one or more plugin goals • Kick a Lifecycle Phase execution: mvn clean or mvn site • 3 standard Lifecycles : clean, default, site • Plugins can define own Lifecycles (see Flex plugin)Heiko Scherrer
  17. 17. Standard Lifecycle - Clean • Provided by the clean plugin • Pre-configured in the pre-clean Super POM • Run mvn clean to execute all three clean phases within the Lifecycle • Deletes build post-clean directory ${basedir}/targetHeiko Scherrer
  18. 18. Standard Lifecycle - Default validate • 21 phases • Validate project compile completeness for build run • Compile source code test • Run unit tests • Package in distributable format package • Install to local repository install • Deploy; copies the artifacts to a remote repository deployHeiko Scherrer
  19. 19. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer
  20. 20. Local Maven Repository • When executing the Lifecycle phase install, Maven populates a local repository with artifacts • Local repository: ~/.m2/repository • Dependencies and custom deliverables are stored hierarchically • The groupId is interpreted as directory path • The artifactId and version define the name of the artifactHeiko Scherrer
  21. 21. Remote Maven Repository • A Remote repository is a central, company- wide storage for build artifacts • Serves as ● a Proxy (to minimize bandwidth) ● a storage for own project artifacts (accessible by Maven or web UI) • Sonatype Nexus Repository Manager is OpenSource (comm. version available) • Copy to central repo: mvn deployHeiko Scherrer
  22. 22. Remote Maven Repository IIHeiko Scherrer
  23. 23. Remote Maven Repository III Deploy remote <distributionManagement> • In your top-level pom <repository> <id>org_openwms_rudi_releases</id> <name>OpenWMS Internal Releases</name> <url>http://rudi:8081/nexus/content/rel</url> </repository> • Define repository <snapshotRepository> server for snapshots <id>org_openwms_rudi_snapshots</id> <name>OpenWMS Internal Snapshots</name> <url>http://rudi:8081/nexus/content/snap</url> and releases </snapshotRepository> <site> <id>org_openwms_sf</id> <name>OpenWMS Website</name> Server definition for <url>scp://${distribution.web.server}</url> • </site> website deployment </distributionManagement> • Use placeholders!Heiko Scherrer
  24. 24. Remote Maven Repository IV <settings>~/.m2/settings.xml: <servers> <server> <id>org_openwms_rudi_releases</id> • Server credentials <username>USERNAME</username> <password>PASSWORD</password> used to deploy </server> </servers> <mirrors> Route all requests to a <mirror> • <id>all</id> <mirrorOf>*</mirrorOf> proxy <url>http://rudi:8081/nexus/content/all</url> </mirror> </mirrors> • Manage exception <repositories> <repository> routes <id>org_openwms_sf_snap</id> <url>http://rudi:8081/nexus/content/snap</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>true</enabled></snapshots> → Demo </repository> </repositories> </settings>Heiko Scherrer
  25. 25. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer
  26. 26. Dependency Management • Manage common dependency declarations in parent pom: <dependencyManagement> • Manage common plugin configuration in parent pom: <pluginManagement> • Define repository locations for artifact & plugin repositories in parent pom • Use variables for substitute versionsHeiko Scherrer
  27. 27. Dependency Management - Example <dependencies> <dependency> • Add dependencies <groupId>javaee</groupId> <artifactId>javaee-api</artifactId> <scope>provided</scope> provided by the EJB </dependency> container <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.12</version> <exclusions> • Exclude <exclusion> <groupId>com.sun.jmx</groupId> <artifactId>jmxri</artifactId> dependencies when </exclusion> </exclusions> </dependency> necessary <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> • Set the proper <scope>test</scope> </dependency> scope to avoid <dependency> <groupId>commons-lang</groupId> packaging of <artifactId>commons-lang</artifactId> <version>2.4</version> <scope>compile</scope> dependencies </dependency> </dependencies>Heiko Scherrer
  28. 28. Worth to mention • Resource filtering • Profiles • ClassifiersHeiko Scherrer
  29. 29. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer
  30. 30. Reporting & Site Generation ASDoc Cobertura Website Javadoc JXR PMD Checkstyle Taglist JDepend CPDHeiko Scherrer
  31. 31. Reporting & Site Generation • Run site generation: mvn site • Maven-site-plugin • Site content: ${basedir}/src/site • Accepted formats: apt, fml, xdoc, DocBook, …Heiko Scherrer
  32. 32. Reporting & Site Generation • Report generation is part of site • Site customization is done within <reporting> section • Useful plugins: maven-project-info-reports-plugin, dashboard-maven-plugin, cobertura-maven-plugin, maven-surefire-report-plugin, maven-javadoc-plugin • → DemoHeiko Scherrer
  33. 33. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer
  34. 34. IDE Integration (Eclipse) • Usually each IDE has its own project setting files • Avoid sharing platform specific files within your VCS • Import pom.xml as Maven project → Eclipse demo • Use maven-eclipse-plugin to add particular project facets: mvn eclipse:eclipse • Use the IDE to develop – not to build. → Keep Maven out of development processHeiko Scherrer
  35. 35. IDE Integration II (Eclipse) • Install m2eclipse: http://m2eclipse.sonatype.org/sites/m2e • m2eclipse comes with Maven3 beta, change manually to local Maven2 installation • In addition to the local and remote repository, m2eclipse uses the workspace as 1st. Repository • Use favorite Run Configurations to run MavenHeiko Scherrer
  36. 36. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer
  37. 37. Tips & Tricks • Download sources mvn dependency:sources • Define <server> in your settings.xml to store your credentials • Add -DskipTests to bypass test phase • Add -U to update snapshot dependencies manually • m2e: Nested projects lead to artifact resolving errorsHeiko Scherrer
  38. 38. Tips & Tricks • Download sources mvn dependency:sources • Define <server> in your settings.xml to store your credentials • Add -DskipTests to bypass test phase • Add -U to update snapshot dependencies manually • m2e: Nested projects lead to artifact resolving errorsHeiko Scherrer
  39. 39. Tips & Tricks II • Aggregate common config in top-level pom • SVN ignore IDE specific files and use pom as project descriptor at all • Dont commit binaries or generated files to VCSHeiko Scherrer
  40. 40. Q&AHeiko Scherrer
  41. 41. Document History • Initial svn rev. [1472]; • Updated svn rev. [1475];2011-01-16Heiko Scherrer
  42. 42. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer 1
  43. 43. What is Maven? • A build tool like Apache Ant but: ● Configure your build, dont script it ● Define what you build, not how! • A dependency management tool ● Coherent organization of dependencies • A project management tool Take back control! Heiko Scherrer 2Apache Ivy is another tool to manage dependencies that can be used together with Ant.
  44. 44. What is Maven? • Currently using Maven2. Maven3 is almost backward compatible • Benefit of a wide range of plugins to setup your build and reporting • Maven repository server, e.g. Sonatypes NexusHeiko Scherrer 3
  45. 45. Maven vs. Ant – Why not Ant? • “Convention over Configuration” • Appreciate for building complex modularized applications • Based on a repository to store and resolve artifacts • Maven doesnt have to know about directory structures (use defaults)Heiko Scherrer 4
  46. 46. Downside of Maven • “Convention over Configuration” • Exceptions are less meaningful and configuration errors hard to find • Plugins are less documentedHeiko Scherrer 5
  47. 47. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer 6
  48. 48. What represents a project ? • Each project has a project descriptor (pom.xml) • A project is determined using Maven coordinates groupId:artifactId:version:classifier:type • Project Object Model (POM) files support inheritanceHeiko Scherrer 7
  49. 49. Standard directory layout • Take advantage of Mavens default configuration - setup a standard directory layout • Maven Archtype plugin creates project structure • The target directory is generated after the first build runHeiko Scherrer 8
  50. 50. POM – Project Object Model (I) • Define your project <project ...> coordinates <modelVersion>4.0.0</modelVersion> <groupId>org.openwms</groupId> • Set a packaging type <artifactId>org.openwms.core</artifactId> <version>1.0.1-SNAPSHOT</version> -> what to build <packaging>jar</packaging> List dependencies, <dependencies> • <dependency> you need for your <groupId>junit</groupId> <artifactId>junit</artifactId> project in different <version>${junit.version}</version> <scope>test</scope> scopes </dependency> </dependencies> • Use custom </project> properties Heiko Scherrer 9●Jar is the default packaging type and can be omitted●Define custom properties within the properties element.●Standard properties: project, env, settings●Version ranges can be used as well: (1.0,2.0]
  51. 51. POM - Scopes • COMPILE Included in compilation, packaged and delivered • PROVIDED Included in compilation, but not packaged. Expected to be provided at runtime • RUNTIME Not included in compilation classpath, but expected at runtime (Class.forName...) • TEST Only included in test classpath and test phase; not delivered • SYSTEM Like provided, but must be referenced directly. Used for non Maven artifacts Heiko Scherrer 10●Optional dependencies are included in the compile classpath but not packaged. It is up to the assembler to provide them at runtime.●Transitive dependencies can be excluded and replaced.
  52. 52. POM Inheritance • A super POM comes with your local Maven installation (maven2.jar#pom-4.0.0.xml) • POM files inherit configuration from a parent project • Common used dependencies or configuration snippets shall be moved to a parent project • That way it is possible to build complex inheritance strategies • Find the effective POM: mvn help:effective-pom Heiko Scherrer 11● All custom POMs inherit the super pom configuration
  53. 53. Grouping & Inheritance • Building modules to group projects • Use the packaging type pom and define submodules • Group modules and configure build with Profiles • Use inheritance to follow DRY principleHeiko Scherrer 12
  54. 54. POM – Project Object Model (II) <project ...> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.openwms</groupId> <artifactId>org.openwms</artifactId> • Define a parent <version>1.0.1-SNAPSHOT</version> </parent> project <artifactId>org.openwms.core</artifactId> <packaging>pom</packaging> • Project coordinates <name>OpenWMS CORE module</name> <modules> <module>org.openwms.core.domain</module> Project name and a </modules> • <build> list of submodules <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler- • Override plugin <configuration> plugin</artifactId> <source>1.6</source> configuration <target>1.6</target> </configuration> </plugin> </plugins> </build> </project> Heiko Scherrer 13● Module definitions expect relative path
  55. 55. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer 14
  56. 56. Lifecycle, Phases, Plugins and Goals • Maven uses plugins to accomplish its work • Each plugin offers one or more goals • A goal is specific to a plugin - comparable to an Ant target • Most plugins are developed and driven by the community • Plugin goals are documented on the generated Maven site Plugin Goal • Calling a single plugin goal: mvn compiler:compileHeiko Scherrer 15
  57. 57. Lifecycles, Phases, Plugins and Goals • The Lifecycle is a pre-defined procedural process for building and distributing a particular artifact • A Phase is one step in Mavens Build Lifecycle ● Plugin goals are attached to an execution Phase ● Each Phase can perform one or more plugin goals • Kick a Lifecycle Phase execution: mvn clean or mvn site • 3 standard Lifecycles : clean, default, site • Plugins can define own Lifecycles (see Flex plugin) Heiko Scherrer 16A goal of a plugin is per default attached to a particular phase. This can be customized with the plugin configuration. See <phase> element.
  58. 58. Standard Lifecycle - Clean • Provided by the clean plugin • Pre-configured in the pre-clean Super POM • Run mvn clean to execute all three clean phases within the Lifecycle • Deletes build post-clean directory ${basedir}/targetHeiko Scherrer 17
  59. 59. Standard Lifecycle - Default validate • 21 phases • Validate project compile completeness for build run • Compile source code test • Run unit tests • Package in distributable format package • Install to local repository install • Deploy; copies the artifacts to a remote repository deployHeiko Scherrer 18
  60. 60. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer 19
  61. 61. Local Maven Repository • When executing the Lifecycle phase install, Maven populates a local repository with artifacts • Local repository: ~/.m2/repository • Dependencies and custom deliverables are stored hierarchically • The groupId is interpreted as directory path • The artifactId and version define the name of the artifactHeiko Scherrer 20
  62. 62. Remote Maven Repository • A Remote repository is a central, company- wide storage for build artifacts • Serves as ● a Proxy (to minimize bandwidth) ● a storage for own project artifacts (accessible by Maven or web UI) • Sonatype Nexus Repository Manager is OpenSource (comm. version available) • Copy to central repo: mvn deploy Heiko Scherrer 21● Use maven-deploy-plugin (deploy-file) to upload non “mavenized” artifacts.
  63. 63. Remote Maven Repository IIHeiko Scherrer 22
  64. 64. Remote Maven Repository III Deploy remote <distributionManagement> • In your top-level pom <repository> <id>org_openwms_rudi_releases</id> <name>OpenWMS Internal Releases</name> <url>http://rudi:8081/nexus/content/rel</url> </repository> • Define repository <snapshotRepository> server for snapshots <id>org_openwms_rudi_snapshots</id> <name>OpenWMS Internal Snapshots</name> <url>http://rudi:8081/nexus/content/snap</url> and releases </snapshotRepository> <site> <id>org_openwms_sf</id> <name>OpenWMS Website</name> Server definition for <url>scp://${distribution.web.server}</url> • </site> website deployment </distributionManagement> • Use placeholders!Heiko Scherrer 23
  65. 65. Remote Maven Repository IV <settings> ~/.m2/settings.xml: <servers> <server> <id>org_openwms_rudi_releases</id> • Server credentials <username>USERNAME</username> <password>PASSWORD</password> used to deploy </server> </servers> <mirrors> Route all requests to a <mirror> • <id>all</id> <mirrorOf>*</mirrorOf> proxy <url>http://rudi:8081/nexus/content/all</url> </mirror> </mirrors> • Manage exception <repositories> <repository> routes <id>org_openwms_sf_snap</id> <url>http://rudi:8081/nexus/content/snap</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>true</enabled></snapshots> → Demo </repository> </repositories> </settings> Heiko Scherrer 24In addition to the repository tag use <pluginRepository>.
  66. 66. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer 25
  67. 67. Dependency Management • Manage common dependency declarations in parent pom: <dependencyManagement> • Manage common plugin configuration in parent pom: <pluginManagement> • Define repository locations for artifact & plugin repositories in parent pom • Use variables for substitute versionsHeiko Scherrer 26
  68. 68. Dependency Management - Example <dependencies> <dependency> • Add dependencies <groupId>javaee</groupId> <artifactId>javaee-api</artifactId> <scope>provided</scope> provided by the EJB </dependency> container <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.12</version> <exclusions> • Exclude <exclusion> <groupId>com.sun.jmx</groupId> <artifactId>jmxri</artifactId> dependencies when </exclusion> </exclusions> </dependency> necessary <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> • Set the proper <scope>test</scope> </dependency> scope to avoid <dependency> <groupId>commons-lang</groupId> packaging of <artifactId>commons-lang</artifactId> <version>2.4</version> <scope>compile</scope> dependencies </dependency> </dependencies> Heiko Scherrer 27●An artifact defined in <dependencies> is inherited to sub projects as dependency.●An artifact within <dependencyManagement> is a declaration only.●Exclusions and scopes are inherited as well.
  69. 69. Worth to mention • Resource filtering • Profiles • Classifiers Heiko Scherrer 28●Use resource filtering option to replace variables within resource files, like Spring configs or web.xml●Profiles can be used to distinguish build and runtime environments.●A classifier is used as an extension to the standard coordinates to distinguish the built artifact for arbitrary runtime environments
  70. 70. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer 29
  71. 71. Reporting & Site Generation ASDoc Cobertura • Click to add an outline Website Javadoc JXR PMD Checkstyle Taglist JDepend CPDHeiko Scherrer 30
  72. 72. Reporting & Site Generation • Run site generation: mvn site • Maven-site-plugin • Site content: ${basedir}/src/site • Accepted formats: apt, fml, xdoc, DocBook, …Heiko Scherrer 31
  73. 73. Reporting & Site Generation • Report generation is part of site • Site customization is done within <reporting> section • Useful plugins: maven-project-info-reports-plugin, dashboard-maven-plugin, cobertura-maven-plugin, maven-surefire-report-plugin, maven-javadoc-plugin • → DemoHeiko Scherrer 32
  74. 74. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer 33
  75. 75. IDE Integration (Eclipse) • Usually each IDE has its own project setting files • Avoid sharing platform specific files within your VCS • Import pom.xml as Maven project → Eclipse demo • Use maven-eclipse-plugin to add particular project facets: mvn eclipse:eclipse • Use the IDE to develop – not to build. → Keep Maven out of development process Heiko Scherrer 34●Eclipse uses .project/.classpath/.settings●NetBeans uses nbproject, nb-build.xml●IntelliJ uses .iml, .ipr, .iws, .idea●In many cases these files include settings specific to the developers local environment (like the JAVA_HOME path or other absolute path...)●Most of the project facets are setup by the IDE plugin (like m2eclipse)
  76. 76. IDE Integration II (Eclipse) • Install m2eclipse: http://m2eclipse.sonatype.org/sites/m2e • m2eclipse comes with Maven3 beta, change manually to local Maven2 installation • In addition to the local and remote repository, m2eclipse uses the workspace as 1st. Repository • Use favorite Run Configurations to run MavenHeiko Scherrer 35
  77. 77. Basic introduction in Maven • Introduction • POM (Project Object Model) • Lifecycle • Repository • Dependency Management • Reporting • IDE Integration • Tips & TricksHeiko Scherrer 36
  78. 78. Tips & Tricks • Download sources mvn dependency:sources • Define <server> in your settings.xml to store your credentials • Add -DskipTests to bypass test phase • Add -U to update snapshot dependencies manually • m2e: Nested projects lead to artifact resolving errors Heiko Scherrer 37M2eclipse is able to download sources and Javadoc automatically
  79. 79. Tips & Tricks • Download sources mvn dependency:sources • Define <server> in your settings.xml to store your credentials • Add -DskipTests to bypass test phase • Add -U to update snapshot dependencies manually • m2e: Nested projects lead to artifact resolving errors Heiko Scherrer 38M2eclipse is able to download sources and Javadoc automatically
  80. 80. Tips & Tricks II • Aggregate common config in top-level pom • SVN ignore IDE specific files and use pom as project descriptor at all • Dont commit binaries or generated files to VCSHeiko Scherrer 39
  81. 81. Q&AHeiko Scherrer 40
  82. 82. Document History • Initial svn rev. [1472]; • Updated svn rev. [1475];2011-01-16Heiko Scherrer 41

×