SlideShare a Scribd company logo
1 of 26
Apache Maven :
                                 A maven in build automation




 Venkat Raghavan G
 M.S - Computer Science
 ADVIS Laboratory.




Department of Computer Science                                 University of Illinois at Chicago.
Motivation..
     • Large number of modules with proper description/status.
     •
     • Rectify implementation issues – Eg: Integrate with a build server or use JARs with
     other projects.
     • How about decreasing training time for developers?
     • Spend more time on programming than organizing it.
     • What about Ant, buildr… Gradle*?
     • The goal is to simplify tests, build, integrations and reporting.




University of Illinois at Chicago.                                               Venkat Raghavan G
Maven - Introduction
     • Officially described as “Software project management & comprehension” tool.
     •
     • Widely recognized as a build automation tool, typically for Java projects.
     • Based on Project-Object-Model (POM)
     • It has a plugin execution framework .
     • Maintains a model of a project :
            • Dependency management
            • Remote repositories
            • Reuse of build logic
            • Tool portability
University of Illinois at Chicago.                                                  Venkat Raghavan G
Today’s talk..
     • Maven Introduction
     •
     • POM
     • Plugin execution framework
     • Build Lifecycle
     • Creating a maven project
     • Advanced Topics*




University of Illinois at Chicago.   Venkat Raghavan G
Maven - History
     • Initiated in 2001 as an Apache Jakarta project.
     •
     • Moved to Turbine after that.
     • Active development by 2003
     • Maven 2.0 in 2005 (POM)
     • Maven 3.0 in 2010
            • Maven 3.0.4 in Jan 2012




University of Illinois at Chicago.                       Venkat Raghavan G
Installation
     • Download tar.gz and extract to ~/
     •
     • Set ‘M2_HOME’ environment variable to ~/<maven>
     • Set ‘M2_HOME/bin’ to PATH : use bashrc or make a symbolic link in /usr/bin
     • Type ‘mvn’ to see the options.




University of Illinois at Chicago.                                            Venkat Raghavan G
Project Object Model (POM)
     • Heart of Maven 2
     •
     • XML – Containing Project info and configuration details
            • build path, dependencies, testing resources, team members, structure etc.
     • Super POM – Default POM. All POMs extend Super POM.
                          <project>
                          <modelVersion>3.0.0</modelVersion>
                          <name>Maven Project</name>
                          <repositories>
                                         <repository>
                                         <id>central</id>
                                         <name>In-house Repository </name>
                                         <layout>default</layout>
                                         <url>http://repos.uic.edu/maven2</url> <snapshots>
                          </repository> </repositories> …..

University of Illinois at Chicago.                                                            Venkat Raghavan G
Ant “build.xml”
 <project name=“sample" default="dist" basedir=".">
   <description>
        •
     Compare Ant & POM
   </description>
   <property name="src" location="src/main/java"/>
   <property name="build" location="target/classes"/>
   <property name="dist" location="target"/>
                                                                                                 Maven “POM.xml”
     <target name="init">                                                            <project>
       <mkdir dir="${build}"/>                                                        <modelVersion>1.0.0</modelVersion>
     </target>
                                                                                      <groupId>edu.uic.lab1</groupId>
     <target name="compile" depends="init“ description="compile the source " >        <artifactId>Project1</artifactId>
         <javac srcdir="${src}" destdir="${build}"/>                                  <version>1.0</version>
     </target>                                                                       </project>
     <target name="dist" depends="compile“ description="generate the distribution"
 >
        <mkdir dir="${dist}/lib"/>
        <jar jarfile="${dist}/build/sample.jar" basedir="${build}"/>
     </target>
 …
 …….


University of Illinois at Chicago.                                                                           Venkat Raghavan G
Convention over configuration..
     src/main/java                   Application/Library sources
     •
     src/main/resources              Application/Library resources                    • Standardized structure
     src/main/filters                Resource filter files                            • Can be overridden but
     src/main/assembly               Assembly descriptors                             not recommended
     src/main/config                 Configuration files
     src/main/scripts                Application/Library scripts
     src/main/webapp                 Web application sources
     src/test/java                   Test sources
     src/test/resources              Test resources
     src/test/filters                Test resource filter files
     src/site                        Site
     LICENSE.txt                     Project's license
                                     Notices and attributions required by libraries
     NOTICE.txt
                                     that the project depends on
     README.txt                      Project's readme

