In an effort to better understand the development lifecycle using the Maven Alfresco SDK, I decided to set up a project for an add-on idea I’ve got and looked to the all-in-one archetype.
The all-in-one archetype generates a project with a buffet of extension projects for a repository AMP, a Share JAR, an Alfresco overlay, a Solr configuration, and a Web Quick Start deployment. I don’t need all of these but none of the other archetypes offer what I consider the minimum projects: the repo AMP and the Share JAR. By using the all-in-one, I can pare it down to what I need and configure the resulting project for my system (Mac OS X Mountain Lion). I fully expect that this type of archetype will become available in the future, but in the meantime, here are the steps I’m taking to fit the project to my needs.
- Generate the all-in-one project.
$ mvn archetype:generate \ -DarchetypeGroupId=org.alfresco.maven.archetype \ -DarchetypeArtifactId=alfresco-allinone-archetype \ -DarchetypeVersion=1.0 -DgroupId=com.yourcompany \ -DartifactId=yourArtifactId
- Delete the “solr” and “wcmqs” projects.
$ rm -rf yourArtifactId/solr $ rm -rf yourArtifactId/wcmqs
- Comment out the “solr” and “wcmqs” modules from the parent POM.xml.
... <modules> <module>amp</module> <module>alfresco</module> <!-- <module>solr</module> --> <module>share</module> <!-- <module>wcmqs</module> --> <module>runner</module> </modules> ...
- Update the file “yourArtifactId/runner/pom.xml” and comment out unnecessary items:
... <profile> <id>run</id> ... <properties> <!-- <alfresco.solr.dir>${project.basedir}/../solr/solr_home</alfresco.solr.dir> --> <runner.host>127.0.0.1</runner.host> <runner.port>8080</runner.port> </properties> <build> <plugins> <plugin> ... <configuration> ... <contextHandlers> <contextHandler implementation="org.mortbay.jetty.webapp.WebAppContext"> <war>${project.basedir}/../alfresco/target/alfresco.war</war> <contextPath>/alfresco</contextPath> </contextHandler> <!-- <contextHandler implementation="org.mortbay.jetty.webapp.WebAppContext"> <war>${alfresco.solr.dir}/apache-solr-1.4.1-overlay.war</war> <contextPath>/solr</contextPath> </contextHandler> --> <contextHandler implementation="org.mortbay.jetty.webapp.WebAppContext"> <war>${project.basedir}/../share/target/share.war</war> <contextPath>/share</contextPath> </contextHandler> <!-- <contextHandler implementation="org.mortbay.jetty.webapp.WebAppContext"> <war>${project.basedir}/../wcmqs/target/wcmqs.war</war> <contextPath>/wcmqs</contextPath> </contextHandler> --> </contextHandlers> <!-- <systemProperties> <systemProperty> <name>solr.solr.home</name> <value>${alfresco.solr.dir}</value> </systemProperty> </systemProperties> --> </configuration> </plugin> </plugins> </build> </profile>
- Update the file “yourArtifactId/alfresco/src/main/properties/local/alfresco-global.properties” and set the following properties to use Lucene and turn off CIFS:
index.subsystem.name=lucene cifs.enabled=false
Optionally, I also add the following for my Mac environment to enable the JOD Converter and configure ImageMagick:
ooo.exe=/Applications/OpenOffice.org.app/Contents/MacOS/soffice ooo.enabled=false jodconverter.officeHome=/Applications/OpenOffice.org.app/Contents jodconverter.portNumbers=8100 jodconverter.enabled=true img.root=/usr/local img.exe=${img.root}/bin/convert swf.exe=${img.root}/bin/pdf2swf
- Finally, another optional change I make is to configure ImageMagick to ignore a system property that causes intermittent errors on Mac OS, submitted by Will Abson. Copy the file “/alfresco/subsystems/thirdparty/default/imagemagick-transform-context.xml” to “yourArtifactId/alfresco/src/main/resources/alfresco/extension/subsystems/thirdparty/default/default/imagemagick-transform-context.xml” (Yes, there is a double “default” directory in there) and comment out the following lines:
<bean id="transformer.worker.ImageMagick" class="org.alfresco.repo.content.transform.magick.ImageMagickContentTransformerWorker"> ... <property name="executer"> <bean name="transformer.ImageMagick.Command" class="org.alfresco.util.exec.RuntimeExec"> ... <property name="processProperties"> <map> ... <!-- <entry key="DYLD_LIBRARY_PATH"> <value>${img.dyn}</value> </entry> -->
- Test the project by running Jetty:
mvn integration-test -Prun
In general, this tends to take about 6-7 minutes to process and start up. At this point, you should see no Jetty should start cleanly with no exceptions.
I’m looking forward to streamlining my development process with Maven and will be documenting what I learn here. If you have any thoughts as to how I can improve this or suggestions as to other archetypes to use, please let me know in the comments.