CQ MAVEN METHODSCQCON 2013
HELLO WORLDIm Andrew.asavory@adobe.com@savs
Joined Adobe in November 2012
CQ NewbieJCR/CMS/TLA old hat
Background in Open Source, Content Management, Mobile
Talking today about what I learned so far...
FORK ME!If you found this talk useful, or spotted mistakes:github.com/savs/CQCon_2013_CQ_Maven_Methods
IN YOUR BROWSERhttp://goo.gl/qqS1F
SEE ALSOhttp://www.planetcq.org/
LETS BUILD A CQ SITE... uh, where to begin?
METHOD 1Enthusiastically rush in, use CRXDE Lite
METHOD 2Im a guru, I use Eclipse and CRXDE
METHOD 3Im a ninja, I use emacs and vlt
METHOD 4Im a guru ninja, I use vi and curl
METHOD 5See also: http://xkcd.com/378/ – Real Programmers
BUT WHAT ABOUT ...reverting mistakes?reproducible builds?collaborating with others?deploying to production?
WHY ISNT IT EASIER TO BUILD A CQ SITE?Laborious project inceptionNo two projects alikeDont know project layoutDont know pr...
CQ SUCKS
$PRODUCT SUCKS
YOUR METHODOLOGY SUCKS(sorry)
SO HOW DO WE FIX THIS?MavenGit(or Subversion, or CVS ... ymmv)Best Practices
MAVEN“Maven is a software project managementand comprehension tool. Based on theconcept of a project object model (POM),Ma...
GIT“Git is a free and open source distributedversion control system designed to handleeverything from small to very large ...
BEST PRACTICES“A best practice is a method or technique thathas consistently shown results superior tothose achieved with ...
WHAT DO WE WANT?Minimal customisationStandardised way to create a projectStandardised way to build a projectStandardised w...
OUR TARGET
Success criteria:ITS EASY TO BUILD A CQ SITE!
GETTING STARTEDInstall Maven: http://maven.apache.org/guides/getting-started/Install Git: http://git-scm.com/book/en/Getti...
CONFIGURING MAVENMaven has a settings file that defines things likerepositories where plugins can be downloaded (typically...
CONFIGURING MAVEN<profile><id>adobe-public</id><activation><activeByDefault>false</activeByDefault></activation><propertie...
CONFIGURING MAVENEnable the repository:Or use the -P option to activate profile(s):<activeProfiles><activeProfile>adobe-pu...
USING MAVEN
STARTING A NEW PROJECT ...... can sometimes feel like reinventing the wheel.
YOU ARE HERE
ARCHETYPESarchetype |ˈɑːkɪtʌɪp|nouna very typical example of a certain person or thing: he wasthe archetype of the old-sty...
MAVEN ARCHETYPESA prototype upon which others arecopied, patterned, or emulated.
WHAT CQ ARCHETYPES ARE THERE?simple-content-packageGenerates a simplemultimodule-content-packageIncludes the folder struct...
ON PACKAGESPackages enable the importing and exporting of repositorycontent. They are used to install new functionality, t...
ON BUNDLESBundles are modular containers of functionality for OSGi –essentially a java module that contains application lo...
HOW TO USE AN ARCHETYPEarchetypeGroupId: identifies the archetype projectuniquely across all projectsarchetypeArtifactId: ...
SIMPLE CONTENT PACKAGE ARCHETYPEFrom the fine manual:“Creates a maven project that is suitable forinstalling resources for...
SIMPLE CONTENT PACKAGE USAGEarchetypeGroupId: com.day.jcr.vaultidentifies the archetype project uniquely across all projec...
SIMPLE CONTENT PACKAGE IN ACTION
SIMPLE CONTENT PACKAGE PARAMETERSgroupId: Like a package name, e.g.com.yourcompany.myprojectartifactId: name of the jar wi...
SIMPLE CONTENT PACKAGE OUTPUTTemplate directoriespom.xml fileInstructions for compiling, creating bundles, deployingto CQ ...
MULTIMODULE CONTENT PACKAGE USAGEmvn archetype:generate-DarchetypeGroupId=com.day.jcr.vault-DarchetypeArtifactId=multimodu...
MULTIMODULE CONTENT PACKAGE OUTPUT${artifactId}|- pom.xml|- bundle|- pom.xml|- src|- main|- java|- ${groupId}|- SimpleDSCo...
|- filter.xml|- nodetypes.cnd|- properties.xml|- definition|- .content.xml
CQBLUEPRINTS MULTI-MODULE USAGEFirst add the CQ Blueprints Maven Repository to Mavenssettings.xml, then:archetypeGroupID: ...
CQBLUEPRINTS MULTI-MODULE OUTPUT${artifactId}|- README|- pom.xml|- ${artifactId}-all|- pom.xml|- ${artifactId}-config|- ${...
WHY USE CQBLUEPRINTS MULTI-MODULE?The cqblueprint multi-module archetype is developed by“The things we wanted to consider ...
CQBLUEPRINTS MULTIMODULE DESIGNfoo-view subproject: where css/html/js developers (frontend)do their workfoo-taglib foo-ser...
USING GIT
WHY GIT?Local safety net"The internet is my backup"Its good to shareEnlightened self-interest
YOU ARE HERE
GIT PROJECT SETUPcd projectnamegit init
GIT IGNOREEdit .gitignore, for example:.classpath.project.vlt/.settings/target/
GET IT IN GITgit add *git commit -m Initial project version
GET IT IN GITHUB (OPTIONAL)hub-new-repo is a shortcut for creating a repository ongithub and pushing your local repo into ...
DEMO
... TIME PASSES ...
COMMIT PROJECTgit add filenamesgit commit -m "meaningful message"git push origin master
(BEST) PRACTICE(S)
YOU ARE HERE
“the three great virtues of a programmer:laziness, impatience, and hubris”
BUILDING
HOW CAN WE BUILD SMARTER?Create local zips and jars that you can upload:mvn packageproduces:Content package output: target...
DEPLOYING
HOW CAN WE BUILD AND DEPLOY SMARTER?Content package: mvn -PautoInstallPackageinstallBundle: mvn -PautoInstallBundle instal...
DEMO
DEVELOPING
YOU ARE HERE
How do we develop in a world of maven builds and deploysand git saves?
THE FILEVAULT TOOLYou can use the FileVault tool (vlt) to check in, check out,update and sync local content with the repos...
SAMPLE DEVELOPMENT WORKFLOWUse maven to build and deployInitialise vltCreate components, templates with CRXDE LiteUse vlt ...
DEMO
TESTING
CONTINUOUS INTEGRATION?with ,as awith andJenkins Git plugin GitHub pluginSelenium serverCucumber for java Jenkins plugin t...
INTEGRATION TESTING FRAMEWORK... see Lydias talk
PRODUCTION
How do we move to production in a world of maven builds anddeploys and git saves?
YOU ARE HERE
MAVEN PROFILE FOR PRODUCTIONAdd this to pom.xml:Deploy using this profile:Or one-time override: mvn -Dcrx.host=another.hos...
DEPLOYMENT TESTING... see Bertrands talk
PUTTING IT ALL TOGETHER
0-60 IN 5 PSEUDO LINESmvn archetype:generategit init; git add *; git commit -m "Initial project"mvn -PautoInstallPackage i...
THANK YOU. QUESTIONS?
CREDITSdesigned by from The Noun Projectdesigned by from The Noun Projectdesigned by from The Noun Projectdesigned by from...
CQCON CQ Maven Methods
CQCON CQ Maven Methods
CQCON CQ Maven Methods
CQCON CQ Maven Methods
Upcoming SlideShare
Loading in...5
×

CQCON CQ Maven Methods

1,367
-1

Published on

This talk was presented at CQCON 2013 in Basel.

Learn how to master development workflows combining the power of CQ with Apache Maven and Git. Sometimes it can be hard to get up and running with other developers' Adobe CQ projects. Where is the code? How can you build it once you have it? How do you get it into CQ? What do you do with it once it's there? Anyone should be able to quickly and easily perform a git clone of a CQ project, followed by doing a Maven build and install, and then immediately be able to try it out and work on it within CQ. This session will show developers how they can structure their projects so that they are buildable "out of the box". We will provide hints and tips on how to structure your application in git, and explain which maven plugins to use in a range of circumstances.

See the CQCON website http://www.cqcon.eu/2013/en/speakers/andrew-savory.html or the online version of the presentation at http://www.andrewsavory.com/presentations/CQCon_2013_CQ_Maven_Methods/index.html
The source of the presentation is in github at https://github.com/savs/CQCon_2013_CQ_Maven_Methods

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,367
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
48
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

CQCON CQ Maven Methods

  1. 1. CQ MAVEN METHODSCQCON 2013
  2. 2. HELLO WORLDIm Andrew.asavory@adobe.com@savs
  3. 3. Joined Adobe in November 2012
  4. 4. CQ NewbieJCR/CMS/TLA old hat
  5. 5. Background in Open Source, Content Management, Mobile
  6. 6. Talking today about what I learned so far...
  7. 7. FORK ME!If you found this talk useful, or spotted mistakes:github.com/savs/CQCon_2013_CQ_Maven_Methods
  8. 8. IN YOUR BROWSERhttp://goo.gl/qqS1F
  9. 9. SEE ALSOhttp://www.planetcq.org/
  10. 10. LETS BUILD A CQ SITE... uh, where to begin?
  11. 11. METHOD 1Enthusiastically rush in, use CRXDE Lite
  12. 12. METHOD 2Im a guru, I use Eclipse and CRXDE
  13. 13. METHOD 3Im a ninja, I use emacs and vlt
  14. 14. METHOD 4Im a guru ninja, I use vi and curl
  15. 15. METHOD 5See also: http://xkcd.com/378/ – Real Programmers
  16. 16. BUT WHAT ABOUT ...reverting mistakes?reproducible builds?collaborating with others?deploying to production?
  17. 17. WHY ISNT IT EASIER TO BUILD A CQ SITE?Laborious project inceptionNo two projects alikeDont know project layoutDont know project dependenciesHard for others to reproduceHard to testLengthy RTFM or worse (no FM)Documentation over convention
  18. 18. CQ SUCKS
  19. 19. $PRODUCT SUCKS
  20. 20. YOUR METHODOLOGY SUCKS(sorry)
  21. 21. SO HOW DO WE FIX THIS?MavenGit(or Subversion, or CVS ... ymmv)Best Practices
  22. 22. MAVEN“Maven is a software project managementand comprehension tool. Based on theconcept of a project object model (POM),Maven can manage a projects build,reporting and documentation from a centralpiece of information.”
  23. 23. GIT“Git is a free and open source distributedversion control system designed to handleeverything from small to very large projectswith speed and efficiency. ”Version control is a system that records changes to a file or set of files overtime so that you can recall specific versions later.
  24. 24. BEST PRACTICES“A best practice is a method or technique thathas consistently shown results superior tothose achieved with other means.”In addition, a "best" practice can evolve to become better as improvementsare discovered.
  25. 25. WHAT DO WE WANT?Minimal customisationStandardised way to create a projectStandardised way to build a projectStandardised way to deploy a projectStandardised way to test a projectStandardised way to share a project
  26. 26. OUR TARGET
  27. 27. Success criteria:ITS EASY TO BUILD A CQ SITE!
  28. 28. GETTING STARTEDInstall Maven: http://maven.apache.org/guides/getting-started/Install Git: http://git-scm.com/book/en/Getting-Started-Installing-Git
  29. 29. CONFIGURING MAVENMaven has a settings file that defines things likerepositories where plugins can be downloaded (typically~/.m2/settings.xml).We need to add a profile to point to the Adobe repository.We then specify this repository when we use thearchetype plugin.See also: Obtaining the Content Package Maven Plugin
  30. 30. CONFIGURING MAVEN<profile><id>adobe-public</id><activation><activeByDefault>false</activeByDefault></activation><properties><releaseRepository-Id>adobe-public-releases</releaseRepository-Id><releaseRepository-Name>Adobe Public Releases</releaseRepository-Name><releaseRepository-URL>http://repo.adobe.com/nexus/content/groups/public</releaseRepository-URL></properties><repositories><repository><id>adobe-public-releases</id><name>Adobe Basel Public Repository</name><url>http://repo.adobe.com/nexus/content/groups/public</url><releases><enabled>true</enabled><updatePolicy>never</updatePolicy></releases><snapshots><enabled>false</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>adobe-public-releases</id><name>Adobe Basel Public Repository</name><url>http://repo.adobe.com/nexus/content/groups/public</url><releases><enabled>true</enabled><updatePolicy>never</updatePolicy></releases><snapshots><enabled>false</enabled></snapshots></pluginRepository></pluginRepositories></profile>
  31. 31. CONFIGURING MAVENEnable the repository:Or use the -P option to activate profile(s):<activeProfiles><activeProfile>adobe-public</activeProfile></activeProfiles>mvn -P adobe-public [...]
  32. 32. USING MAVEN
  33. 33. STARTING A NEW PROJECT ...... can sometimes feel like reinventing the wheel.
  34. 34. YOU ARE HERE
  35. 35. ARCHETYPESarchetype |ˈɑːkɪtʌɪp|nouna very typical example of a certain person or thing: he wasthe archetype of the old-style football club chairman.an original which has been imitated; a prototype: aninstrument which was the archetype of the early flute.
  36. 36. MAVEN ARCHETYPESA prototype upon which others arecopied, patterned, or emulated.
  37. 37. WHAT CQ ARCHETYPES ARE THERE?simple-content-packageGenerates a simplemultimodule-content-packageIncludes the folder structure for developing a CQapplication (content package and bundle).cqblueprints multi-moduleThird-party archetype encapsulating best practices forworking with e.g. OSGi bundles, taglibs, and CQ contentSee also:content packageHow to work with packages
  38. 38. ON PACKAGESPackages enable the importing and exporting of repositorycontent. They are used to install new functionality, transfercontent between instances, or back up the repositoryA package is a zip file in file system (vault) serializationformatPackages include meta information - filter definitions,import configuration, package propertiesPackages are often managed through the CQPackage Manager
  39. 39. ON BUNDLESBundles are modular containers of functionality for OSGi –essentially a java module that contains application logicBundles consist of java classes and other resources neededto deliver functionality or to provide services to otherbundles.Bundles can be managed through the CQSee also:Web ConsoleCreating OSGi bundles using CRXDE
  40. 40. HOW TO USE AN ARCHETYPEarchetypeGroupId: identifies the archetype projectuniquely across all projectsarchetypeArtifactId: the name of the archetype jarwithout a version numberarchetypeRepository: where to get the archetype from(based on pluginRepository in settings.xml)See also: andmvn archetype:generate-DarchetypeGroupId=foo-DarchetypeArtifactId=bar-DarchetypeVersion=1.0.0-DarchetypeRepository=bazMaven: Introduction to Archetypes Maven: Naming conventions
  41. 41. SIMPLE CONTENT PACKAGE ARCHETYPEFrom the fine manual:“Creates a maven project that is suitable forinstalling resources for a simple CQapplication. The folder structure is that usedbelow the /apps folder of the CQ repository.The POM defines commands for packagingthe resources that you place in the folders andinstalling the packages on the CQ server.”
  42. 42. SIMPLE CONTENT PACKAGE USAGEarchetypeGroupId: com.day.jcr.vaultidentifies the archetype project uniquely across all projectsarchetypeArtifactId: simple-content-package-archetypethe name of the archetype jar without a version numberarchetypeRepository: adobe-public-releaseswhere to get the archetype from (based onpluginRepository in settings.xml)mvn archetype:generate-DarchetypeGroupId=com.day.jcr.vault-DarchetypeArtifactId=simple-content-package-archetype-DarchetypeVersion=1.0.1-DarchetypeRepository=adobe-public-releases
  43. 43. SIMPLE CONTENT PACKAGE IN ACTION
  44. 44. SIMPLE CONTENT PACKAGE PARAMETERSgroupId: Like a package name, e.g.com.yourcompany.myprojectartifactId: name of the jar without the version, e.g.myprojectversion: accept the defaultpackage: not used in simple-content-packageappsFolderName: name of /apps/myproject, e.g. myprojectartifactName: Description in Package ManagerpackageGroup: Group in Package ManagerSee also: Maven: Naming conventions
  45. 45. SIMPLE CONTENT PACKAGE OUTPUTTemplate directoriespom.xml fileInstructions for compiling, creating bundles, deployingto CQ in packagesFileVault configuration files
  46. 46. MULTIMODULE CONTENT PACKAGE USAGEmvn archetype:generate-DarchetypeGroupId=com.day.jcr.vault-DarchetypeArtifactId=multimodule-content-package-archetype-DarchetypeVersion=1.0.1-DarchetypeRepository=adobe-public-releases
  47. 47. MULTIMODULE CONTENT PACKAGE OUTPUT${artifactId}|- pom.xml|- bundle|- pom.xml|- src|- main|- java|- ${groupId}|- SimpleDSComponent.java|- test|- java|- ${groupId}|- SimpleUnitTest.java|- content|- pom.xml|- src|- main|- content|- jcr_root|- apps|- ${appsFolderName}|- config|- install|- META-INF|- vault|- config.xml
  48. 48. |- filter.xml|- nodetypes.cnd|- properties.xml|- definition|- .content.xml
  49. 49. CQBLUEPRINTS MULTI-MODULE USAGEFirst add the CQ Blueprints Maven Repository to Mavenssettings.xml, then:archetypeGroupID: com.cqblueprints.archetypesarchetypeArtifactId: multi-modulearchetypeVersion: 1.0.5archetypeRepository: cqblueprints.plugins.releasesSee also: andmvn -P cqblueprints archetype:generate-DarchetypeGroupId=com.cqblueprints.archetypes-DarchetypeArtifactId=multi-module-DarchetypeVersion=1.0.5-DarchetypeRepository=cqblueprints.plugins.releasesConnecting to the CQ Blueprints Repository The CQ Project Maven Archetype
  50. 50. CQBLUEPRINTS MULTI-MODULE OUTPUT${artifactId}|- README|- pom.xml|- ${artifactId}-all|- pom.xml|- ${artifactId}-config|- ${artifactId}-content|- ${artifactId}-services|- ${artifactId}-taglib|- ${artifactId}-view
  51. 51. WHY USE CQBLUEPRINTS MULTI-MODULE?The cqblueprint multi-module archetype is developed by“The things we wanted to consider with ourarchetype is to address concerns of largerteams”headwire.com
  52. 52. CQBLUEPRINTS MULTIMODULE DESIGNfoo-view subproject: where css/html/js developers (frontend)do their workfoo-taglib foo-services: where java developers (backend) dotheir workfoo-config: where the configuration (runmode configs stored)foo-content: how we get initial content and site structure ontothe developers box quicklyfoo-all: how we hand off builds to the next environment
  53. 53. USING GIT
  54. 54. WHY GIT?Local safety net"The internet is my backup"Its good to shareEnlightened self-interest
  55. 55. YOU ARE HERE
  56. 56. GIT PROJECT SETUPcd projectnamegit init
  57. 57. GIT IGNOREEdit .gitignore, for example:.classpath.project.vlt/.settings/target/
  58. 58. GET IT IN GITgit add *git commit -m Initial project version
  59. 59. GET IT IN GITHUB (OPTIONAL)hub-new-repo is a shortcut for creating a repository ongithub and pushing your local repo into itSee also:See also:cd projectgit hub-new-repoCLI remote github repo creationgithub
  60. 60. DEMO
  61. 61. ... TIME PASSES ...
  62. 62. COMMIT PROJECTgit add filenamesgit commit -m "meaningful message"git push origin master
  63. 63. (BEST) PRACTICE(S)
  64. 64. YOU ARE HERE
  65. 65. “the three great virtues of a programmer:laziness, impatience, and hubris”
  66. 66. BUILDING
  67. 67. HOW CAN WE BUILD SMARTER?Create local zips and jars that you can upload:mvn packageproduces:Content package output: target/yourapp-content-1.0-SNAPSHOT.zipBundle output: target/testapp-bundle-1.0-SNAPSHOT.jar
  68. 68. DEPLOYING
  69. 69. HOW CAN WE BUILD AND DEPLOY SMARTER?Content package: mvn -PautoInstallPackageinstallBundle: mvn -PautoInstallBundle installcqblueprints: mvn -Pauto-deploy install
  70. 70. DEMO
  71. 71. DEVELOPING
  72. 72. YOU ARE HERE
  73. 73. How do we develop in a world of maven builds and deploysand git saves?
  74. 74. THE FILEVAULT TOOLYou can use the FileVault tool (vlt) to check in, check out,update and sync local content with the repository.Install: extract crx-quickstart/opt/filevault/filevault.[tgz|zip] and add to your pathUsage: vlt --credentials admin:admin co --force http://localhost:4502/crxSee also: How to use the VLT Tool
  75. 75. SAMPLE DEVELOPMENT WORKFLOWUse maven to build and deployInitialise vltCreate components, templates with CRXDE LiteUse vlt to copy back into local filesystemChange locallyUse vlt to copy back into the repositoryAdd to git
  76. 76. DEMO
  77. 77. TESTING
  78. 78. CONTINUOUS INTEGRATION?with ,as awith andJenkins Git plugin GitHub pluginSelenium serverCucumber for java Jenkins plugin tests in java
  79. 79. INTEGRATION TESTING FRAMEWORK... see Lydias talk
  80. 80. PRODUCTION
  81. 81. How do we move to production in a world of maven builds anddeploys and git saves?
  82. 82. YOU ARE HERE
  83. 83. MAVEN PROFILE FOR PRODUCTIONAdd this to pom.xml:Deploy using this profile:Or one-time override: mvn -Dcrx.host=another.host,crx.port=4504 -PautoInstallPackage installSee also:<profile><id>auto-deploy-prod</id><properties><crx.host>production.server.hostname</crx.host><crx.port>4502</crx.port></properties></profile>mvn -PautoInstallPackage,auto-deploy-prod installIntroduction to build profiles
  84. 84. DEPLOYMENT TESTING... see Bertrands talk
  85. 85. PUTTING IT ALL TOGETHER
  86. 86. 0-60 IN 5 PSEUDO LINESmvn archetype:generategit init; git add *; git commit -m "Initial project"mvn -PautoInstallPackage installvlt checkout ; vlt update ; vlt commitgit add; git commit; git push
  87. 87. THANK YOU. QUESTIONS?
  88. 88. CREDITSdesigned by from The Noun Projectdesigned by from The Noun Projectdesigned by from The Noun Projectdesigned by from The Noun Projectdesigned by from The Noun Projectdesigned by from The Noun Projectdesigned by from The Noun Projectdesigned by from The Noun Projectdesigned by from The Noun Projectdesigned by from The Noun Projectdesigned by from The Noun ProjectLight Bulb Shane David KennaQuestion Anas RamadanHard Disk Drive Eddie AlshehriTime wayne25ukSync P.J. OnoriSync Rohith M SCloud Upload Adam WhitcroftPuzzle John OSheaQuestion Henry RyderFactory Adrijan KaravdicCrash Test Dummy Luis Prado
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×