University of Illinois at Chicago.                                                                  Venkat Raghavan G
More on POM..
     <project>
      <modelVersion>1.0.0</modelVersion>
      <groupId>edu.uic.lab1</groupId>                  Default POM
      <artifactId>Project1</artifactId>
      <version>1.0</version>

     <properties>
      <project.build.sourceEncoding>UTF-8              Properties – encoding, Java
      </project.build.sourceEncoding>                  system, user-defined, etc.
     </properties>

     <repositories>
        <repository>
           <id>repo1</id>                              Location for maven to lookup
           <url>http://project1.uic.edu/maven2</url>   when materializing the project.
        </repository>
     </repositories> ..

University of Illinois at Chicago.                                         Venkat Raghavan G
More on POM..
     <dependencies>
            <dependency>
                <groupId>log4j</groupId>               Defining dependencies
                <artifactId>log4j</artifactId>
                <version>1.2.12</version>
            </dependency>
     </dependencies>

     <build>
     <sourceDirectory>src</sourceDirectory>
     <testSourceDirectory>test</testSourceDirectory>
     <resources>
         <resource>
                                                       SuperPOM - Overriding
              <directory>resources</directory>
         </resource>
     </resources>
     </build>

University of Illinois at Chicago.                                       Venkat Raghavan G
Dependency configuration
   • Artifact is identified by coordinates
     •
                                                                         <dependencies>
                                                                                <dependency>
          • groupid, artifactid, version                                            <groupId>log4j</groupId>
                                                                                    <artifactId>log4j</artifactId>
                                                                                    <version>1.2.12</version>
   • No more version conflicts or binary data in VCS.                               <scope> test</scope>
          • Quick checkout, reuse artifacts                                     </dependency>
                                                                         </dependencies>

   • Version : <major>.<minor>.<revision>

   • Dependency scopes:
          1.   compile – packaged into the build file => JAR, WAR
          2.   provided – not packaged but used for compile => Servlet
          3.   runtime – not for compile but for tests => taglibs
          4.   test – used only for test => JUnit
          5.   system – similar to ‘provided’ => 3rd party softwares

University of Illinois at Chicago.                                                            Venkat Raghavan G
Plugin execution framework
                                                   <build>
    ••Maven, by itself, is a dummy XML framework    <plugins>
                                                     <plugin>
    • Plugins turn them into a giant tool.           <artifactId>maven-enforcer-plugin
                                                     </artifactId>
    • Collection of one or more ‘goals’              <version>1.1.1</version>
                                                    <executions>
    • Does ‘executions’.                            <execution>
                                                     <id>enforce-java</id>
                                                     <goals>
    • Custom plugin can be written.                   <goal>enforce</goal>
                                                     </goals>
           • Java, Groovy, Ruby etc.
                                                     <configuration>
                                                      <rules>
                                                       <requireJavaVersion>
                                                        <version>[1.6.0-0,1.6.0-32]</version>
                                                       </requireJavaVersion>
                                                     </rules>
                                                     </configuration>…..



University of Illinois at Chicago.                                                Venkat Raghavan G
Repository configuration
    ••Central repository :                       <repositories>
                                                    <repository>
         • http://repo1.maven.org/maven2             <id>central</id>
         • Huge set of libraries are available       <url>http://repo1.maven.org/maven2
                                                     </url>
                                                    </repository>
    • Local repository :                         </repositories>

         • ~/${maven-folder}/repository
         • Contains artifacts
               • used by maven
               • used by projects
               • created by projects




University of Illinois at Chicago.                                    Venkat Raghavan G
Creating a new repository
    ••Get a web space.
    • Create a new maven project.
    • Add ‘extension’ for a protocol in POM: Eg: – wagon-ftp
    • Add ‘distributionManagement’ repository – the new FTP address
    • To keep it secure, add credentials to ~/.m2/settings.xml
    • mvn deploy
    • Share your repository link to the world!




