The amazing adventures of Doug Hughes

About a year ago I announced and released CFAnt. CFAnt was my first crack at creating tasks for Ant to made deploying ColdFusion applications with Apache Ant very easy. I never got the impression it was widely used outside of Alagad, but we used it internally to deploy essentially all of our applications. Those of you who did use it are aware that it had some shortcomings. For example, it required that you place CFAnt directly in your application’s webroot. Also, it exposed, perhaps, hundreds of poorly documented tasks for managing ColdFusion configuration. So, while CFAnt worked well for Alagad, I wanted to find a better and easier way to deploy ColdFusion applications using Ant. This spawned the genesis of Ant4CF, which is officially the second release of CFAnt, but with a new name. Ant4CF fixes a number of confusing issues with CFAnt and makes it really, really simply to remotely execute build files and to interact with services exposed through Ant4CF. These services include a collection of components which proxy the Admin API features. Ant4CF is made up of three Ant tasks packaged into a JAR file and a collection of CFML files which you can place anywhere on your server. The most common location for these files is under the CFIDE directory. With those two things in place you can easily create a build script that kicks off another build script remotely on your server. For example, this is a basic build.xml file:

<project name="Local Build Script" default="Build">
     <target name="Build">
         <input message="Please enter CFAdmin password:" addproperty="cfAdminPassword" />
         <taskdef name="configure" classname="com.alagad.ant4cf.Configure" classpath="antlib/ant4cf-java-2.0-SNAPSHOT-jar-with-dependencies.jar" />
         <taskdef name="remoteant" classname="com.alagad.ant4cf.RemoteAnt" classpath="antlib/ant4cf-java-2.0-SNAPSHOT-jar-with-dependencies.jar" />
         <configure ant4cfUrl="http://yourapp.com/CFIDE/ant4cf" adminPassword="${cfAdminPassword}" />
         <remoteant antfile="remoteBuild.xml" properties="cfAdminPassword,dsnPassword,svnUsername,svnPassword" timeout="120" />
     </target>
</project>

This build file essentially gathers the ColdFusion admin password, defines two of the Ant4CF tasks, configures Ant4CF and then remotely runs a build script named remoteBuild.xml.

To expand on that a bit Ant4CF provides three tasks, two of which are shown above: configure and remoteant.

The configure task tells Ant4CF where to find the Ant4CF files on your server and the password used to access the ColdFusion administrator.

The remoteant task is the more interesting of these two as it specifies a specific ant file to upload to the remote server and run. You can specify a set of properties to pass into that file as well. The remoteant task can also keep track of other third party Ant tasks you’re using and will upload those JARs to the server.

This means that you can essentially write an Ant script that does whatever you want and use the remoteant task to run it on your server without change.

Ant4CF also provides a service task that looks like this:

<service component="adminapi.801.datasourceProxy" method="setMSSQL" property="result">
    <argument name="name" value="yourapp" />
    <argument name="host" value="10.248.79.47" />
    <argument name="database" value="yourdatabase" />
    <argument name="username" value="dbusername" />
    <argument name="password" value="${dsnPassword}" />
    <argument name="selectmethod" value="direct" />
</service>

The service task is remnient of the cfinvoke tag in ColdFusion. In the case of the service tag you specify a component and a method and pass arguments into it via the argument tag. Any results are returned into the property specified.

By default, Ant4CF comes with a proxy for the ColdFusion Administrator API. This means that you have all of the capabilities of the Admin API built into Ant4CF. The service example above creates or edits a new MSSQL datasource for you.

In my applications a typical build script will export the application from Subversion, change the ColdSpring configuration, export Model-Glue from SNV and ColdSpring from CVS. I then create my datasource, enable and clear the trusted cache and reload the application.

Want to know how I do this? I type “ant” in the command line. The rest is handled for my automatically!

If you’re interested in Ant4CF you can download it here: http://alagad.com/go/products-and-projects/ant4cf/ant4cf

Ant4CF is free, open source, and, believe it or not, documented!

Comments on: "Ant4CF Released Run Build Files Remotely and Interact with ColdFusion Services From Ant Scripts" (5)

  1. John Whish said:

    @Doug – this looks awesome! Any chance of converting the documentation in the download from a Word docx to a PDF or RTF? Thanks 🙂

    Like

  2. Doug Hughes said:

    @John – Thanks for the suggestion. I just uploaded a new zip with PDF documentation.

    Like

  3. John Whish said:

    @Doug – thanks! Off to download now… 🙂

    Like

  4. Apoorv Pal said:

    Doug Hughses…

    I am new to ANT4CF and Build Servers.
    I just wanted to know.
    Does ANT4CF checks syntax errors in Cold Fusion Code during building??
    As i tried it and it was not checking it…

    Please let me know

    Like

Comments are closed.

Tag Cloud

%d bloggers like this: