Maven Timestamp plugin 0.1 released
I just released my first maven plugin. It's really the simplest possible piece of code you could imagine, but yet it makes it's goal (addings a timestamp variable to your build process) a piece of cake. You can find it at http://code.google.com/p/maven-timestamp-plugin/ along with a bugtracker and some docs.
Now, why would I write something as simple as a timestamp plugin? Well, I am the first to admit that adding timestamp in your build process is not exactly rocket science. But unfortunately most of the procedures to do just that made it seem more complicated than it should be. Either you jump through hoops trying to get a filter output back into your pom.xml, or you end up using a plugin that doesn't have the ability to give you a customized date format (who the hell knows at first sight that the timestamp 1212931073482 means 8th june 2008 15:18h?!). So out of this frustration, the timestamp plugin was born. Have fun with it folks
Matching XML content with XPath – the magic is in the ‘.’
Sometimes it's the simple things that make you wonder how they are done on a high level. For example, if you are wondering how you'd match the content of a node in Xpath, you might think to yourself: "Gee I really would like to know which food-nodes in my xml document contain the word 'Donuts' - this should be easy to find out with XPath".
Well, let me save you some time here. At first you might be looking for a function that matches strings. By looking into the w3c xpath function reference you'd find a function called contains(). 'contains()' takes two parameters. And here the fun starts.
What the reference doesn't tell you (ok I'm sure it does tell you somewhere), is how to fiddle your matches into the first contains() parameter, which incidentally is the text you want to scan. If your document looks something like this:
<mydocument> <food>Bavarian Donuts</food> <food>Cheesecake</food> <food>Oranges</food> </mydocument>
Your first approach might look like this: /mydocument/food[contains(/mydocument/food,'Donuts')] Which, in a universe where everything makes perfect sense, would yield you one hit. However, this one just breaks your XPath processor, because contains() doesn't accept multiple matches as the first parameter.
Instead you can do this: /mydocument/food[contains(.,'Donuts')]
The trick is that you use the '.' which is a shortcut for the current node function to reference the currently matched node as input to your contains() function. That's all there's to it.
Spring 2.5 and the runtime paradigm shift
I just finished reading up on the new features of Spring 2.5 and I have to say I'm pretty excited. One thing that bothered me from the start of the Spring project has always been the need for xml wiring of components. No matter what you do in Spring land, you will have to create at least a minimal stub of xml in your config files to make your component known to Spring. And now, the freshly released 2.5 version of Spring is reaping the benefits of annotation driven development and completely does away with that.