1 / 10

Maven

Maven . Next generation build and project setup tool. Why another build tool?. Every Ant script is different. Why? Maven uses convention over configuration Maven conventions make it easier to learn a new project Ant can be flexible

hua
Download Presentation

Maven

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Maven Next generation build and project setup tool

  2. Why another build tool? • Every Ant script is different. Why? • Maven uses convention over configuration • Maven conventions make it easier to learn a new project • Ant can be flexible • Maven and Ant are not incompatible - you can use the strengths of both

  3. Build lifecycle • With Ant, you have to define your own build lifecycle. • Maven defines a standard build lifecycle for each type of project - jar, war, ear, etc. • The actual work is performed by Maven ‘plugins’, which are wired to different phases of the build lifecycle. The default wiring is sufficient for most projects. • The default lifecycles allow most projects to be built automatically, with minimum configuration

  4. Configuring Maven • Every module in your project has a maven xml configuration file called a POM (project object model). • Each module has a ‘packaging’ type. When you build that module this determines the type of ‘artifact’ which results, and the build lifecycle eg .jar, .war or .ear • Each built artifact has a group and name to identify it, plus a version - defined in the .pom ath the point the build took place. • Over time, the version number will be incremented.

  5. Dependency management in Maven • Nothing in Ant helps you manage dependencies between modules. • Maven can manage your dependencies for you - using the concept of an ‘Artifact Repository’ • Set up your module’s dependencies by listing them in the .pom • When the Maven build runs, Maven will look for the dependencies in your local artifact repository

  6. Maven Repositories - local and remote • Maven repositories are nothing more than a set of folders containing versioned artifacts (.jars, .wars etc) and their matching .poms • They conform to a well know directory structure, based on module group, name and version • A Maven repository can be set up under a web server, so the contents can be served • Maven build will look for a dependency in your local repository first, then try your team’s repository, and finally the maven central repository – it is a bit like DNS

  7. Transitive dependencies in maven • Why include the .poms in the artifact repository? • Maven can automatically go and find your dependencies for you, including all the indirect ‘transitive’ dependencies. • From version 7, Intellij can read your .poms and autoconfigure your Intellij project, downloading any required libraries and.

  8. Enough talking - show me the code

  9. Other Maven features Plugins

  10. Common problems Missing artifacts. Not every project is a Maven project (yet!)- use maven install:install-file Maven central repository can be slow (set up your maven configuration to use the mirrors) Finding the documentation. Each plugin has its own documentation. Use the links on our wiki.

More Related