SlideShare uma empresa Scribd logo
1 de 88
Demystifying By Mike Desjardins
Topics ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
About Me ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Installation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Ant vs. Maven ,[object Object],[object Object],greeting_id greeting_text 1 Hello 2 Bon jour 3 Buenos dias 4 Kon ni chi wa
Example – Source Code First, we will need a class to represent a greeting: @Entity public   class  Greeting { @Id   @GeneratedValue (strategy=GenerationType. IDENTITY ) @Column (name= "greeting_id" ,nullable= false ,unique= true )  private  Integer  id ; @Column (name= "greeting_text" ) private  String  text ; @Column (name= "version" )  @Version private  Integer  version ; public  Integer getId() {  return   this . id ; } public   void  setId(Integer id) {  this . id  = id; } public  String getText() {  return   this . text ; } public   void  setText(String text) {  this . text  = text; } }
Example – Source Code Next, we will need a class with a static main method to actually do stuff...
Example – Source Code public   class  App { private   static  SessionFactory  sessionFactory ; static  { try  { sessionFactory  =  new  AnnotationConfiguration().configure().buildSessionFactory(); }  catch  (Throwable t) { System. out .println( &quot;Something terrible has happened.&quot; ); t.printStackTrace(); } } public   static  SessionFactory getSessionFactory() {  return  App. sessionFactory ; } public   void  run() { System. out .println( &quot;======================================================&quot; ); Criteria c = App. getSessionFactory ().openSession().createCriteria(Greeting. class ); List<Greeting> greetings =  c.list() ; for  (Greeting greeting : greetings) { System. out .println(greeting.getId() +  &quot;: &quot;  + greeting.getText()); } System. out .println( &quot;======================================================&quot; ); } public   static   void  main(String args[]) { App app =  new  App().run()); } }
Ant: Let's Get Started! First, let's create the directories for our project: Mac:~/_work$ mkdir demo-ant Mac:~/_work$ cd demo-ant Mac:~/_work/demo-ant$ mkdir src lib conf target Mac:~/_work/demo-ant$ cd src Mac:~/_work/demo-ant/src$ mkdir com Mac:~/_work/demo-ant/src$ cd com Mac:~/_work/demo-ant/src/com$ mkdir techmaine Mac:~/_work/demo-ant/src/com$ cd techmaine Mac:~/_work/demo-ant/src/com/techmaine$ mkdir antdemo Mac:~/_work/demo-ant/src/com/techmaine$
Ant: Let's Get Started! (If you’re more of a visual person)
Let's go get our jars! 1.) Visit the Hibernate Website, eventually find their download page…
Let's go get our jars! 2.) Download gigantic ZIP file ZZZZZZZZZ….
Let's go get our jars! 3.) Unpack the ZIP file 0  09-10-08 12:27  hibernate-distribution-3.3.1.GA/ 26428  09-10-08 12:21  hibernate-distribution-3.3.1.GA/lgpl.txt 1456  09-10-08 12:21  hibernate-distribution-3.3.1.GA/hibernate_logo.gif 152761  09-10-08 12:21  hibernate-distribution-3.3.1.GA/changelog.txt 2766130  09-10-08 12:27  hibernate-distribution-3.3.1.GA/hibernate3.jar 31493  09-10-08 12:22  hibernate-distribution-3.3.1.GA/hibernate-testing.jar 0  09-10-08 12:27  hibernate-distribution-3.3.1.GA/lib/ 0  09-10-08 12:27  hibernate-distribution-3.3.1.GA/lib/required/ 443432  06-13-08 12:09  hibernate-distribution-3.3.1.GA/lib/required/antlr-2.7.6.jar 559366  06-13-08 12:09  hibernate-distribution-3.3.1.GA/lib/required/commons-collections-3.1.jar 313898  06-13-08 12:09  hibernate-distribution-3.3.1.GA/lib/required/dom4j-1.6.1.jar 13236  06-13-08 12:09  hibernate-distribution-3.3.1.GA/lib/required/jta-1.1.jar 17384  08-19-08 19:40  hibernate-distribution-3.3.1.GA/lib/required/slf4j-api-1.5.2.jar 471005  06-13-08 12:10  hibernate-distribution-3.3.1.GA/lib/required/javassist-3.4.GA.jar 0  09-10-08 12:27  hibernate-distribution-3.3.1.GA/lib/optional/ 0  09-10-08 12:27  hibernate-distribution-3.3.1.GA/lib/optional/c3p0/ 608376  06-13-08 12:12  hibernate-distribution-3.3.1.GA/lib/optional/c3p0/c3p0-0.9.1.jar 0  09-10-08 12:27  hibernate-distribution-3.3.1.GA/lib/optional/proxool/ 475943  06-13-08 12:12  hibernate-distribution-3.3.1.GA/lib/optional/proxool/proxool-0.8.3.jar . . . . . . Holy Shnikeys! Do I really need  all  of this stuff?!?
Next Steps ,[object Object],[object Object],[object Object],[object Object]
Create the build.xml ,[object Object],[object Object],[object Object],[object Object],Step 1
Create the build.xml ,[object Object],build.xml <!-- set global properties for this build --> <property name=&quot;lib&quot; value=&quot;lib&quot;/> <property name=&quot;src&quot; value=&quot;src&quot;/> <property name=&quot;conf&quot; value=&quot;conf&quot;/> <property name=&quot;target&quot; value=&quot;target&quot;/> <property name=&quot;classes&quot; value=&quot;${target}/classes&quot;/> Step 2
Create the build.xml ,[object Object],[object Object],build.xml <fileset id=&quot;compile.libs&quot; dir=&quot;${lib}&quot;> <include name=&quot;antlr-2.7.6.jar&quot;/> <include name=&quot;asm.jar&quot;/> <include name=&quot;asm-attrs.jar&quot;/> <include name=&quot;cglib-2.1.3.jar&quot;/> <include name=&quot;commons-collections-3.2.jar&quot;/> <include name=&quot;commons-lang-2.3.jar&quot;/>  <include name=&quot;commons-logging-1.0.4.jar&quot;/> <include name=&quot;dom4j-1.6.1.jar&quot;/> <include name=&quot;ejb3-persistence.jar&quot;/> <include name=&quot;javassist.jar&quot;/> <include name=&quot;jboss-archive-browsing.jar&quot;/> <include name=&quot;jdbc2_0-stdext.jar&quot;/> <include name=&quot;jta.jar&quot;/> <include name=&quot;xml-apis.jar&quot;/> <include name=&quot;xercesImpl-2.6.2.jar&quot;/> <include name=&quot;hibernate3.jar&quot;/> <include name=&quot;hibernate-annotations.jar&quot;/> <include name=&quot;hibernate-commons-annotations.jar&quot;/> <include name=&quot;hibernate-entitymanager.jar&quot;/> </fileset> Step 3
Create the build.xml ,[object Object],build.xml <target name=&quot;init&quot;> <tstamp/> <mkdir dir=&quot;${classes}&quot;/> </target> <target name=&quot;compile&quot; depends=&quot;init&quot;> <mkdir dir=&quot;${basedir}/${classes}&quot;/> <javac srcdir=&quot;${basedir}/${src}&quot;    destdir=&quot;${basedir}/${classes}&quot;    debug=&quot;yes&quot;  target=&quot;1.5&quot;> <classpath> <fileset refid=&quot;compile.libs&quot;/> </classpath> </javac> <copy file=&quot;${basedir}/${conf}/hibernate.cfg.xml&quot;    todir=&quot;${basedir}/${classes}&quot;/> </target> <target name=&quot;clean&quot;> <delete quiet=&quot;yes&quot; dir=&quot;${basedir}/${target}&quot;/> <mkdir dir=&quot;${basedir}/${target}&quot;/> </target> Step 4
Create the build.xml ,[object Object],build.xml <fileset id=&quot;runtime.libs&quot; dir=&quot;${lib}&quot;> <include name=&quot;postgresql-8.2-507.jdbc3.jar&quot;/> </fileset> <target name=&quot;run&quot; depends=&quot;compile&quot;> <java classname=&quot;com.techmaine.antdemo.App&quot;> <classpath> <fileset refid=&quot;compile.libs&quot;/> <fileset refid=&quot;runtime.libs&quot;/> <pathelement location=&quot;${basedir}/${classes}&quot;/> </classpath> </java> </target> Step 5
Recap ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],The way
Maven Terminology ,[object Object]
Create a Project Directory ,[object Object],[object Object],mvn archetype:create -DgroupId=com.techmaine -DartifactId=demo-mvn  -DpackageName=com.techmaine.mvndemo -Dversion=1.0 Step 1
Create a Project Directory mvn  archetype :create -DgroupId=com.techmaine -DartifactId=demo-mvn  -DpackageName=com.techmaine.mvndemo -Dversion=1.0 Plugin Name Step 1
Create a Project Directory mvn archetype: create  -DgroupId=com.techmaine -DartifactId=demo-mvn  -DpackageName=com.techmaine.mvndemo -Dversion=1.0 Plugin Name Goal Step 1
Create a Project Directory Voila !  Look what maven has done for you: Step 1
Set up the dependencies Open pom.xml.  We need to tell maven that  we have a dependency on Hibernate: <project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0  http://maven.apache.org/maven-v4_0_0.xsd&quot;> <modelVersion>4.0.0</modelVersion> <groupId>com.techmaine</groupId> <artifactId>demo-mvn</artifactId> <packaging>jar</packaging> <version>1.0</version> <name>demo-mvn</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project> We’ll add the dependency here. Step 2
Set up the dependencies <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-annotations</artifactId> <version>3.3.1.ga</version> </dependency> This is all we need to add: We don’t need to tell Maven about any of the jars on which Hibernate depends; Maven takes care of all of the transitive dependencies for us! Step 2
Set up the compiler <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </build> Maven assumes a default source version of 1.3.  We need to tell it if we want 1.5.  Here’s a preview of plugin configuration: STUPIDITY ALERT! Step 3
Set up Hibernate Configuration Create a resources directory beneath the main (and, optionally, test) directory, and put the Hibernate configuration file there.  ,[object Object],[object Object],Step 4
Package Next, package everything up before we run it. To do this, invoke maven thusly: mvn package   This is an alternate way to invoke maven.  Instead of specifying a plugin and goal, you specify a phase (in this case, package is the phase).  A phase is a sequenced set of goals.  The package phase compiles the java classes and copies the resources Step 5
Execute Next, use the exec plugin to run our application: mvn  exec:exec   -DmainClass=com.techmaine.mvndemo.App Step 6
Recap ,[object Object],[object Object],[object Object],[object Object],[object Object]
Recap – Why Maven is Cool ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What can Maven do? ,[object Object],[object Object],[object Object],[object Object],[object Object],But... from where? * Actually, dependency downloads are done by a plugin, too.
Configuring Maven ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Configuring Maven ,[object Object],[object Object],[object Object],[object Object]
Repositories ,[object Object],[object Object],[object Object],[object Object]
The POM ,[object Object],[object Object],[object Object],[object Object],[object Object]
Anatomy of a POM File ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
General Information ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Coordinates
Project Inheritance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Project Inheritance ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Multimodule Projects ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Multimodule Projects ,[object Object],[object Object],[object Object]
Multimodule Projects ,[object Object],[object Object],[object Object],[object Object],[object Object],Depends on the EJB artifact Creates EJB jar
Multimodule: Reactor ,[object Object],[object Object],[object Object],[object Object]
User-Defined Properties ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
User-Defined Properties ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Other Properties ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dependencies ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dependencies ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dependencies ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],groupId and artifactId: must be unique
Dependencies ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dependencies ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dependencies ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Prevents this dependency from being included as a transitive dependency if some other project depends on this project.
Transitive Dependencies A 1.0 B 1.0 C 1.0 E 1.0 D 1.0 Our project (Project “A”) depends on B and C.  Project C depends on projects D and E.  Thus, our project depends on B, C, D, and E, and Maven will fetch and use these artifacts appropriately.
Transitive Dependencies A 1.0 B 1.0 C 1.0 E 1.0 D 1.0 Now, let’s say project C has a dependency on project B, but requires version 1.1.  If project A’s POM doesn’t explicitly require version 1.0 or earlier, then Maven will choose version 1.1. B 1.1
Transitive Dependencies A 1.0 B [1.0] C 1.0 E 1.0 D 1.0 Uh oh.  Now Project A is saying that it must use version 1.0 of B, and only version 1.0, and project C needs version 1.1 of project B. B [1.1]
Dependency Exclusions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Dependency Management Parent POM Child POM The  dependencyManagement  element allows you to specify version numbers of dependencies in child POMs without making all children dependent on a particular library. <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>2.5.5</version> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> </dependency> </dependencies>
SNAPSHOT Versions ,[object Object],[object Object],[object Object],[object Object]
Build Configuration ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Build Configuration ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Build Configuration  Filters ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Path to a properties file (name=value).  When the resources are processed during packaging, maven will substitute any ${name} strings with the corresponding value from the properties file.
Build Configuration Resources ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Build Configuration Plugins ,[object Object],[object Object],[object Object]
Plugin Configuration ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Plugin Configuration: Example ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Core Plugins ,[object Object],[object Object],[object Object],[object Object],[object Object],Maven Plugin Whirlwind Tour
Core Plugins, cont. ,[object Object],[object Object],[object Object],[object Object],[object Object],Maven Plugin Whirlwind Tour
Packaging Plugins ,[object Object],[object Object],[object Object],[object Object],[object Object],Maven Plugin Whirlwind Tour
Utility Plugins ,[object Object],[object Object],[object Object],[object Object],[object Object],Maven Plugin Whirlwind Tour
Build Lifecycle ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Maven’s Lifecycles ,[object Object],[object Object],[object Object],[object Object]
Clean Lifecycle ,[object Object],[object Object],[object Object],[object Object],[object Object]
Executions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Maven’s Default Lifecycle ,[object Object],validate generate-test-sources package generate-sources process-test-sources pre-integration-test process-sources generate-test-resources integration-test generate-resources process-test-resources post-integration-test process-resources test-compile verify compile test install process-classes prepare-package deploy
Package-Specific Lifecycles ,[object Object],Lifecycle Phase Goal process-resources resources:resources compile compiler:compile process-test-resources resources:testResources test-compile compiler:testCompile test surefire:test package war:war install install:install deploy deploy:deploy
Build Profiles ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Profiles: Customized Builds ,[object Object],[object Object],[object Object]
How to declare a profile ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Build Configuration in a Profile ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Example from  Maven: The Definitive Guide,  Sonatype, O’Reilly p.200
Activating a Profile ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Activation Elements ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Example from  Maven: The Definitive Guide,  Sonatype, O’Reilly p.204-205
Sometimes Maven Sucks … returns “about 128,000” results
Common Criticisms ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]

