I use Maven to manage my Java build process. Maven, like Ant, uses XML to store information about your project and how to build it.

Yesterday, a thought occurred to me – What if I wanted to write a script that would do post-packaging of the Maven-built artifact(s)?

For example, what if I wanted to take the Maven-built artifact and distribute it via an OS X disk image? Or even something as simple as packaging the source into a tar.gz?

A simple shell script would be easy enough to cook up – but without repeating myself, how could I do it such that the subsequent packages are named according to the same version declared in the Maven pom.xml file?

This got me to thinking about how to query XML, possibly using XPath from a shell script or the command line. I thought I might have to roll out my own XML-XPath command line processor, but fortunately somebody else beat me to it (thanks, God for all the wonderful people on teh internets) with XMLStarlet.

Read the rest of this entry »

I work with a distributed team of Ruby (on Rails) developers, and we use Subversion as our repository of choice. Just recently, I wanted to find out which files were recently changed or added to a particular directory of our project.

Doing it manually would’ve been tedious. I also wanted to do it with code so that maybe sometime in the future we might be able to script some behavior depending on the last changed date of a file or group of files in our repository.

I could’ve resorted to merely calling svn info and parsing its output, but I thought maybe this was a good excuse to sharpen my Ruby chops and figure out the Subversion Ruby bindings.
Read the rest of this entry »

Building db44 using MacPorts

September 18, 2007

MacPorts provides an extremely convenient way to install/uninstall various open-source software packages that have been ported to the Mac. It’s sort of like apt-get for Debian or yum for RH/CentOS/Fedora. For a developer like me who uses (and likes to use) open-source software on the Mac, MacPorts is a godsend.

If you were brought to this article, chances are you’ve encountered the same problem as I have when trying to install certain packages that depend on db44 (Version 4.4 of the Berkeley Data Base library). (Chances are, you’re also running on an Intel Mac like me – as I haven’t seen any complaints from people on PPC Macs)
Read the rest of this entry »

If you’re developing with Rails using PostgreSQL as your database back-end, you might find yourself in the same situation I was just in.

Rails, by convention, makes us think in terms of application ‘environments’: development, test and production (where I work we add “staging”). Each environment is given it’s own database (each environment can even have entirely different database servers).

During development, there’ll be times where you start populating a table with meaningful data as you develop and test. For example, you might have created a users table and added a couple of logins.

In some cases, data that’s meaningful in development can also be meaningful during staging or production. So, like me, one day you might find yourself wanting to copy some rows or an entire table from one database to another.

If I were using MySQL, I could easily do this via the SQL console. But PostgreSQL doesn’t support cross-database references (offering schemas, instead).

Fortunately, Rails comes with a nifty console which can do the job for us!
Read the rest of this entry »