University of Illinois at Chicago.                                    Venkat Raghavan G
Default life-cycle..
                                                              Plugins

                                     generate-sources         archetype
                                     compile
                                                              compiler
                                     test-compile

                                     test
                                                        POM    surefire
                                     package

                                     integration-test            jar
                                     install

                                     deploy                    install


University of Illinois at Chicago.                                        Venkat Raghavan G
Few maven commands..
    ••mvn dependency:analyze  Cleans up the dependencies again
    • mvn dependency:tree (or) mvn dependency:list  To learn about dependencies.
    • mvn install  Install the o/p to the repository
    • mvn clean  Cleans the target directory
    • mvn package  Creates war/jar
    • mvn compile  Compiles the project
    • mvn test  Tests as defined in POM




University of Illinois at Chicago.                                          Venkat Raghavan G
Creating a maven project..
     • Understand “archetype”
     • mvn archetype:generate -DgroupId=edu.uic –DartifactId=project1 –
     DarchetypeGroupId=maven-archetype-quickstart
            • Creates maven project with default POM
            • Creates src/main/java and src/test/java folders




University of Illinois at Chicago.                                        Venkat Raghavan G
Extra POM elements..
     • <developers> <developer>….
     • <contributors><contributor>…
     • <organization>
     • <licenses><license>…
     • <reporting>
                   And so on…




University of Illinois at Chicago.    Venkat Raghavan G
Some useful links..
    ••POM Reference -- http://maven.apache.org/pom.html
    • Repository using FTP -- http://stuartsierra.com/2009/09/08/run-your-own-maven-
    repository
    • Advanced reading -- http://shop.oreilly.com/product/9780596517335.do




University of Illinois at Chicago.                                           Venkat Raghavan G
Advanced topics..
     •
     Inheritance

             • “Management” prefix keyword.
             • ‘pluginManagement’ and ‘dependencyManagement’
             • Does inheritance
             • Used in more complex projects
             • Be careful! Not to be confused with ‘plugins’/’dependencies’




University of Illinois at Chicago.                                            Venkat Raghavan G
Advanced topics..
     •
     Profiles

             • Customize build based on environments.
                    • Eg: production, development
             • Allows build portability

                           <profiles>
                               <profile>
                                        <id>production</id>
                                        <build> …. </build>
                               </profile>
                           </profiles>

University of Illinois at Chicago.                            Venkat Raghavan G
Advanced topics..
     •
     Creating website

             • Create a maven project
             • Add jetty plugin and run “mvn jetty:run”
             • Add site-descriptors to pom.xml
             • Document using APT, Xdoc or FML (Maven uses Doxia)
             • Deploy




University of Illinois at Chicago.                                  Venkat Raghavan G
Advanced topics..
     •
     Add security

             • Restrict users for deployment, build, distribution etc.
             • Create a private key : mvn –ecrypt-master-password myPassword
             • Add <settingssecurity> to ~/{maven2}/settings-security.xml
             • You can register in the server through “settings.xml”.




University of Illinois at Chicago.                                             Venkat Raghavan G
Summary
        • Maven – more than a build automation tool
        • Convention over configuration
        • Central repository and dependency management
        • Execution of life-cycle phases through plugin
        • Software project management services viz. websites, reporting etc.
        • Integration with eclipse IDE through m2e plugin




University of Illinois at Chicago.                                             Venkat Raghavan G
•




                                     Thank You!!




University of Illinois at Chicago.                 Venkat Raghavan G

More Related Content

What's hot

Jdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent ProjectsJdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent ProjectsMert Çalışkan
 
Tycho - good, bad or ugly ?
Tycho - good, bad or ugly ?Tycho - good, bad or ugly ?
Tycho - good, bad or ugly ?Max Andersen
 
How to be effective with JBoss Developer Studio
How to be effective with JBoss Developer StudioHow to be effective with JBoss Developer Studio
How to be effective with JBoss Developer StudioMax Andersen
 
Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for DummiesTomer Gabel
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with MavenSid Anand
 
