SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
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
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
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
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 

Kürzlich hochgeladen (20)

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
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...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
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
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

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