Maven  OpenSource platform Integration
Maven
Agenda Maven Philosophy POM Standard Directory Layout Lifecycle Plugins Dependencies Release Repository Archetype Site
What is Maven? Standardized build infrastructure Build tool Dependency Management tool Quality tool OpenSource Apache project
Maven Philosophy Convention over Configuration Ease the build process Best practises patterns Consistent build
Project Descriptor POM ie Project Object Model ie pom.xml Contains all metadata of a project Name Packaging Type Dependencies Tool links (CI, SCM, Bug Tracker…) License People One POM == One Artifact POM relationships Inheritance Aggregation
Project Descriptor Sample <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/xsd/maven-4.0.0.xsd&quot;>  <modelVersion>4.0.0</modelVersion>  <groupId>com.mycompany.app</groupId>  <artifactId>my-app</artifactId>  <packaging>jar</packaging>  <version>1.0-SNAPSHOT</version>  <dependencies>  <dependency>  <groupId>junit</groupId>  <artifactId>junit</artifactId>  <version>4.5</version>  <scope>test</scope>  </dependency>  </dependencies>  </project>
Standard Directory Layout src/main/java src/main/resources src/main/config src/test/java src/test/resources src/site target
Build Lifecycle 3 different lifecycle default clean  site Phases (lifecycle default) validate compile test package integration-test verify install deploy Invoked with ‘mvn’ command line
Plugin Set of goals (Mojos) Plugin Goals can be bound to phases Depending on packaging type a list of goals are assigned to phases
Plugin goal binding <plugin>   <groupId>com.mycompany</groupId>   <artifactId>some-maven-plugin</artifactId>   <executions>   <execution>   <phase>process-test-resources</phase>   <configuration>…</configuration>   <goals>   <goal>someGoal</goal>   </goals>   </execution>   </executions> </plugin>
Plugin goal binding user mvn install generate- sources compile test install deploy package integration- test mojo mojo mojo mojo mojo bindings
Plugin sample Surefire Release Archetype Checkstyle Findbugs Cargo  (Application Server Deployment) Eclipse Groovy Native
Packaging Type Specifies artifact’s type Configure  default  lifecycle Available types jar war rar ear ejb / ejb3 maven-plugin (extends jar to install plugin in maven repository) pom Default packaging is  jar
Dependencies Identified by groupId artifactId version scope Scope affects dependencies transitivity and build classpath Available scope compile provided runtime test
Repository Contains artifacts and plugins (versioned) with associated pom No more lib copies per project Allows reproduceable builds Official remote repositories available; new ones can be added Local repository caches artifacts and allows offline builds
Site Automatic website generation based on project metadata Plugins can be added to generate report (surefire, checkstyle, findbugs…) Documentation can be written in several languages
Profile Allows to adapt build for a particular Environment / User Defined as part of pom.xml or user settings.xml Can be active by default  or activated based on conditions  or enabled on command line
Integration environment OpenSource
Agenda OpenSource  Platform Continuous Integration Source Control Manager Bug/Feature Tracker Maven Repository Maven Facilities
Continuous Integration http://opensource.fastconnect.org/hudson
Source Control Manager http://opensource.fastconnect.org/svn
Bug/Feature Tracker http://opensource.fastconnect.org/redmine
Maven Repository https://opensource.fastconnect.org/archiva
OpenSource Licences GPL or LGPL How to chose: http://fastconnect.org/mediawiki/index.php/OpenSource_License
Maven Facilities Archetype fr.fastconnect.maven:simple-archetype:1.1 fr.fastconnect.maven:openspaces-archetype:1.1 Parent POM fr.fastconnect.maven:parent:1.1 Skin fr.fastconnect.maven:simple-skin:1.0 Common  fr.fastconnect:common:0.6
Documentation http://fastconnect.org/mediawiki/index.php/Environment http://fastconnect.org/mediawiki/index.php/Maven http://fastconnect.org/mediawiki/index.php/Java_Project_Life_cycle http://fastconnect.org/mediawiki/index.php/Category:Maven_Plugin http://fastconnect.org/mediawiki/index.php/Subversion
Sample mvn archetype:generate  -DarchetypeGroupId=fr.fastconnect.maven  -DarchetypeArtifactId=simple-archetype  -DarchetypeVersion=1.0  -DartifactId=test –DgroupId=fr.fastconnect  cd test mvn license:format -Dlicense.type=gpl mvn verify -Dlicense.type=gpl mvn eclipse:eclipse mvn site cd target/site
End

