Mavenizing your
Liferay project

April 18th 2012
Presented by
Jan Gregor




                  …the open source integrator
Presenter
• Introductions   Jan Gregor
                  Senior Portal Consultant
• Questions?
• Presenter




   26.04.2012                                2
Agenda
• Choosing the right build system- Stable and
  efficient build system is a heart of good software
  engineering
• Maven & Liferay– Transforming good to perfect
• Live demo - build, deploy and release of real
  project using Maven
• Next steps – what is planned…
• Q&A




     26.04.2012                                        3
Choosing the right build system
• OOTB Liferay IDE/SDK comes with Ant
• What is wrong with Ant ?
  └   Learn the ant tasks (non-standard)
  └   Non standard folder structure
  └   Integration into existing maven build infrastructure
  └   No dependency management
  └   No versioning
  └   No simple release management




      26.04.2012                                             4
Choosing the right build system
• What is wrong with Ant ?
  └   “Works on my machine ” code
  └   Machine/User-dependant builds
  └   Installation/management effort
  └   Inconsistency of developer environments
  └   Scalability in big teams




      26.04.2012                                5
Choosing the right build system
• Impact on project
  └ Decrease of quality
      └ No releasing
      └ No dependency management
      └ Maintenance & Scalability in future
  └ Higher costs
      └ High effort for each developer setup
      └ Delay by WOMM problems….
  └ Higher project risk
      └ Non-standard processes




     26.04.2012                                6
Choosing the right build system
• Maven
  Maven's primary goal is to allow a developer to comprehend
  the complete state of a development effort in the shortest
  period of time. In order to attain this goal there are several
  areas of concern that Maven attempts to deal with:

  └   Making the build process easy
  └   Providing a uniform build system
  └   Providing quality project information
  └   Providing guidelines for best practices development
  └   Allowing transparent migration to new features



      26.04.2012                                                   7
Maven & Liferay
• Need for a maven plugin for Liferay development

  └ Liferay Maven plugin
      └ Official maven support provided by Liferay with focus on copying the
        ant-based approach in maven enviroment
  └ Mimacom Maven plugin
      └ Custom maven plugin focused on maximizing potential and
        advantages from Maven build system and connecting it with Liferay
        portal
      └ Open source
      └ Plugin maven site




     26.04.2012                                                                8
Mimacom Maven plugin
• Goal of plugin
  └   Wraps the ant scripts with a nice maven facade
  └   Use of standard maven project layout
  └   No learning effort
  └   All maven features are available
  └   Produces self contained artifacts, deployable directly on
      any application server




      26.04.2012                                                  9
Mimacom Maven plugin
• Plugin features
  └   Standardized and transparent build system
  └   Portal customizations without ext
  └   Full support of all liferay plugins development
  └   Product-like packaging of software
  └   Application-server specific builds
  └   Migration & dependency management
  └   Patch management




      26.04.2012                                        10
Standardized & transparent build
• Project structure with standard maven modules
  └ Parent (defines project base configuration)
      └ Portal (represents Liferay portal)
      └ Plugins (represents Liferay plugins)
      └ Another modules (can be anything…)




     26.04.2012                                   11
Portal customizations without ext
• Portal as a part of project
   └ Standard maven module
   └ Opposite of “ext” approach
   └ Original and customization on
     one place
      └ Always separated
      └ Delivered as a black box
   └ Built and deployed by maven



   └ Live preview in eclipse



     26.04.2012                      12
Support of all liferay plugins
• Standard maven modules
   └   Themes
   └   Hooks
   └   Plugins
   └   Layouts
• Build & deploy to server
• Standard folder structure
• Specific plugin configuration

  └    Live preview in eclipse




       26.04.2012                 13
Product-like packaging
• All components are managed by Maven
  └   OOTB Liferay portal
  └   Portal customizations
  └   Plugins
  └   Configuration
  └   Libraries

  └ Singe point of
       └   Compile
       └   Build
       └   Release
       └   Delivery



      26.04.2012                        14
Product-like packaging
• Developing portal customizations
  └ “Ext way”
      └ Separate installation of Application server + Liferay
      └ Developing ext-modules and deploying to portal
  └ Maven way
      └ OOTB Portal with all artifacts and dependencies stored in Maven
        repository
      └ Customizations are made in a maven module
      └ By build time the ootb portal + customizations are merged and
        delivered as a single monolithic package




     26.04.2012                                                           15