Mais conteúdo relacionado

Mais procurados (20)

Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
Maven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafeMaven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafe
 
Maven tutorial
Maven tutorialMaven tutorial
Maven tutorial
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1
 
Apache Maven In 10 Slides
Apache Maven In 10 SlidesApache Maven In 10 Slides
Apache Maven In 10 Slides
 
Maven tutorial
Maven tutorialMaven tutorial
Maven tutorial
 
Maven 3 Overview
Maven 3  OverviewMaven 3  Overview
Maven 3 Overview
 
Apache maven 2 overview
Apache maven 2 overviewApache maven 2 overview
Apache maven 2 overview
 
Maven basics
Maven basicsMaven basics
Maven basics
 
Apache Maven
Apache MavenApache Maven
Apache Maven
 
Development Tools - Maven
Development Tools - MavenDevelopment Tools - Maven
Development Tools - Maven
 
Using Maven 2
Using Maven 2Using Maven 2
Using Maven 2
 
Maven
MavenMaven
Maven
 
Maven ppt
Maven pptMaven ppt
Maven ppt
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to Maven
 
Introduction to maven
Introduction to mavenIntroduction to maven
Introduction to maven
 
Maven 2 features
Maven 2 featuresMaven 2 features
Maven 2 features
 
Maven tutorial for beginners
Maven tutorial for beginnersMaven tutorial for beginners
Maven tutorial for beginners
 