Enterprise Maven Repository BOF
Enterprise Maven Repository BOFEnterprise Maven Repository BOF
Enterprise Maven Repository BOFMax Andersen
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeansRyan Cuprak
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and AntDavid Noble
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to MavenJoao Pereira
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules uploadRyan Cuprak
 
Maven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafeMaven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafeHolasz Kati
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1MD Sayem Ahmed
 

What's hot (20)

Jdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent ProjectsJdc 2010 - Maven, Intelligent Projects
Jdc 2010 - Maven, Intelligent Projects
 
Tycho - good, bad or ugly ?
Tycho - good, bad or ugly ?Tycho - good, bad or ugly ?
Tycho - good, bad or ugly ?
 
How to be effective with JBoss Developer Studio
How to be effective with JBoss Developer StudioHow to be effective with JBoss Developer Studio
How to be effective with JBoss Developer Studio
 
Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for Dummies
 
Hands On with Maven
Hands On with MavenHands On with Maven
Hands On with Maven
 
Enterprise Maven Repository BOF
Enterprise Maven Repository BOFEnterprise Maven Repository BOF
Enterprise Maven Repository BOF
 
Maven Overview
Maven OverviewMaven Overview
Maven Overview
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
 
Java Builds with Maven and Ant
Java Builds with Maven and AntJava Builds with Maven and Ant
Java Builds with Maven and Ant
 
Apache maven 2 overview
Apache maven 2 overviewApache maven 2 overview
Apache maven 2 overview
 
An introduction to Maven
An introduction to MavenAn introduction to Maven
An introduction to Maven
 
Preparing for java 9 modules upload
Preparing for java 9 modules uploadPreparing for java 9 modules upload
Preparing for java 9 modules upload
 
Maven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafeMaven Presentation - SureFire vs FailSafe
Maven Presentation - SureFire vs FailSafe
 
Demystifying Maven
Demystifying MavenDemystifying Maven
Demystifying Maven
 
Maven basics
Maven basicsMaven basics
Maven basics
 
Apache Maven basics
Apache Maven basicsApache Maven basics
Apache Maven basics
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Maven nutshell
Maven nutshellMaven nutshell
Maven nutshell
 
Maven basic concept
Maven basic conceptMaven basic concept
Maven basic concept
 
An Introduction to Maven Part 1
An Introduction to Maven Part 1An Introduction to Maven Part 1
An Introduction to Maven Part 1
 

Viewers also liked

Transition de NIBs/XIBs vers Storyboards
Transition de NIBs/XIBs vers StoryboardsTransition de NIBs/XIBs vers Storyboards
Transition de NIBs/XIBs vers StoryboardsCocoaHeads France
 
Cocoaheads Paris Nombembre Test unitaires
Cocoaheads Paris Nombembre Test unitairesCocoaheads Paris Nombembre Test unitaires
Cocoaheads Paris Nombembre Test unitairesCocoaHeads France
 
Maven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in MavenMaven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in MavenGeert Pante
 
Engineering & Materials Science Orientation
Engineering & Materials Science OrientationEngineering & Materials Science Orientation
Engineering & Materials Science OrientationHossam Farran
 
Maven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension toolMaven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension toolelliando dias
 

Viewers also liked (6)

Transition de NIBs/XIBs vers Storyboards
Transition de NIBs/XIBs vers StoryboardsTransition de NIBs/XIBs vers Storyboards
Transition de NIBs/XIBs vers Storyboards
 
Cocoaheads Paris Nombembre Test unitaires
Cocoaheads Paris Nombembre Test unitairesCocoaheads Paris Nombembre Test unitaires
Cocoaheads Paris Nombembre Test unitaires
 
Maven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in MavenMaven plugins, properties en profiles: Advanced concepts in Maven
Maven plugins, properties en profiles: Advanced concepts in Maven
 
6.3 sequence activities
6.3 sequence activities6.3 sequence activities
6.3 sequence activities
 