Product-like packaging
• Developing portal customizations
  └ Customizations to
      └   Portal-impl
      └   Portal-web
      └   Portal-service
      └   Portal configuration


  └ 3 delivery artifacts
      └ Portal war file
      └ Portal configuration
      └ Portal dependencies




     26.04.2012                      16
Product-like packaging
• Developing portal-service
  customizations
  └ Using standard maven approach
  └ New maven module
      └ Packaging jar
      └ Added portal-service dependencies
      └ Overriding classes
  └ Finally add to portal module as
    dependency
  └ Configure for automatic
    deployment into /lib/ext




     26.04.2012                             17
Product-like packaging
• Delivery artifacts
   └ Portal war-file
       └ Merge ootb + changes
       └ Clear separation for developer
       └ Transparent delivery for customer
   └ Portal dependencies (zip)
       └ Manageable and configurable
   └ Portal configuration (zip)
       └ Separated config files
       └ Manageable and configurable


   └ Getting profits from all standard
     development approaches


      26.04.2012                             18
Product-like packaging
• Profits
   └   All software components managed on a single place
   └   Full control of used versions, components, changes
   └   Clear separation of customized and original code
   └   “Blackbox” delivery of software to a customer without
       any previous installation of portal




       26.04.2012                                              19
Application-server specific builds
• Common problems
  └ Different development / production environments
  └ Automatization and control of AS dependent builds
  └ Missing auto deploy functionality by some Application
    servers




    26.04.2012                                              20
Application-server specific builds
• Individual builds for different AS’s
   └ Integration with maven profiling
   └ Current support of Tomcat & Websphere AS
   └ Simulating deployment process in Liferay by build time
     -> Ensure simple deployment to WAS
   └ Live preview in Eclipse




     26.04.2012                                               21
Migration & dependency management
• All artifacts stored in maven
  repository
   └ Portal-web/impl/service
   └ Portal dependencies
   └ 3rd party libraries




     26.04.2012                     22
Migration & dependency management
• Installing new Liferay version (Step 1)
  └ Download the artifacts
      └ CE
       mvn org.mimacom.maven.plugins:maven-liferay-plugin:downloadLiferay
       -Dversion=6.0.6


      └ EE (Requires access to Customer portal)
       mvn org.mimacom.maven.plugins:maven-liferay-plugin:downloadLiferay
       -Dversion=6.0.11
       -DfileVersion=6.0-ee-sp1
       -Dusername=XXX
       -Dpassword=XXX




     26.04.2012                                                             23
Migration & dependency management
• Installing new Liferay version (Step 2)
   └ Upload the artefacts to maven repository

 mvn org.mimacom.maven.plugins:maven-liferay-plugin:deployLiferay
 -DrepositoryId=mimacom-repo-id-deploy-thirdparty
 -DrepositoryUrl=${mimacom-deploy-path-thirdparty}
 -Dversion=5.2.9
 -DfileVersion=5.2-ee-sp5
 -DserverType=tomcat




   └ Plugin will automatically upload all artifacts into
     repository




       26.04.2012                                                   24
Migration & dependency management
• Migrating to newer Liferay version
  └ Change the dependency version




  └ All dependencies and ootb portal will be
    automatically updated by build time
  └ Possible compile problems and API incompatibility
    immediately signalized




     26.04.2012                                         25
Patch management
• Profiting from maven
  dependency
  management
  └ All patches provided by
    Liferay need to be installed
    in Maven repository
  └ Versioning enables
    installation of “wrong”
    patches
  └ Internal persistent storage
    of all provided patches




     26.04.2012                    26
Patch management
• Integrating patches to
  project
  └ Portal-impl
      └ Dependencies with scope
        compile
  └ Portal-service
      └ Dependencies with scope
        compile and moved by plugin
        to global libraries
  └ Portal-web
      └ Integrated as a maven
        module (hook plugin)
  └ Portlets
      └ Integrated a maven module


     26.04.2012                       27
Next steps
• Support of maven archetypes
• Support of more application servers
• Integration with Liferay IDE and Liferay’s maven
  support
• Improving product-like documentation &
  features
• Providing enterprise support




     26.04.2012                                      28
How to start
• Visit plugin maven site
  └ http://repo.mimacom.org/content/repositories/mimaco
    m-sites-
    open/org/mimacom/maven/plugins/1.5.5/org.edorasfra
    mework.tools.parent/maven-liferay-plugin/index.html