An Introduction to Maven
An Introduction to MavenAn Introduction to Maven
An Introduction to Maven
 

Destaque

Mastering Maven 2.0 In 1 Hour V1.3
Mastering Maven 2.0 In 1 Hour V1.3Mastering Maven 2.0 In 1 Hour V1.3
Mastering Maven 2.0 In 1 Hour V1.3Matthew McCullough
 
Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for DummiesTomer Gabel
 
Automated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yardsAutomated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yardsJohn Ferguson Smart Limited
 
Lorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenLorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenArnaud Héritier
 
Build Automation using Maven
Build Automation using Maven Build Automation using Maven
Build Automation using Maven Ankit Gubrani
 
Continuous Delivery with Jenkins and Wildfly (2014)
Continuous Delivery with Jenkins and Wildfly (2014)Continuous Delivery with Jenkins and Wildfly (2014)
Continuous Delivery with Jenkins and Wildfly (2014)Tracy Kennedy
 
Jenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated DeploymentJenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated DeploymentDan Stine
 
Maven 2 in the real world
Maven 2 in the real worldMaven 2 in the real world
Maven 2 in the real worldCarlo Bonamico
 
Introduction to Apache Maven
Introduction to Apache MavenIntroduction to Apache Maven
Introduction to Apache Mavenjuvenxu
 
