Deploying an Encrypted ColdBox Application and a gotcha

I currently run my on a shared hosting provider and felt that it was time that I actually encrypted the source files, I added some extra logic to my Ant build.xml to take care of this and as I had used it in the past I never expected any problems with this.

However I was dead wrong with that assumption.

The mistake I made was to assume that the xml files within ColdBox would be ok to be encrypted, which was an assumption that I would normally not make. But in this case it had slipped my mind, and the error message that I received was something that just didn't make me click.

So what I did was to write an Ant target that would compile the files to another directory, in which I would then just make sure that I would copy the files I didn't want compiled. The script is pretty straight forward and you should be able to see what is happening.

<target name="Compiled Source">
   <echo>Compiling Application : ${package.name} ${package.version}</echo>
   <exec executable="${server.compiler}\cfcompile.bat">
      <arg line="-deploy" />
      <arg line="${basedir}\wwwroot\" />
      <arg line="${basedir}\wwwroot\" />
    <arg line="${basedir}\deployment\compiled\wwwroot\" />
   </exec>
   <!-- We need to do this to make sure that xml.cfm files are no compiled -->
   <copy todir="${basedir}\deployment\compiled\wwwroot" includeEmptyDirs="true" overwrite="true">
      <fileset dir="${basedir}\wwwroot" includes="**/*.xml.cfm*, **/*.ini.cfm*">
      </fileset>
   </copy>
</target>

As you can see the first section of the code takes the current source and runs the ColdFusion compile to compile the files into an output directory, from here we just tell Ant to then copy the files that we wish to remain in their normal state.