CFCompile Ant snippet

June 19, 2008 by Mike Henke    No Comments
Posted under: Ant · ColdFusion

I have been working on a build.xml file for work that updates the local working copy, runs MXunit tests, create JUnit reports based on MXunit results, minifies js/css, grabs only modified files between revisions, crunches ColdFusion files, checks compile errors, and also will check for unscoped vars in cfcs using varScoper.

Here is a snippet for the checking ColdFusion compiling using cfcompile. I'll release the full build.xml, lib, and buildprops when I have the unscoped var target working.

<!—
compileCheck
Compiles the ColdFusion files for any syntax errors
—>
<target name="compileCheck">
<echo>Check Coldfusion Compile for ${webroot}${temp.dir}${jarfileTstamp}</echo>

<exec failonerror="true" dir="${cfcompile_path}" executable="cmd.exe" output="${webroot}${temp.dir}${jarfileTstamp}compile${jarfileTstamp}.txt" >
<env key="JAVA_HOME" value="${JAVA_HOME}"/>
<arg line="/c cfcompile.bat ${webroot}${temp.dir}${jarfileTstamp}" />
</exec>
<!— need to check log for failures —>
<loadfile srcfile="${webroot}${temp.dir}${jarfileTstamp}compile${jarfileTstamp}.txt" property="src.file.cferrors">
<filterchain>
<LineContainsRegExp>
<regexp pattern="Error*"/>
</LineContainsRegExp>
</filterchain>
</loadfile>
<echo>${src.file.cferrors}</echo>
<fail>
<condition>
<isset property="src.file.cferrors"/>
</condition>
</fail>
</target>

Related Posts:

Use eclipse, ant and cfcompile.bat to precompile your code

Snarling radioactive ants!