Tycho Tutorial (EclipseCon 2012)
Tycho Tutorial (EclipseCon 2012)Tycho Tutorial (EclipseCon 2012)
Tycho Tutorial (EclipseCon 2012)jsievers
 
Análise de qualidade de código com Sonar - Fernando Boaglio
Análise de qualidade de código com Sonar - Fernando Boaglio Análise de qualidade de código com Sonar - Fernando Boaglio
Análise de qualidade de código com Sonar - Fernando Boaglio Fernando Boaglio
 
Continuous inspection with Sonar
Continuous inspection with SonarContinuous inspection with Sonar
Continuous inspection with Sonargaudol
 
Regla del Boy Scout y la Oxidación del Software
Regla del Boy Scout y la Oxidación del SoftwareRegla del Boy Scout y la Oxidación del Software
Regla del Boy Scout y la Oxidación del SoftwareAlejandro Pérez García
 

Destaque (20)

Mastering Maven 2.0 In 1 Hour V1.3
Mastering Maven 2.0 In 1 Hour V1.3Mastering Maven 2.0 In 1 Hour V1.3
Mastering Maven 2.0 In 1 Hour V1.3
 
Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for Dummies
 
Continuous delivery-with-maven
Continuous delivery-with-mavenContinuous delivery-with-maven
Continuous delivery-with-maven
 
