Montag, 16. August 2010

Joomla template development using Ant

My personal 3 Problems developing Joomla templates

First it is necessary to maintain a file called templateDetails.xml. In this file you have to define all the files used by the template. Adding a picture means adding this picture to the list of files. If you forget to do so, the file is not installed which results in template bugs.
Second building the template package means creating a zip file. This is like creating a jar file - who would want to do it using a file manager and a zip tool?
Last but not least it is not possible to reinstall a template. Once installed, you have to uninstall it prior to installing the new version of the template. Who would like to do this every time a css file changed? So most people are using a ftp client like FileZilla which supports "online file edit" or directory synchronization. In my case this means opening files with FileZilla, not with eclipse. DO NOT forget to sync them back!

Ant to the rescue

I spent some time and created a custom ant task and a build script using the ftp sync feature built into ant. The custom ant task is responsible for maintaining the file list of the templateDetails.xml. It scans the template directory recursively and replaces the files section with the results. You can download it here. You can find the source code included in the jar file. I don't want to include those ugly lines doing their dirty job in this article.
The ant build script is quite simple:

<?xml version="1.0" encoding="UTF-8"?>
<project name="MyKewlTemplate" default="myKewlTemplate">
 <target name="refreshFileList">
  <taskdef name="TemplateDetailsGenerator" classname="de.rhauswald.ant.joomla.TemplateDetailsGenerator" classpath="ant/TemplateDetailsGenerator.jar" />
  <TemplateDetailsGenerator templatedirectory="myKewlTemplate" />

 <target name="clean">
  <delete file="build/" />

 <target name="myKewlTemplate" depends="clean">
  <antcall target="refreshFileList" />
  <zip destfile="build/" basedir="myKewlTemplate" />

 <!-- include apache commons-net into  ant lib directory-->
 <target name="sync">
  <antcall target="refreshFileList" />
  <ftp password="XXX" server="XXX" userid="XXX" passive="true" newer="true" remotedir="templates/myKewlTemplate" verbose="true" binary="true">
   <fileset dir="myKewlTemplate">
Now my three problems are solved: The file list is auto generated before every build(ftp sync or zip). I can build the installation zip file with just one click. The ftp sync works like a charm. Change something, click the build button and ant uploads the changes only. In case I add a background picture and the proper lines to the css file a click at the build button does the following:
  1. Add the new picture to the file list
  2. Upload the templateDetails.xml file
  3. Upload the picture
  4. Upload the css file
I can concentrate on writing div boxes and css now...

Samstag, 14. August 2010

Speeding up maven dependency report

Executing the maven site goal with the default configuration can take a long time. In my case . Most of the time is consumed by the "Dependencies" report. This is the build summary with the default configuration:
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 44 seconds
[INFO] Finished at: Fri Aug 13 09:31:14 CEST 2010
[INFO] Final Memory: 69M/429M
[INFO] ------------------------------------------------------------------------
The docs of the dependency report module offered two options enabled by default. Disabling both of them is done in the reporting section of the project pom this way:
This speeds up the site generation extremely:
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 22 seconds
[INFO] Finished at: Fri Aug 13 09:33:44 CEST 2010
[INFO] Final Memory: 65M/395M
[INFO] ------------------------------------------------------------------------

Freitag, 13. August 2010

Windows Command / CMD Alternative

I found an awesome tool today named "console". It can be used as an alternative command line window for windows. Everyone who has broken his fingers a hundred times using the cmd tool shipped with windows should give this piece of software a try!

The website states: Console is a Windows console window enhancement. Console features include: multiple tabs, text editor-like text selection, different background types, alpha and color-key transparency, configurable font, different window styles

  © Blogger template 'Morning Drink' by 2008

Back to TOP