Using your own build templates from second zero
Some tasks are nice to have around in each and every project, such as the JSLint task I wrote about earlier today. However, we still don’t want that in each and every project - where’s the point in having a js-lint in a project that does not use any javascript at all like a pure service oriented project without any html output? So we don’t want that task in the core agavi build file but still in our standard project.
However, using agavi project-wizard copies the standard agavi buildfile, so we have to manually copy our changes over and over again. Tedious work. We might also have a customized set of templates to use with the latest output type generation feature and we’d like to use that from the start so that all views generated in the project wizard benefit from that as well. But hmm, agavi project-wizard uses the standard templates. So let’s go change that.
A custom template set
We start off by copying the standard template set - there’s a task for it:
Zodiacal-Light:Sites fgilcher$ mkdir agavi-build-templates
Zodiacal-Light:Sites fgilcher$ cd agavi-build-templates/
Zodiacal-Light:agavi-build-templates fgilcher$ agavi system-template-copy-all
Agavi > system-template-copy-all:
Output directory [/Users/fgilcher/Sites/agavi-build-templates]:
[copy] Copying 55 files to /Users/fgilcher/Sites/agavi-build-templates
Zodiacal-Light:agavi-build-templates fgilcher$
Now we modify the build.xml.tmpl to contain our JSL-Task:
<?xml version="1.0" encoding="utf-8"?>
<project name="%%PROJECT_NAME%%" basedir="." default="status">
<!--
Define project-specific or custom build targets.
-->
<target name="lint-javascripts" description="check all javascripts for validity">
<property name="javascript.lint.showWarnings" value="true" />
<jsllint showWarnings="${javascript.lint.showWarnings}" haltOnFailure="true">
<fileset dir="${project.directory}/pub/">
<include name="**/*.js" />
</fileset>
</jsllint>
</target>
</project>
We can also change or add any other template we might like at this point. From here on it’s a matter of passing the template directory to use to the agavi script:
Zodiacal-Light:Sites fgilcher$ agavi -D templates.directory /Users/fgilcher/Sites/agavi-build-templates project-wizard
...
Zodiacal-Light:Sites fgilcher$
Done. This project will use the modified set of build templates from now on.