Maven and ANT
Maven and ANTMaven and ANT
Maven and ANT
 
Automated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yardsAutomated Deployment with Maven - going the whole nine yards
Automated Deployment with Maven - going the whole nine yards
 
Maven 3 / Tycho
Maven 3 / TychoMaven 3 / Tycho
Maven 3 / Tycho
 
Maven 3.0 at Øredev
Maven 3.0 at ØredevMaven 3.0 at Øredev
Maven 3.0 at Øredev
 
Lorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - MavenLorraine JUG (1st June, 2010) - Maven
Lorraine JUG (1st June, 2010) - Maven
 
Build Automation using Maven
Build Automation using Maven Build Automation using Maven
Build Automation using Maven
 
Continuous Delivery with Jenkins and Wildfly (2014)
Continuous Delivery with Jenkins and Wildfly (2014)Continuous Delivery with Jenkins and Wildfly (2014)
Continuous Delivery with Jenkins and Wildfly (2014)
 
Jenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated DeploymentJenkins and Chef: Infrastructure CI and Automated Deployment
Jenkins and Chef: Infrastructure CI and Automated Deployment
 
Maven 2 in the real world
Maven 2 in the real worldMaven 2 in the real world
Maven 2 in the real world
 
Introduction to Apache Maven
Introduction to Apache MavenIntroduction to Apache Maven
Introduction to Apache Maven
 