Engineering & Materials Science Orientation
Engineering & Materials Science OrientationEngineering & Materials Science Orientation
Engineering & Materials Science Orientation
 
Maven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension toolMaven 2.0 - Project management and comprehension tool
Maven 2.0 - Project management and comprehension tool
 

Similar to Apache Maven (20)

Maven in Mule
Maven in MuleMaven in Mule
Maven in Mule
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Maven
MavenMaven
Maven
 
Maven introduction in Mule
Maven introduction in MuleMaven introduction in Mule
Maven introduction in Mule
 
Training in Android with Maven
Training in Android with MavenTraining in Android with Maven
Training in Android with Maven
 
Introduction to Maven
Introduction to MavenIntroduction to Maven
Introduction to Maven
 
Mavenppt
MavenpptMavenppt
Mavenppt
 
Introduction To Maven2
Introduction To Maven2Introduction To Maven2
Introduction To Maven2
 
Liferay maven sdk
Liferay maven sdkLiferay maven sdk
Liferay maven sdk
 
Maven
MavenMaven
Maven
 
Oracle 12c Launch Event 02 ADF 12c and Maven in Jdeveloper / By Aino Andriessen
Oracle 12c Launch Event 02 ADF 12c and Maven in Jdeveloper / By Aino Andriessen Oracle 12c Launch Event 02 ADF 12c and Maven in Jdeveloper / By Aino Andriessen
Oracle 12c Launch Event 02 ADF 12c and Maven in Jdeveloper / By Aino Andriessen
 
Ant, Maven and Jenkins
Ant, Maven and JenkinsAnt, Maven and Jenkins
Ant, Maven and Jenkins
 
Developing Liferay Plugins with Maven
Developing Liferay Plugins with MavenDeveloping Liferay Plugins with Maven
Developing Liferay Plugins with Maven
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with Maven
 
Releasing Projects Using Maven
Releasing Projects Using MavenReleasing Projects Using Maven
Releasing Projects Using Maven
 
Maven Basics - Explained
Maven Basics - ExplainedMaven Basics - Explained
Maven Basics - Explained
 
Maven II
Maven IIMaven II
Maven II
 
Maven part 2
Maven part 2Maven part 2
Maven part 2
 

