Viewing By Category : ANT / Main

Need to Refactor Transfer to meet your server layout? Here you go!


As you all now, the best and easiest way to install Transfer is just by droping it in your web root and boom, you are ready to roll. However, sometimes you need the flexibility to change the path and things just work. Well, I just created this ANT task to do that. It will ask you for a new base path and a new relative path, then it will refactor the entire Transfer codebase to meet your directory layout. This similar Task is included with ColdBox in the install directory, so you can refactor the ColdBox codebase to your layout.

Example

I have my frameworks under a directory called: 'frameworks' and I usually create a version to them, say: frameworks.coldbox2_00 or frameworks.transfer0_63

Everybody has their own naming conventions and ideas. Anyways, here is the ANT Task.

<?xml version="1.0"?>
<!-- ======================================================================
Mar 19, 2007 12:23:55 PM

transfer.refactoring
This ant task will rebuild Transfer using a prefix of choice:
shared.frameworks.transfer0_63

This is useful, if you are not placing the Transfer library
in your web root.

Example: shared.frameworks.transfer0_63

by Luis Majano
====================================================================== -->

<project name="transfer.refactoring" default="do.refactor" basedir=".">
<description>
This ant task will rebuild colspring using a prefix of choice
</description>
   
   <target name="do.prefix" description="Choose the new transfer prefix">
   <input message="What prefix would you like to use? (ex:frameworks.transfer0_63)" addproperty="transfer.newprefix" />
   <input message="What is the relative path now? (ex:/frameworks/transfer0_63)" addproperty="transfer.relativepath" />
      <echo>The prefix choosen is: ${transfer.newprefix}</echo>
</target>
   
   <target name="do.refactor" depends="do.prefix" description="refactor the code">
      <echo>Refactoring: ${basedir}</echo>
      <replace dir="${basedir}" value="${transfer.newprefix}.com" summary="yes">
          <include name="**/*.cfc" />
         <replacetoken>transfer.com</replacetoken>
      </replace>
      <replace dir="${basedir}" value="${transfer.relativepath}/resources" summary="yes">
          <include name="**/*.cfc" />
         <replacetoken>/transfer/resources</replacetoken>
      </replace>
   </target>

</project>

You just need to place this as build.xml or refactor.xml in the root of your Transfer directory, where the TransferFactory.cfc is. Then just run it, it will ask you for the first path, type "frameworks.transfer0_63" then the relative path, type "/frameworks/transfer0_63" and then you are ready to roll.

Just make sure when you instantiate the factory it will now be: "frameworks.transfer0_63.TransferFactory"

There you go. Make sure you make a backup, just in case, or if you are a real geek, then keep it, so you can run it multiple times.

Have fun!!

 Related Blog Entries

 

 Comments

Ant rocks! Great example on how to use replacetoken.

I'll add a link on my Ant wiki.

Thanks Jim,

I actually learned a lot from your wiki!! Thanks!!

Glad someone's reading it :)

You dont waste time!

Take a look at objectBreeze too. It's a very easy ORM to implement in any CF application.
I think it's possible to make it available for Coldbox, for example as pluging.

Kind regards

Joeri

http://www.objectbreeze.com/

I have Joeri,

Actually, that is the first ORM I looked at and really liked it too. I think so too. This would be great to great one single ORM plugin that can have adaptors built in for all the ORM's

I actually learned a lot from your wiki!! Thanks!!

http://www.bosvaktim.com




 


ColdBox 2.6.3 : RENEWED