Maven overview
Maven overviewMaven overview
Maven overview
 
Tycho Tutorial (EclipseCon 2012)
Tycho Tutorial (EclipseCon 2012)Tycho Tutorial (EclipseCon 2012)
Tycho Tutorial (EclipseCon 2012)
 
Análise de qualidade de código com Sonar - Fernando Boaglio
Análise de qualidade de código com Sonar - Fernando Boaglio Análise de qualidade de código com Sonar - Fernando Boaglio
Análise de qualidade de código com Sonar - Fernando Boaglio
 
Maven basic concept
Maven basic conceptMaven basic concept
Maven basic concept
 
Continuous inspection with Sonar
Continuous inspection with SonarContinuous inspection with Sonar
Continuous inspection with Sonar
 
Regla del Boy Scout y la Oxidación del Software
Regla del Boy Scout y la Oxidación del SoftwareRegla del Boy Scout y la Oxidación del Software
Regla del Boy Scout y la Oxidación del Software
 
Maven
MavenMaven
Maven
 

Semelhante a Demystifying Maven

Semelhante a Demystifying Maven (20)

Apache Ant
Apache AntApache Ant
Apache Ant
 
Introduction To Ant
Introduction To AntIntroduction To Ant
Introduction To Ant
 
Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat Tool
 
Ant - Another Neat Tool
Ant - Another Neat ToolAnt - Another Neat Tool
Ant - Another Neat Tool
 
Apache ant
Apache antApache ant
Apache ant
 
Ant User Guide
Ant User GuideAnt User Guide
Ant User Guide
 
Using Ant To Build J2 Ee Applications
Using Ant To Build J2 Ee ApplicationsUsing Ant To Build J2 Ee Applications
Using Ant To Build J2 Ee Applications
 
Red5 - PHUG Workshops
Red5 - PHUG WorkshopsRed5 - PHUG Workshops
Red5 - PHUG Workshops
 
Ant Build Tool
Ant Build ToolAnt Build Tool
Ant Build Tool
 
Introduction To Ant1
Introduction To  Ant1Introduction To  Ant1
Introduction To Ant1
 
Deploy Flex with Apache Ant
Deploy Flex with Apache AntDeploy Flex with Apache Ant
Deploy Flex with Apache Ant
 
ActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group PresentationActiveWeb: Chicago Java User Group Presentation
ActiveWeb: Chicago Java User Group Presentation
 
Sbt, idea and eclipse
Sbt, idea and eclipseSbt, idea and eclipse
Sbt, idea and eclipse
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
Ant
Ant Ant
Ant
 
Ext 0523
Ext 0523Ext 0523
Ext 0523
 
course slides -- powerpoint
course slides -- powerpointcourse slides -- powerpoint
course slides -- powerpoint
 
Adventurous Merb
Adventurous MerbAdventurous Merb
Adventurous Merb
 
Optimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for DockerOptimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for Docker
 
Rails 101
Rails 101Rails 101
Rails 101
 

Último

A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI AgeCprime
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

A Framework for Development in the AI Age
A Framework for Development in the AI AgeA Framework for Development in the AI Age
A Framework for Development in the AI Age
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 

