Ant sucks for FTP deployment - What alternatives do we have?

Posted by Felix Geisendörfer, on Oct 10, 2006 - in Coding Techniques & Tools » Tools

Deprecated post

The authors of this post have marked it as deprecated. This means the information displayed is most likely outdated, inaccurate, boring or a combination of all three.

Policy: We never delete deprecated posts, but they are not listed in our categories or show up in the search anymore.

Comments: You can continue to leave comments on this post, but please consult Google or our search first if you want to get an answer ; ).

Update: Bruno D. has spent quite some time researching alternatives to ANT deployment and posted his results in the comments. So if you don't like my SVN deployment task for Cake 1.2, you might find his suggestions useful.

I wish I could say deploying my applications is just a matter of typing "ant deploy" into the command line these days, but the truth is - it isn't. Don't get me wrong, I like Ant a lot and I use it for some of my SVN tasks like exporting the current trunk and zipping it up for emailing it to a client and things like this, but trying to make it deploy my CakePHP app's on shared hosts via FTP turns out to be a nightmare. Here is why:

  • Ant's FTP task is not capable of copying empty folders, making it really messy to copy an applications entire structure (especially tmp folders)
  • Ant's FTP task cannot chmod folders
  • Ant's FTP task cannot recursivly delete files if .htaccess files are hidden and can only be seen via LIST -a

Now you could work around those issues using various manual sub tasks. In fact I even got myself the source of the java commons-net package which is needed for FTP, and hacked it so ANT would automatically use "LIST -a" to work around problem #3. However, looking back, I've probably already spent more then 10 hours trying to create a smooth deploying mechanism with ANT with very little results so far - getting to the point where my automation efforts defeat their purpose.

So right now I'm half way done with an AutoHotkey script that can be called by Ant that will use my FTP client (FileZilla) to perform the required tasks (in the background). But I'm a little unhappy about the fact that this will remain a Win only solution. For that reason I would like to replace the FileZilla/Autohotkey combination with a command line utility available for Windows, Linux and Mac OS X, but to my dissapointment I could not find one fitting my needs. Such a utility would need to be able to recursivly upload, delete and chmod files + folders. If any of you knows about such a tool, please let me know!

Ok, what are the other alternatives? I know some people like Phing, but it doesn't come with a FTP task and uses php5 (I'm on php4). Anyway, "Evan Wired" mentioned that he uses (scroll down to the comments) a custom FTP task with phing, so Evan if you are still reading this blog and would like to share your task - I would love to give it a try at this point.

Another idea floating in my head is to write a CakePHP specific deployment tool that could be coupled with SVN. One that would check what files have been modified in the trunk since the last update and only overwrite those, and maybe take care of DB migration as well. This could maybe be integrated into bake.php. Cake 1.2 has a new folder inside /cake/script called tasks, so it could be a good place to hook in. But this would not be one of those little 5 minute hacks, so I'm not quite convinced it would be worth it.

So, this and the last post were more in the "ask my readers"-"whine about life" category then I would have liked them to be, but I'll make it up with some useful CakePHP posts this week, I promise. However, no cake bet will be involved this time ; ).

--Felix Geisendörfer aka the_undefined

PS: I know Daniel (cake baker) has a strong Java background, maybe we should make him enhance the ANT ftp task ; ).