• Save
An introduction to Maven
Upcoming SlideShare
Loading in...5
×
 

An introduction to Maven

on

  • 3,869 views

This is a introduction to Maven 2. For more information visit http://jpereira.eu/2012/05/03/an-introduction-to-maven-2/ ...

This is a introduction to Maven 2. For more information visit http://jpereira.eu/2012/05/03/an-introduction-to-maven-2/

If you want to download the editable presentation contact me (find my contacts on my blog)

Statistics

Views

Total Views
3,869
Views on SlideShare
2,215
Embed Views
1,654

Actions

Likes
13
Downloads
0
Comments
0

10 Embeds 1,654

http://jpereira.eu 1615
http://investing.jpereira.eu 22
http://www.linkedin.com 6
http://feeds2.feedburner.com 3
http://www.bingsandbox.com 2
https://www.linkedin.com 2
http://cloud.feedly.com 1
http://manageit.jpereira.eu 1
http://translate.googleusercontent.com 1
http://feedly.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike LicenseCC Attribution-NonCommercial-ShareAlike License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    An introduction to Maven An introduction to Maven Presentation Transcript

    • An introduction to João Miguel Pereira http://jpereira.eu May 2012 An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • An introduction to Maven • Introduction • Build Lifecycle • Architecture • Plug-ins and Goals • Default phase bindings • Repositories • Artifacts • Project Object Model • Dependencies • ArchetypesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 2Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • An introduction to Maven • Introduction • Build Lifecycle • Architecture • Plug-ins and Goals • Default phase bindings • Repositories • Artifacts • Project Object Model • Dependencies • ArchetypesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 3Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • The life before Maven • Use javac in the command line to compile your projects • Rely on the IDE (Integrated Development Environment) to have your project compiled (Eclipse, NetBeans, IntelliJ IDEA, JDeveloper,...) • Use ANT (Another Neat Tool) • GNU MakeAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 4Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • What is Maven • Apache Project • Born within Apache community to simplify the Jakarta Turbine project • Can generate deployable artifacts from source code • Compile, pack, test and distribute your source code • But its not just “another build tool” • Its more a Project Management tool than a “build tool” • It also create reports, generate a web site for the project and facilitates communication among team membersAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 5Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Why use Maven • Manage all your project dependencies and life- cycle • Dont need to worry about having the dependencies in your dev machine • Convention over configuration means less configuration • Used in big and complex projects • Let developers focus on what is really important (coding) • Based on XML to configure the projectAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 6Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • An introduction to Maven • Introduction • Build Lifecycle • Architecture • Plug-ins and Goals • Default phase bindings • Repositories • Artifacts • Project Object Model • Dependencies • ArchetypesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 7Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven Build Lifecycle • Maven relies on build lifecycles to define the process of building and distributing artifacts (eg. Jar files, war files) • There are three built-in build lifecycles – Default – handles project building and deployment – Clean – handles project cleaning – Site – handles project’s site generationAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 8Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven Build Lifecycle • Each Build Lifecycle is made up of phases • Example: Validate Compile Test Package Install DeployAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 9Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven Build Lifecycle • You can invoke a specific phase on the lifecyle • Example: $ mvn test • When you invoke a specific phase, every previous phases run, including the one you specified. If you run: $ mvn test Validate Compile TestAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 10Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Default lifecycle phasesPhase Descriptionvalidate Validate the project is correct and all necessary information is available to complete a buildgenerate-sources Generate any source code for inclusion in compilationprocess-sources Process the source code, for example to filter any valuesgenerate-resources Generate resources for inclusion in the packageprocess-resources Copy and process the resources into the destination directory, ready for packagingcompile Compile the source code of the projectprocess-classes Post-process the generated files from compilation, for example to do bytecode enhancement on Java classesgenerate-test- Generate any test source code for inclusion insources compilationAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 11Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Default lifecycle phases (Continued…)Phase Descriptionprocess-test- Process the test source code, for example to filter anysources valuesgenerate-test- Create resources for testingresourcesprocess-test- Copy and process the resources into the test destinationresources directorytest-compile Compile the test source code into the test destination directorytest Run tests using a suitable unit testing framework. These tests should not require the code be packaged or deployedAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 12Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Default lifecycle phases (Continued…)Phase Descriptionprepare-package Perform any operations necessary to prepare a package before the actual packaging. This often results in an unpacked, processed version of the package (coming in Maven 2.1+)package Take the compiled code and package it in its distributable format, such as a JAR, WAR, or EARpre-integration-test Perform actions required before integration tests are executed. This may involve things such as setting up the required environmentintegration-test Process and deploy the package if necessary into an environment where integration tests can be runpost-integration- Perform actions required after integration tests havetest been executed. This may include cleaning up the environmentAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 13Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Default lifecycle phases (Continued…)Phase Descriptionverify Run any checks to verify the package is valid and meets quality criteriainstall Install the package into the local repository, for use as a dependency in other projects locallydeploy Copies the final package to the remote repository for sharing with other developers and projects (usually only relevant during a formal release)An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 14Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Clean lifecycle phasesPhase DescriptionPre-clean Run before the clean goal is performedClean Clean the target folderPost-clean Run after the clean goal is performedAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 15Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Site lifecycle phasesPhase DescriptionPre-site Run any goal that is needed before the site generationSite Generate the sitePost-site Run any goal that should be performed after site generationSite-deploy Deploy the siteAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 16Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • An introduction to Maven • Introduction • Build Lifecycle • Architecture • Plug-ins and Goals • Default phase bindings • Repositories • Artifacts • Project Object Model • Dependencies • ArchetypesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 17Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven architecture Plug-in (1) Plug-in (2) Plug-in (3) Plug-in (n) Core Engine Remote Remote Local Repository Remote Repository Repository RepositoriesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 18Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven architecture • Core Engine provides: – Project processing Read the project configuration file and configure the project accordingly. – Build lifecycle management  Run a series of phases (as seen before). – Framework for plug-ins.An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 19Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven architecture • Plug-ins provides: – The core operations to build your project. For example, to create a jar the maven-jar-plugin will do the job, not maven itself. • Plug-ins provides one or more “Goals” • A Goal perform some operation on the project. Ex: compile, create a Jar, deploy to Jboss, etc. • Goals can be bound to build lifecycle phasesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 20Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • An introduction to Maven • Introduction • Build Lifecycle • Architecture • Plug-ins and Goals • Default phase bindings • Repositories • Artifacts • Project Object Model • Dependencies • ArchetypesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 21Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven Plug-ins and Goals • Goals can be bound to build-lifecycle phases. Example: Plug-in’s goals Bound by default to Lifecyle phase Maven-compiler-plugin Compile Goal: compile Goal: test-compile Test-compile Maven-surefire-plugin Goal: test TestAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 22Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven Plug-ins and Goals • Goals can be bound to build-lifecycle phases. Example: $ mvn test Validate Compile Test-Compile Test Execute Execute Execute Maven-compiler-plugin Goal: compile Maven-surefire-plugin Goal: test Goal: test-compileAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 23Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven Plug-ins and Goals • We can bind a plug-in’s goal to a lifecycle phaseAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 24Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven Lifecyle, Plug-ins and Goals • Putting lifecycles, phases, plug-ins and goals together…. – A lifecycle is a series of phases – A phase is made of goals – Goals are provided by plug-ins • Each phase have default bindingsAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 25Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • An introduction to Maven • Introduction • Build Lifecycle • Architecture • Plug-ins and Goals • Default phase bindings • Repositories • Artifacts • Project Object Model • Dependencies • ArchetypesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 26Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Default phase bindings • See http://maven.apache.org/guides/introduction/introduction-to-the- lifecycle.html#Built-in_Lifecycle_BindingsAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 27Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Default phase bindings(Continued…)An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 28Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Default phase bindings(Continued…)An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 29Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • An introduction to Maven • Introduction • Build Lifecycle • Architecture • Plug-ins and Goals • Default phase bindings • Repositories • Artifacts • Project Object Model • Dependencies • ArchetypesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 30Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven Repositories • Used to hold build artifacts/dependencies • Two types of repositories – Remote – LocalAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 31Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven Repositories • Remote repositories – Accessed by http://, file://, ftp:// or other supported protocol – Provided by a third party (example: http://repo1.maven.org, https://repository.jboss.org/nexus/) – Provided by your company to distribute private artifacts/dependenciesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 32Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven Repositories • Remote repositories – By default, any Maven project use http://repo1.maven.org/maven2, as a remote repository – Any number of remote repositories can be configuredAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 33Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven Repositories • Remote repositories – Also hold plug-ins – Plug-in repositories can be configuredAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 34Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven Repositories • Local repositories – Cache of dependencies and build artifacts used or produced by your project, located in Maven’s installation machine – By default, located at ${user.home}/.m2/repository – Can be overridden in file ${user.home}/.m2/settings.xmlAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 35Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • An introduction to Maven • Introduction • Build Lifecycle • Architecture • Plug-ins and Goals • Default phase bindings • Repositories • Artifacts • Project Object Model • Dependencies • ArchetypesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 36Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven artifacts • An artifact is a file resulting from packaging a project • Can be a jar, war, ear, .xml file, for example • Artifacts are deployed in repositories, so they can be used, as dependencies, by other projectsAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 37Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven artifacts • Artifacts are identified by three components: – Group Id  An unique identifier for a group of related artifacts. Usually named like Java packages (Ex: pt.jpereira.mobile) – Artifact Id  An unique identifier, within the context of GroupId, that identifies the artifact (project). (Ex: puzzle) – Version • Also called artifact coordinatesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 38Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • An introduction to Maven • Introduction • Build Lifecycle • Architecture • Plug-ins and Goals • Default phase bindings • Repositories • Artifacts • Project Object Model • Dependencies • ArchetypesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 39Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Project Object Model • POM for short • XML file located at the root of the project (pom.xml) • The configuration for your project, including – Information about the project – Configuration details to build the project – Contains default values for most of the projects. Ex: Source dir, target dir – Dependencies of the project – Configuration about plugins and goals – Used repositories –…An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 40Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Project Object Model • Minimum configuration is: • project root • modelVersion - should be set to 4.0.0 • groupId - the id of the projects group. • artifactId - the id of the artifact (project) • version - the version of the artifact under the specified groupAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 41Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Project Object Model • Minimum configuration exampleAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 42Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Super POM • Every POM has a super POM • What is not specified, and is required to build the project, is inherited from a super POM Super POM Project’s POMAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 43Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Project Inheritance • Any POM, by default, inherit from the super POM • POM can inherit other POM, like class inheritance in Java Super POM Project’s Parent POM Project 1 POM Project 2 POM Project 3 POMAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 44Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Project Inheritance • Example of POM Inheritance GroupId is also inherited Minimum requiredAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 45Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Project Inheritance • A POM can override values from POMs higher in the hierarchy • An effective POM is the sum of all configurations in the hierarchy of POMs • You can see the effective POM by using: – mvn help:effective-pomAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 46Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Multi module POM • A POM can aggregate multiple modules • Commonly used configuration (remember the n-tier architectures, for example) • A POM can aggregate multiple modules and be their parent POM at the same timeAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 47Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Multi module POM • Example for Maven 2.2.2 project: Module of Parent POM and multi module POMAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 48Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • An introduction to Maven • Introduction • Build Lifecycle • Architecture • Plug-ins and Goals • Default phase bindings • Repositories • Artifacts • Project Object Model • Dependencies • ArchetypesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 49Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Dependencies • Selling point of Maven • Managing hundreds of dependencies is hard • Maven will manage the dependencies for you • Dependencies are cached in you local repository • Transitive dependencies managed by Maven • Multiple scopes for including dependenciesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 50Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Declaring Dependencies • Must provide the coordinates of the artifact: – GroupId – ArtifactId – Version • Declared in pom.xml <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.9</version> <scope>test</scope> </dependency> </dependencies>An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 51Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Dependency Management • Mechanism to centralize dependency information • Have all information about dependencies in the parent POM (version, exclusions, scope, type) • Child POMs only have to have a simple reference to the dependencies, excluding version, exclusions, scope type.An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 52Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Dependency Management • Example: Project A Project B <project> <project> <dependencies> <dependencies> <dependency> <dependency> <groupId>group-a</groupId> <groupId>group-c</groupId> <artifactId>artifact-a</artifactId> <artifactId>artifact-b</artifactId> <version>1.0</version> <version>1.0</version> <exclusions> <type>war</type> <exclusion> <scope>runtime</scope> <groupId>group-c</groupId> </dependency> <artifactId>ex-artif</artifactId> <dependency> </exclusion> <groupId>group-a</groupId> </exclusions> <artifactId>artifact-b</artifactId> </dependency> <version>1.0</version> <dependency> <type>jar</type> <groupId>group-a</groupId> <scope>runtime</scope> <artifactId>artifact-b</artifactId> </dependency> <version>1.0</version> </dependencies> <type>jar</type> </project> <scope>runtime</scope> </dependency> </dependencies> </project>An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 53Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Dependency Management <project> Parent POM <dependencyManagement> <dependencies> <dependency> <groupId>group-a</groupId> <artifactId>artifact-a</artifactId> <version>1.0</version> <exclusions> <exclusion> <groupId>group-c</groupId> <artifactId>excluded-artifact</artifactId> </exclusion> </exclusions> </dependency>Put here all information about <dependency> <groupId>group-c</groupId>dependencies <artifactId>artifact-b</artifactId> <version>1.0</version> <type>war</type> <scope>runtime</scope> </dependency> <dependency> <groupId>group-a</groupId> <artifactId>artifact-b</artifactId> <version>1.0</version> <type>jar</type> <scope>runtime</scope> </dependency> </dependencies> </dependencyManagement> </project>An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 54Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Dependency Management Parent POM Project A Project BAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 55Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Dependency Management • Simplified POMs: Project A Project B <project> <project> <parent> <parent> <groupId>GroupParent</groupId> <groupId>GroupParent</groupId> <artifactId>parentPOM</artifactId> <artifactId>parentPOM</artifactId> </parent> </parent> <dependencies> <dependencies> <dependency> <dependency> <groupId>group-a</groupId> <groupId>group-c</groupId> <artifactId>artifact-a</artifactId> <artifactId>artifact-b</artifactId> </dependency> <type>war</type> <dependency> </dependency> <groupId>group-a</groupId> <dependency> <artifactId>artifact-b</artifactId> <groupId>group-a</groupId> </dependency> <artifactId>artifact-b</artifactId> </dependencies> </dependency> </project> </dependencies> </project>An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 56Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Cache Dependencies Depends Your Project Effective use LIB_A_V1 LIB_B_V1 LIB_C_V2 LIB_A_V1 LIB_B_V1 LIB_C_V2 Download Remote Local Repositories Repository (Cache)An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 57Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Transitive dependencies • Maven will manage the dependencies of your dependencies Your Project LIB_A_V1 LIB_B_V1 LIB_C_V2 LIB_D_V1 LIB_E_V1 LIB_E_V1 LIB_F_V1 LIB_G_V1 LIB_H_V1 LIB_I_V1LIB_j_V1 LIB_K_V1 LIB_L_V1 LIB_M_V1 LIB_N_V1 LIB_O_V1 LIB_P_V1 LIB_Q_V1An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 58Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Dependency Mediation • If version not explicit, Maven will use the nearest definition in the tree Your Project A 1.0 B 1.0 C 1.0 D 1.0 E 1.0 Which version of F will be used? F 1.0 G 1.0 F 2.0An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 59Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Dependency Mediation • If version not explicit, Maven will use the nearest definition in the tree Your Project A 1.0 B 1.0 C 1.0 D 1.0 E 1.0 Which version of F will be used? F 1.0 is the neareast in the tree F 1.0 G 1.0 F 2.0An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 60Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Dependency Scope • Allows you to only include dependencies appropriate for the current stage of the build • You don’t need all dependencies in all situations • Examples: – Why would you need to distribute JUnit library if you are not distributing tests to your customers? – Why would you package hibernate.jar into your ear file, if you will deploy your application to Jboss that already provides hibernate.jar?An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 61Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Available Scopes • 6 Available Scopes – Compile – Provided – Runtime – Test – System – Import (Maven 2.0.9 onwards)An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 62Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Compile Dependency • Default for dependencies not specifying scope • Available to all classpaths of build lifecycle (compile, test-compile, test, package) • Packaged into final artifact • Required by user projects, i.e., by projects that depends on the one declaring the dependency. – Example: If your project (Y) depends on project X, with scope compile, then any project (U) that depends on your project (Y) will transitively depends on X.An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 63Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Compile Dependency U Compile Dependency Will use X in all classpaths and packaged artifact Your Project (Y) Compile Dependency XAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 64Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Provided Dependency • Available to compile ant test classpaths • Not packaged as part of your artifact • It’s expected the container, where the artifact will be used, to provide the dependency – Example: Use of servlet-api for compilation and testing but will not distribute the servlet-api with the artifact, because is expected that the Servlet container to provide that dependencyAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 65Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Runtime Dependency • This dependency is not required for compiling your project • Is required at runtime, when your application run • Also required when testing because tests will execute main codeAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 66Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Runtime Dependency X’s API does not need Z, however X’s API implementation Your Project (Y) requires Z, thus Z is required to run Y but not compiling it. Compile Dependency API X Implementation Runtime Dependency ZAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 67Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Test Dependency • This dependency is only required to compile and run test • Will not be packaged into final assembly (Jar, War, Ear, etc) • Not needed when compiling or running main codeAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 68Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • System Dependency • Similar to Provided Dependency • Not looked up in repository • Expected to exists in your development machine • Have to give full path to the dependency using <systemPath> • Used only for rare cases where the build depend on the machine where the build process is taking place • Not recommendedAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 69Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Import Dependency • Only available on Maven 2.0.9 onwards • Used to import dependencies from other POM • Used with Dependency Management <dependencyManagement> • Use if you want to centralize all dependency management into a single project (in this case is that project will produces an POM file)An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 70Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Import Dependency Dependencies POM groupX:artifactX:1.0 (GroupId:ArtifactId:Version) <project> <dependencyManagement> <dependencies> <dependency> <project> <groupId>group-a</groupId> <dependencyManagement> <artifactId>artifact-a</artifactId> <dependencies> <version>1.0</version> <dependency> </dependency> <groupId>groupX</groupId> <dependency> <artifactId>artifactX</artifactId> <groupId>group-c</groupId> <version>1.0</version> <artifactId>artifact-b</artifactId> <type>pom</type> <version>1.0</version> <scope>import</scope> <type>war</type> </dependency> <scope>runtime</scope> </dependencyManagement> </dependency> <dependencies> <dependency> <dependency> <groupId>group-a</groupId> <groupId>group-c</groupId> <artifactId>artifact-b</artifactId> <artifactId>artifact-b</artifactId> <type>war</type> <version>1.0</version> </dependency> <type>jar</type> <dependency> <scope>runtime</scope> <groupId>group-a</groupId> </dependency> <artifactId>artifact-b</artifactId> </dependencies> </dependency> </dependencyManagement> </dependencies> </project> </project>An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 71Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Excluded Dependencies • Transitive dependencies can be excluded from dependency tree Your Project (Y) X X Transitive dependency ZAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 72Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Excluded Dependencies <dependencies> <dependency> <groupId>GroupX</groupId> <artifactId>ArtifactX</artifactId> <exclusions> <exclusion> <groupId>GroupZ</groupId> <artifactId>ArtifactZ</artifactId> </exclusion> </exclusions> </dependency> </dependencies>An introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 73Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Optional Dependencies • Optional dependencies are excluded by default Your Project (Y) X X Transitive dependency Optional ZAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 74Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • An introduction to Maven • Introduction • Build Lifecycle • Architecture • Plug-ins and Goals • Default phase bindings • Repositories • Artifacts • Project Object Model • Dependencies • ArchetypesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 75Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven archetypes • An archetype is a project template • Contains the common configurations for projects of the same type • Example: All JPA2.0 projects contains the dependencies to JPA2.0 API • You can create your archetypes from a project • Archetypes are deployed in repositoriesAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 76Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Maven archetypes • Using archetypes: – mvn archetype:generate • Create archetype from current project – mvn archetype:create-from-projectAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 77Attribution-NonCommercial-ShareAlike 3.0 Unported License.
    • Everything about… • Maven: – http://maven.apache.org/ – http://www.sonatype.com/books/mvnref- book/reference/ • POM: – http://maven.apache.org/pom.htmlAn introduction to Maven by João Miguel Pereira is licensed under a Creative Commons 78Attribution-NonCommercial-ShareAlike 3.0 Unported License.