Demystifying Maven

  • 1. Demystifying By Mike Desjardins
  • 2.
  • 3.
  • 4.
  • 5.
  • 6. Example – Source Code First, we will need a class to represent a greeting: @Entity public class Greeting { @Id @GeneratedValue (strategy=GenerationType. IDENTITY ) @Column (name= &quot;greeting_id&quot; ,nullable= false ,unique= true ) private Integer id ; @Column (name= &quot;greeting_text&quot; ) private String text ; @Column (name= &quot;version&quot; ) @Version private Integer version ; public Integer getId() { return this . id ; } public void setId(Integer id) { this . id = id; } public String getText() { return this . text ; } public void setText(String text) { this . text = text; } }
  • 7. Example – Source Code Next, we will need a class with a static main method to actually do stuff...
  • 8. Example – Source Code public class App { private static SessionFactory sessionFactory ; static { try { sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory(); } catch (Throwable t) { System. out .println( &quot;Something terrible has happened.&quot; ); t.printStackTrace(); } } public static SessionFactory getSessionFactory() { return App. sessionFactory ; } public void run() { System. out .println( &quot;======================================================&quot; ); Criteria c = App. getSessionFactory ().openSession().createCriteria(Greeting. class ); List<Greeting> greetings = c.list() ; for (Greeting greeting : greetings) { System. out .println(greeting.getId() + &quot;: &quot; + greeting.getText()); } System. out .println( &quot;======================================================&quot; ); } public static void main(String args[]) { App app = new App().run()); } }
  • 9. Ant: Let's Get Started! First, let's create the directories for our project: Mac:~/_work$ mkdir demo-ant Mac:~/_work$ cd demo-ant Mac:~/_work/demo-ant$ mkdir src lib conf target Mac:~/_work/demo-ant$ cd src Mac:~/_work/demo-ant/src$ mkdir com Mac:~/_work/demo-ant/src$ cd com Mac:~/_work/demo-ant/src/com$ mkdir techmaine Mac:~/_work/demo-ant/src/com$ cd techmaine Mac:~/_work/demo-ant/src/com/techmaine$ mkdir antdemo Mac:~/_work/demo-ant/src/com/techmaine$
  • 10. Ant: Let's Get Started! (If you’re more of a visual person)
  • 11. Let's go get our jars! 1.) Visit the Hibernate Website, eventually find their download page…
  • 12. Let's go get our jars! 2.) Download gigantic ZIP file ZZZZZZZZZ….
  • 13. Let's go get our jars! 3.) Unpack the ZIP file 0 09-10-08 12:27 hibernate-distribution-3.3.1.GA/ 26428 09-10-08 12:21 hibernate-distribution-3.3.1.GA/lgpl.txt 1456 09-10-08 12:21 hibernate-distribution-3.3.1.GA/hibernate_logo.gif 152761 09-10-08 12:21 hibernate-distribution-3.3.1.GA/changelog.txt 2766130 09-10-08 12:27 hibernate-distribution-3.3.1.GA/hibernate3.jar 31493 09-10-08 12:22 hibernate-distribution-3.3.1.GA/hibernate-testing.jar 0 09-10-08 12:27 hibernate-distribution-3.3.1.GA/lib/ 0 09-10-08 12:27 hibernate-distribution-3.3.1.GA/lib/required/ 443432 06-13-08 12:09 hibernate-distribution-3.3.1.GA/lib/required/antlr-2.7.6.jar 559366 06-13-08 12:09 hibernate-distribution-3.3.1.GA/lib/required/commons-collections-3.1.jar 313898 06-13-08 12:09 hibernate-distribution-3.3.1.GA/lib/required/dom4j-1.6.1.jar 13236 06-13-08 12:09 hibernate-distribution-3.3.1.GA/lib/required/jta-1.1.jar 17384 08-19-08 19:40 hibernate-distribution-3.3.1.GA/lib/required/slf4j-api-1.5.2.jar 471005 06-13-08 12:10 hibernate-distribution-3.3.1.GA/lib/required/javassist-3.4.GA.jar 0 09-10-08 12:27 hibernate-distribution-3.3.1.GA/lib/optional/ 0 09-10-08 12:27 hibernate-distribution-3.3.1.GA/lib/optional/c3p0/ 608376 06-13-08 12:12 hibernate-distribution-3.3.1.GA/lib/optional/c3p0/c3p0-0.9.1.jar 0 09-10-08 12:27 hibernate-distribution-3.3.1.GA/lib/optional/proxool/ 475943 06-13-08 12:12 hibernate-distribution-3.3.1.GA/lib/optional/proxool/proxool-0.8.3.jar . . . . . . Holy Shnikeys! Do I really need all of this stuff?!?
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24. Create a Project Directory mvn archetype :create -DgroupId=com.techmaine -DartifactId=demo-mvn -DpackageName=com.techmaine.mvndemo -Dversion=1.0 Plugin Name Step 1
  • 25. Create a Project Directory mvn archetype: create -DgroupId=com.techmaine -DartifactId=demo-mvn -DpackageName=com.techmaine.mvndemo -Dversion=1.0 Plugin Name Goal Step 1
  • 26. Create a Project Directory Voila ! Look what maven has done for you: Step 1
  • 27. Set up the dependencies Open pom.xml. We need to tell maven that we have a dependency on Hibernate: <project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&quot;> <modelVersion>4.0.0</modelVersion> <groupId>com.techmaine</groupId> <artifactId>demo-mvn</artifactId> <packaging>jar</packaging> <version>1.0</version> <name>demo-mvn</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project> We’ll add the dependency here. Step 2
  • 28. Set up the dependencies <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-annotations</artifactId> <version>3.3.1.ga</version> </dependency> This is all we need to add: We don’t need to tell Maven about any of the jars on which Hibernate depends; Maven takes care of all of the transitive dependencies for us! Step 2
  • 29. Set up the compiler <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.5</source> <target>1.5</target> </configuration> </plugin> </plugins> </build> Maven assumes a default source version of 1.3. We need to tell it if we want 1.5. Here’s a preview of plugin configuration: STUPIDITY ALERT! Step 3
  • 30.
  • 31. Package Next, package everything up before we run it. To do this, invoke maven thusly: mvn package This is an alternate way to invoke maven. Instead of specifying a plugin and goal, you specify a phase (in this case, package is the phase). A phase is a sequenced set of goals. The package phase compiles the java classes and copies the resources Step 5
  • 32. Execute Next, use the exec plugin to run our application: mvn exec:exec -DmainClass=com.techmaine.mvndemo.App Step 6
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49.
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55.
  • 56.
  • 57. Transitive Dependencies A 1.0 B 1.0 C 1.0 E 1.0 D 1.0 Our project (Project “A”) depends on B and C. Project C depends on projects D and E. Thus, our project depends on B, C, D, and E, and Maven will fetch and use these artifacts appropriately.
  • 58. Transitive Dependencies A 1.0 B 1.0 C 1.0 E 1.0 D 1.0 Now, let’s say project C has a dependency on project B, but requires version 1.1. If project A’s POM doesn’t explicitly require version 1.0 or earlier, then Maven will choose version 1.1. B 1.1
  • 59. Transitive Dependencies A 1.0 B [1.0] C 1.0 E 1.0 D 1.0 Uh oh. Now Project A is saying that it must use version 1.0 of B, and only version 1.0, and project C needs version 1.1 of project B. B [1.1]
  • 60.
  • 61. Dependency Management Parent POM Child POM The dependencyManagement element allows you to specify version numbers of dependencies in child POMs without making all children dependent on a particular library. <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>2.5.5</version> </dependency> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> </dependency> </dependencies>
  • 62.
  • 63.
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69.
  • 70.
  • 71.
  • 72.
  • 73.
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79.
  • 80.
  • 81.
  • 82.
  • 83.
  • 84.
  • 85.
  • 86. Sometimes Maven Sucks … returns “about 128,000” results
  • 87.
  • 88.