Recently uploaded

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Apache Maven

  • 1. Apache Maven : A maven in build automation Venkat Raghavan G M.S - Computer Science ADVIS Laboratory. Department of Computer Science University of Illinois at Chicago.
  • 2. Motivation.. • Large number of modules with proper description/status. • • Rectify implementation issues – Eg: Integrate with a build server or use JARs with other projects. • How about decreasing training time for developers? • Spend more time on programming than organizing it. • What about Ant, buildr… Gradle*? • The goal is to simplify tests, build, integrations and reporting. University of Illinois at Chicago. Venkat Raghavan G
  • 3. Maven - Introduction • Officially described as “Software project management & comprehension” tool. • • Widely recognized as a build automation tool, typically for Java projects. • Based on Project-Object-Model (POM) • It has a plugin execution framework . • Maintains a model of a project : • Dependency management • Remote repositories • Reuse of build logic • Tool portability University of Illinois at Chicago. Venkat Raghavan G
  • 4. Today’s talk.. • Maven Introduction • • POM • Plugin execution framework • Build Lifecycle • Creating a maven project • Advanced Topics* University of Illinois at Chicago. Venkat Raghavan G
  • 5. Maven - History • Initiated in 2001 as an Apache Jakarta project. • • Moved to Turbine after that. • Active development by 2003 • Maven 2.0 in 2005 (POM) • Maven 3.0 in 2010 • Maven 3.0.4 in Jan 2012 University of Illinois at Chicago. Venkat Raghavan G
  • 6. Installation • Download tar.gz and extract to ~/ • • Set ‘M2_HOME’ environment variable to ~/<maven> • Set ‘M2_HOME/bin’ to PATH : use bashrc or make a symbolic link in /usr/bin • Type ‘mvn’ to see the options. University of Illinois at Chicago. Venkat Raghavan G
  • 7. Project Object Model (POM) • Heart of Maven 2 • • XML – Containing Project info and configuration details • build path, dependencies, testing resources, team members, structure etc. • Super POM – Default POM. All POMs extend Super POM. <project> <modelVersion>3.0.0</modelVersion> <name>Maven Project</name> <repositories> <repository> <id>central</id> <name>In-house Repository </name> <layout>default</layout> <url>http://repos.uic.edu/maven2</url> <snapshots> </repository> </repositories> ….. University of Illinois at Chicago. Venkat Raghavan G
  • 8. Ant “build.xml” <project name=“sample" default="dist" basedir="."> <description> • Compare Ant & POM </description> <property name="src" location="src/main/java"/> <property name="build" location="target/classes"/> <property name="dist" location="target"/> Maven “POM.xml” <target name="init"> <project> <mkdir dir="${build}"/> <modelVersion>1.0.0</modelVersion> </target> <groupId>edu.uic.lab1</groupId> <target name="compile" depends="init“ description="compile the source " > <artifactId>Project1</artifactId> <javac srcdir="${src}" destdir="${build}"/> <version>1.0</version> </target> </project> <target name="dist" depends="compile“ description="generate the distribution" > <mkdir dir="${dist}/lib"/> <jar jarfile="${dist}/build/sample.jar" basedir="${build}"/> </target> … ……. University of Illinois at Chicago. Venkat Raghavan G
  • 9. Convention over configuration.. src/main/java Application/Library sources • src/main/resources Application/Library resources • Standardized structure src/main/filters Resource filter files • Can be overridden but src/main/assembly Assembly descriptors not recommended src/main/config Configuration files src/main/scripts Application/Library scripts src/main/webapp Web application sources src/test/java Test sources src/test/resources Test resources src/test/filters Test resource filter files src/site Site LICENSE.txt Project's license Notices and attributions required by libraries NOTICE.txt that the project depends on README.txt Project's readme University of Illinois at Chicago. Venkat Raghavan G
  • 10. More on POM.. <project> <modelVersion>1.0.0</modelVersion> <groupId>edu.uic.lab1</groupId> Default POM <artifactId>Project1</artifactId> <version>1.0</version> <properties> <project.build.sourceEncoding>UTF-8 Properties – encoding, Java </project.build.sourceEncoding> system, user-defined, etc. </properties> <repositories> <repository> <id>repo1</id> Location for maven to lookup <url>http://project1.uic.edu/maven2</url> when materializing the project. </repository> </repositories> .. University of Illinois at Chicago. Venkat Raghavan G
  • 11. More on POM.. <dependencies> <dependency> <groupId>log4j</groupId> Defining dependencies <artifactId>log4j</artifactId> <version>1.2.12</version> </dependency> </dependencies> <build> <sourceDirectory>src</sourceDirectory> <testSourceDirectory>test</testSourceDirectory> <resources> <resource> SuperPOM - Overriding <directory>resources</directory> </resource> </resources> </build> University of Illinois at Chicago. Venkat Raghavan G
  • 12. Dependency configuration • Artifact is identified by coordinates • <dependencies> <dependency> • groupid, artifactid, version <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.12</version> • No more version conflicts or binary data in VCS. <scope> test</scope> • Quick checkout, reuse artifacts </dependency> </dependencies> • Version : <major>.<minor>.<revision> • Dependency scopes: 1. compile – packaged into the build file => JAR, WAR 2. provided – not packaged but used for compile => Servlet 3. runtime – not for compile but for tests => taglibs 4. test – used only for test => JUnit 5. system – similar to ‘provided’ => 3rd party softwares University of Illinois at Chicago. Venkat Raghavan G
  • 13. Plugin execution framework <build> ••Maven, by itself, is a dummy XML framework <plugins> <plugin> • Plugins turn them into a giant tool. <artifactId>maven-enforcer-plugin </artifactId> • Collection of one or more ‘goals’ <version>1.1.1</version> <executions> • Does ‘executions’. <execution> <id>enforce-java</id> <goals> • Custom plugin can be written. <goal>enforce</goal> </goals> • Java, Groovy, Ruby etc. <configuration> <rules> <requireJavaVersion> <version>[1.6.0-0,1.6.0-32]</version> </requireJavaVersion> </rules> </configuration>….. University of Illinois at Chicago. Venkat Raghavan G
  • 14. Repository configuration ••Central repository : <repositories> <repository> • http://repo1.maven.org/maven2 <id>central</id> • Huge set of libraries are available <url>http://repo1.maven.org/maven2 </url> </repository> • Local repository : </repositories> • ~/${maven-folder}/repository • Contains artifacts • used by maven • used by projects • created by projects University of Illinois at Chicago. Venkat Raghavan G
  • 15. Creating a new repository ••Get a web space. • Create a new maven project. • Add ‘extension’ for a protocol in POM: Eg: – wagon-ftp • Add ‘distributionManagement’ repository – the new FTP address • To keep it secure, add credentials to ~/.m2/settings.xml • mvn deploy • Share your repository link to the world! University of Illinois at Chicago. Venkat Raghavan G
  • 16. Default life-cycle.. Plugins generate-sources archetype compile compiler test-compile test POM surefire package integration-test jar install deploy install University of Illinois at Chicago. Venkat Raghavan G
  • 17. Few maven commands.. ••mvn dependency:analyze  Cleans up the dependencies again • mvn dependency:tree (or) mvn dependency:list  To learn about dependencies. • mvn install  Install the o/p to the repository • mvn clean  Cleans the target directory • mvn package  Creates war/jar • mvn compile  Compiles the project • mvn test  Tests as defined in POM University of Illinois at Chicago. Venkat Raghavan G
  • 18. Creating a maven project.. • Understand “archetype” • mvn archetype:generate -DgroupId=edu.uic –DartifactId=project1 – DarchetypeGroupId=maven-archetype-quickstart • Creates maven project with default POM • Creates src/main/java and src/test/java folders University of Illinois at Chicago. Venkat Raghavan G
  • 19. Extra POM elements.. • <developers> <developer>…. • <contributors><contributor>… • <organization> • <licenses><license>… • <reporting> And so on… University of Illinois at Chicago. Venkat Raghavan G
  • 20. Some useful links.. ••POM Reference -- http://maven.apache.org/pom.html • Repository using FTP -- http://stuartsierra.com/2009/09/08/run-your-own-maven- repository • Advanced reading -- http://shop.oreilly.com/product/9780596517335.do University of Illinois at Chicago. Venkat Raghavan G
  • 21. Advanced topics.. • Inheritance • “Management” prefix keyword. • ‘pluginManagement’ and ‘dependencyManagement’ • Does inheritance • Used in more complex projects • Be careful! Not to be confused with ‘plugins’/’dependencies’ University of Illinois at Chicago. Venkat Raghavan G
  • 22. Advanced topics.. • Profiles • Customize build based on environments. • Eg: production, development • Allows build portability <profiles> <profile> <id>production</id> <build> …. </build> </profile> </profiles> University of Illinois at Chicago. Venkat Raghavan G
  • 23. Advanced topics.. • Creating website • Create a maven project • Add jetty plugin and run “mvn jetty:run” • Add site-descriptors to pom.xml • Document using APT, Xdoc or FML (Maven uses Doxia) • Deploy University of Illinois at Chicago. Venkat Raghavan G
  • 24. Advanced topics.. • Add security • Restrict users for deployment, build, distribution etc. • Create a private key : mvn –ecrypt-master-password myPassword • Add <settingssecurity> to ~/{maven2}/settings-security.xml • You can register in the server through “settings.xml”. University of Illinois at Chicago. Venkat Raghavan G
  • 25. Summary • Maven – more than a build automation tool • Convention over configuration • Central repository and dependency management • Execution of life-cycle phases through plugin • Software project management services viz. websites, reporting etc. • Integration with eclipse IDE through m2e plugin University of Illinois at Chicago. Venkat Raghavan G
  • 26. Thank You!! University of Illinois at Chicago. Venkat Raghavan G