I'm Andrew.
Joined Adobe in November 2012
CQ Newbie
JCR/CMS/TLA old hat
Background in Open Source, Content Management, Mobile
Talking today about what I learned so far...
If you found this talk useful, or spotted mistakes:
github.com/savs/CQCon_2013_CQ_Maven_Methods
... uh, where to begin?
Enthusiastically rush in, use CRXDE Lite
I'm a guru, I use Eclipse and CRXDE
I'm a ninja, I use emacs and vlt
I'm a guru ninja, I use vi and curl
See also: http://xkcd.com/378/ – Real Programmers
reverting mistakes?
reproducible builds?
collaborating with others?
deploying to production?
Laborious project inception
No two projects alike
Don't know project layout
Don't know project dependencies
Hard for others to reproduce
Hard to test
Lengthy RTFM or worse (no FM)
Documentation over convention
(sorry)
Maven
Git
(or Subversion, or CVS ... ymmv)
Best Practices
“Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.”
“Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. ”
Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later.
“A best practice is a method or technique that has consistently shown results superior to those achieved with other means.”
In addition, a "best" practice can evolve to become better as improvements are discovered.
Minimal customisation
Standardised way to create a project
Standardised way to build a project
Standardised way to deploy a project
Standardised way to test a project
Standardised way to share a project
Success criteria:
Install Maven: http://maven.apache.org/guides/getting-started/
Install Git: http://git-scm.com/book/en/Getting-Started-Installing-Git
~/.m2/settings.xml
).<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>
Enable the repository:
<activeProfiles> <activeProfile>adobe-public</activeProfile> </activeProfiles>
Or use the -P
option to activate profile(s):
mvn -P adobe-public [...]
... can sometimes feel like reinventing the wheel.
archetype |ˈɑːkɪtʌɪp|
noun
A prototype upon which others are
copied, patterned, or emulated.
See also: How to work with packages
See also: Creating OSGi bundles using CRXDE
mvn archetype:generate
-DarchetypeGroupId=foo
-DarchetypeArtifactId=bar
-DarchetypeVersion=1.0.0
-DarchetypeRepository=baz
See also: Maven: Introduction to Archetypes and Maven: Naming conventions
From the fine manual:
“Creates a maven project that is suitable for installing resources for a simple CQ application. The folder structure is that used below the /apps folder of the CQ repository. The POM defines commands for packaging the resources that you place in the folders and installing the packages on the CQ server.”
mvn archetype:generate
-DarchetypeGroupId=com.day.jcr.vault
-DarchetypeArtifactId=simple-content-package-archetype
-DarchetypeVersion=1.0.1
-DarchetypeRepository=adobe-public-releases
See also: Maven: Naming conventions
pom.xml
filemvn archetype:generate
-DarchetypeGroupId=com.day.jcr.vault
-DarchetypeArtifactId=multimodule-content-package-archetype
-DarchetypeVersion=1.0.1
-DarchetypeRepository=adobe-public-releases
${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 |- filter.xml |- nodetypes.cnd |- properties.xml |- definition |- .content.xml
settings.xml
, then:mvn -P cqblueprints archetype:generate -DarchetypeGroupId=com.cqblueprints.archetypes -DarchetypeArtifactId=multi-module -DarchetypeVersion=1.0.5 -DarchetypeRepository=cqblueprints.plugins.releases
See also: Connecting to the CQ Blueprints Repository and The CQ Project Maven Archetype
${artifactId} |- README |- pom.xml |- ${artifactId}-all |- pom.xml |- ${artifactId}-config |- ${artifactId}-content |- ${artifactId}-services |- ${artifactId}-taglib |- ${artifactId}-view
“The things we wanted to consider with our archetype is to address concerns of larger teams”
The cqblueprint multi-module archetype is developed by headwire.com
cd projectname git init
Edit .gitignore
, for example:
.classpath .project .vlt/ .settings/ target/
git add * git commit -m 'Initial project version'
cd project git hub-new-repo
hub-new-repo
is a shortcut for creating a repository on github and pushing your local repo into it
See also: CLI remote github repo creation
See also: github
git add filenames
git commit -m "meaningful message"
git push origin master
“the three great virtues of a programmer: laziness, impatience, and hubris”
Create local zips and jars that you can upload:
mvn package
produces:
target/yourapp-content-1.0-SNAPSHOT.zip
target/testapp-bundle-1.0-SNAPSHOT.jar
mvn -PautoInstallPackage install
mvn -PautoInstallBundle install
cqblueprints: mvn -Pauto-deploy install
How do we develop in a world of maven builds and deploys and git saves?
You can use the FileVault tool (vlt
) to check in, check out, update and sync local content with the repository.
crx-quickstart/opt/filevault/filevault.[tgz|zip]
and add to your pathvlt --credentials admin:admin co --force http://localhost:4502/crx
See also: How to use the VLT Tool
vlt
vlt
to copy back into local filesystemvlt
to copy back into the repository... see Lydia's talk
How do we move to production in a world of maven builds and deploys and git saves?
<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 install
mvn -Dcrx.host=another.host,crx.port=4504 -PautoInstallPackage install
See also: Introduction to build profiles
... see Bertrand's talk
mvn archetype:generate
git init; git add *; git commit -m "Initial project"
mvn -PautoInstallPackage install
vlt checkout ; vlt update ; vlt commit
git add; git commit; git push