Maven Overview

  • 1.
    Maven OpenSourceplatform Integration
  • 2.
  • 3.
    Agenda Maven PhilosophyPOM Standard Directory Layout Lifecycle Plugins Dependencies Release Repository Archetype Site
  • 4.
    What is Maven?Standardized build infrastructure Build tool Dependency Management tool Quality tool OpenSource Apache project
  • 5.
    Maven Philosophy Conventionover Configuration Ease the build process Best practises patterns Consistent build
  • 6.
    Project Descriptor POMie Project Object Model ie pom.xml Contains all metadata of a project Name Packaging Type Dependencies Tool links (CI, SCM, Bug Tracker…) License People One POM == One Artifact POM relationships Inheritance Aggregation
  • 7.
    Project Descriptor Sample<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/xsd/maven-4.0.0.xsd&quot;> <modelVersion>4.0.0</modelVersion> <groupId>com.mycompany.app</groupId> <artifactId>my-app</artifactId> <packaging>jar</packaging> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.5</version> <scope>test</scope> </dependency> </dependencies> </project>
  • 8.
    Standard Directory Layoutsrc/main/java src/main/resources src/main/config src/test/java src/test/resources src/site target
  • 9.
    Build Lifecycle 3different lifecycle default clean site Phases (lifecycle default) validate compile test package integration-test verify install deploy Invoked with ‘mvn’ command line
  • 10.
    Plugin Set ofgoals (Mojos) Plugin Goals can be bound to phases Depending on packaging type a list of goals are assigned to phases
  • 11.
    Plugin goal binding<plugin> <groupId>com.mycompany</groupId> <artifactId>some-maven-plugin</artifactId> <executions> <execution> <phase>process-test-resources</phase> <configuration>…</configuration> <goals> <goal>someGoal</goal> </goals> </execution> </executions> </plugin>
  • 12.
    Plugin goal bindinguser mvn install generate- sources compile test install deploy package integration- test mojo mojo mojo mojo mojo bindings
  • 13.
    Plugin sample SurefireRelease Archetype Checkstyle Findbugs Cargo (Application Server Deployment) Eclipse Groovy Native
  • 14.
    Packaging Type Specifiesartifact’s type Configure default lifecycle Available types jar war rar ear ejb / ejb3 maven-plugin (extends jar to install plugin in maven repository) pom Default packaging is jar
  • 15.
    Dependencies Identified bygroupId artifactId version scope Scope affects dependencies transitivity and build classpath Available scope compile provided runtime test
  • 16.
    Repository Contains artifactsand plugins (versioned) with associated pom No more lib copies per project Allows reproduceable builds Official remote repositories available; new ones can be added Local repository caches artifacts and allows offline builds
  • 17.
    Site Automatic websitegeneration based on project metadata Plugins can be added to generate report (surefire, checkstyle, findbugs…) Documentation can be written in several languages
  • 18.
    Profile Allows toadapt build for a particular Environment / User Defined as part of pom.xml or user settings.xml Can be active by default or activated based on conditions or enabled on command line
  • 19.
  • 20.
    Agenda OpenSource Platform Continuous Integration Source Control Manager Bug/Feature Tracker Maven Repository Maven Facilities
  • 21.
  • 22.
    Source Control Managerhttp://opensource.fastconnect.org/svn
  • 23.
  • 24.
  • 25.
    OpenSource Licences GPLor LGPL How to chose: http://fastconnect.org/mediawiki/index.php/OpenSource_License
  • 26.
    Maven Facilities Archetypefr.fastconnect.maven:simple-archetype:1.1 fr.fastconnect.maven:openspaces-archetype:1.1 Parent POM fr.fastconnect.maven:parent:1.1 Skin fr.fastconnect.maven:simple-skin:1.0 Common fr.fastconnect:common:0.6
  • 27.
    Documentation http://fastconnect.org/mediawiki/index.php/Environment http://fastconnect.org/mediawiki/index.php/Mavenhttp://fastconnect.org/mediawiki/index.php/Java_Project_Life_cycle http://fastconnect.org/mediawiki/index.php/Category:Maven_Plugin http://fastconnect.org/mediawiki/index.php/Subversion
  • 28.
    Sample mvn archetype:generate -DarchetypeGroupId=fr.fastconnect.maven -DarchetypeArtifactId=simple-archetype -DarchetypeVersion=1.0 -DartifactId=test –DgroupId=fr.fastconnect cd test mvn license:format -Dlicense.type=gpl mvn verify -Dlicense.type=gpl mvn eclipse:eclipse mvn site cd target/site
  • 29.