Blogging via Ant with the Blogger API
I've often thought that it would be nice to be able to blog from Ant and, while discussing some stuff over at JavaRanch, Gregg has given me an opportunity to put some simple code together. Being able to blog from Ant opens up a few opportunities if you think about using a blog as a project diary.
- Publishing Ant build/test reports
- Publishing release information such as change logs
So, after a bit of hacking I came up with a simple Ant task that posts a blog entry via the Blogger API. I'm going to include it in the next Pebble release but if you want to give it a go now, you'll need pebble-ant.jar and xmlrpc-1.1.jar (you'll need to right click and "Save as..." because the MIME type isn't set correctly). Just drop these both onto your classpath before starting Ant and then use the following in your build.xml file, changing the attributes as necessary.
<taskdef name="postToBlog" classname="pebble.ant.BloggerAPITask"/>
<!-- content must use escaped HTML/XML tags -->
<property name="content" value="<p>Hello from Ant!</p>"/>
<!-- example of how to post to a blog -->
<target name="example">
<postToBlog
url="http://localhost:8080/blog/xmlrpc"
handler="blogger"
blogid="test"
username="simon"
password="password"
title="Hello"
content="${content}" />
</target>
There's also a category attribute but you'll need to be posting to Pebble 1.4.2 to be able to use this because I've extended the Blogger API to allow entries to be categorised. If your blogging system supports the Blogger API and expects blog entry titles to be wrapped up within <title> tags at the start of the blog entry text then it should work.
Re: Blogging via Ant with the Blogger API
Re: Blogging via Ant with the Blogger API
If you want extra synergy, I remember seeing one project where the delivered documentation was compiled by doing an HTTP trawl of a local Wiki. Add these two ideas together and you get painless editing of release notes, change lists and other documentation, and one-button publishing. Sweet.
Now, has anyone got any ant tasks for driving the byzantine file release process at sourceforge ?
Re: Blogging via Ant with the Blogger API
If if post with a <category>Java</category> in the content, it adds it to the post. The log looks like...
[pebble.webservice.BloggerAPIHandler] BloggerAPI.newPost(77783D0E1EE8808BD4D3327D1EB2601C78DB3D65, blog, phil, ********, <title>Test</title><category>Java</category>Test Content, true)
Re: Blogging via Ant with the Blogger API
It's an additional XML-RPC method call as follows because the BloggerAPI doesn't support it...
Name : addCategory
OK, one of us got confused ;-). I was trying to post an entry to a specific category via the API, not add a category. This is not supported I guess? Phil
Simon is a hands-on software architect and a senior consultant at 