• Any feedback is very welcome!




     26.04.2012                                           29
mimacom path




          Idee              Lösung




© mimacom ag     10/21/10
                  31
Contact




    Contact mimacom:                  Contact Liferay
    International: +41 31 329 09 00   Free: +49 6196 773 0680
    johan.oelen@mimacom.ch            sales-eu@liferay.com

Mavenizing your Liferay project

  • 1.
    Mavenizing your Liferay project April18th 2012 Presented by Jan Gregor …the open source integrator
  • 2.
    Presenter • Introductions Jan Gregor Senior Portal Consultant • Questions? • Presenter 26.04.2012 2
  • 3.
    Agenda • Choosing theright build system- Stable and efficient build system is a heart of good software engineering • Maven & Liferay– Transforming good to perfect • Live demo - build, deploy and release of real project using Maven • Next steps – what is planned… • Q&A 26.04.2012 3
  • 4.
    Choosing the rightbuild system • OOTB Liferay IDE/SDK comes with Ant • What is wrong with Ant ? └ Learn the ant tasks (non-standard) └ Non standard folder structure └ Integration into existing maven build infrastructure └ No dependency management └ No versioning └ No simple release management 26.04.2012 4
  • 5.
    Choosing the rightbuild system • What is wrong with Ant ? └ “Works on my machine ” code └ Machine/User-dependant builds └ Installation/management effort └ Inconsistency of developer environments └ Scalability in big teams 26.04.2012 5
  • 6.
    Choosing the rightbuild system • Impact on project └ Decrease of quality └ No releasing └ No dependency management └ Maintenance & Scalability in future └ Higher costs └ High effort for each developer setup └ Delay by WOMM problems…. └ Higher project risk └ Non-standard processes 26.04.2012 6
  • 7.
    Choosing the rightbuild system • Maven Maven's primary goal is to allow a developer to comprehend the complete state of a development effort in the shortest period of time. In order to attain this goal there are several areas of concern that Maven attempts to deal with: └ Making the build process easy └ Providing a uniform build system └ Providing quality project information └ Providing guidelines for best practices development └ Allowing transparent migration to new features 26.04.2012 7
  • 8.
    Maven & Liferay •Need for a maven plugin for Liferay development └ Liferay Maven plugin └ Official maven support provided by Liferay with focus on copying the ant-based approach in maven enviroment └ Mimacom Maven plugin └ Custom maven plugin focused on maximizing potential and advantages from Maven build system and connecting it with Liferay portal └ Open source └ Plugin maven site 26.04.2012 8
  • 9.
    Mimacom Maven plugin •Goal of plugin └ Wraps the ant scripts with a nice maven facade └ Use of standard maven project layout └ No learning effort └ All maven features are available └ Produces self contained artifacts, deployable directly on any application server 26.04.2012 9
  • 10.
    Mimacom Maven plugin •Plugin features └ Standardized and transparent build system └ Portal customizations without ext └ Full support of all liferay plugins development └ Product-like packaging of software └ Application-server specific builds └ Migration & dependency management └ Patch management 26.04.2012 10
  • 11.
    Standardized & transparentbuild • Project structure with standard maven modules └ Parent (defines project base configuration) └ Portal (represents Liferay portal) └ Plugins (represents Liferay plugins) └ Another modules (can be anything…) 26.04.2012 11
  • 12.
    Portal customizations withoutext • Portal as a part of project └ Standard maven module └ Opposite of “ext” approach └ Original and customization on one place └ Always separated └ Delivered as a black box └ Built and deployed by maven └ Live preview in eclipse 26.04.2012 12
  • 13.
    Support of allliferay plugins • Standard maven modules └ Themes └ Hooks └ Plugins └ Layouts • Build & deploy to server • Standard folder structure • Specific plugin configuration └ Live preview in eclipse 26.04.2012 13
  • 14.
    Product-like packaging • Allcomponents are managed by Maven └ OOTB Liferay portal └ Portal customizations └ Plugins └ Configuration └ Libraries └ Singe point of └ Compile └ Build └ Release └ Delivery 26.04.2012 14
  • 15.
    Product-like packaging • Developingportal customizations └ “Ext way” └ Separate installation of Application server + Liferay └ Developing ext-modules and deploying to portal └ Maven way └ OOTB Portal with all artifacts and dependencies stored in Maven repository └ Customizations are made in a maven module └ By build time the ootb portal + customizations are merged and delivered as a single monolithic package 26.04.2012 15
  • 16.
    Product-like packaging • Developingportal customizations └ Customizations to └ Portal-impl └ Portal-web └ Portal-service └ Portal configuration └ 3 delivery artifacts └ Portal war file └ Portal configuration └ Portal dependencies 26.04.2012 16
  • 17.
    Product-like packaging • Developingportal-service customizations └ Using standard maven approach └ New maven module └ Packaging jar └ Added portal-service dependencies └ Overriding classes └ Finally add to portal module as dependency └ Configure for automatic deployment into /lib/ext 26.04.2012 17
  • 18.
    Product-like packaging • Deliveryartifacts └ Portal war-file └ Merge ootb + changes └ Clear separation for developer └ Transparent delivery for customer └ Portal dependencies (zip) └ Manageable and configurable └ Portal configuration (zip) └ Separated config files └ Manageable and configurable └ Getting profits from all standard development approaches 26.04.2012 18
  • 19.
    Product-like packaging • Profits └ All software components managed on a single place └ Full control of used versions, components, changes └ Clear separation of customized and original code └ “Blackbox” delivery of software to a customer without any previous installation of portal 26.04.2012 19
  • 20.
    Application-server specific builds •Common problems └ Different development / production environments └ Automatization and control of AS dependent builds └ Missing auto deploy functionality by some Application servers 26.04.2012 20
  • 21.
    Application-server specific builds •Individual builds for different AS’s └ Integration with maven profiling └ Current support of Tomcat & Websphere AS └ Simulating deployment process in Liferay by build time -> Ensure simple deployment to WAS └ Live preview in Eclipse 26.04.2012 21
  • 22.
    Migration & dependencymanagement • All artifacts stored in maven repository └ Portal-web/impl/service └ Portal dependencies └ 3rd party libraries 26.04.2012 22
  • 23.
    Migration & dependencymanagement • Installing new Liferay version (Step 1) └ Download the artifacts └ CE mvn org.mimacom.maven.plugins:maven-liferay-plugin:downloadLiferay -Dversion=6.0.6 └ EE (Requires access to Customer portal) mvn org.mimacom.maven.plugins:maven-liferay-plugin:downloadLiferay -Dversion=6.0.11 -DfileVersion=6.0-ee-sp1 -Dusername=XXX -Dpassword=XXX 26.04.2012 23
  • 24.
    Migration & dependencymanagement • Installing new Liferay version (Step 2) └ Upload the artefacts to maven repository mvn org.mimacom.maven.plugins:maven-liferay-plugin:deployLiferay -DrepositoryId=mimacom-repo-id-deploy-thirdparty -DrepositoryUrl=${mimacom-deploy-path-thirdparty} -Dversion=5.2.9 -DfileVersion=5.2-ee-sp5 -DserverType=tomcat └ Plugin will automatically upload all artifacts into repository 26.04.2012 24
  • 25.
    Migration & dependencymanagement • Migrating to newer Liferay version └ Change the dependency version └ All dependencies and ootb portal will be automatically updated by build time └ Possible compile problems and API incompatibility immediately signalized 26.04.2012 25
  • 26.
    Patch management • Profitingfrom maven dependency management └ All patches provided by Liferay need to be installed in Maven repository └ Versioning enables installation of “wrong” patches └ Internal persistent storage of all provided patches 26.04.2012 26
  • 27.
    Patch management • Integratingpatches to project └ Portal-impl └ Dependencies with scope compile └ Portal-service └ Dependencies with scope compile and moved by plugin to global libraries └ Portal-web └ Integrated as a maven module (hook plugin) └ Portlets └ Integrated a maven module 26.04.2012 27
  • 28.
    Next steps • Supportof maven archetypes • Support of more application servers • Integration with Liferay IDE and Liferay’s maven support • Improving product-like documentation & features • Providing enterprise support 26.04.2012 28
  • 29.
    How to start •Visit plugin maven site └ http://repo.mimacom.org/content/repositories/mimaco m-sites- open/org/mimacom/maven/plugins/1.5.5/org.edorasfra mework.tools.parent/maven-liferay-plugin/index.html • Any feedback is very welcome! 26.04.2012 29
  • 30.
    mimacom path Idee Lösung © mimacom ag 10/21/10 31
  • 34.
    Contact Contact mimacom: Contact Liferay International: +41 31 329 09 00 Free: +49 6196 773 0680 johan.oelen@mimacom.ch sales-eu@liferay.com