Update 2011-09-16: a better solution now is the Missing Link http task, which provides a one-stop full-featured http implementation for Ant.
Erik Hatcher, Steve Loughran and Thorsten Scherler on the solr-usr user list helped me to a method for posting batches of files into Solr from Ant. To start with, you need the ant-contrib package and the Jakarta commons-codec package; put them on Ant’s classpath, most conveniently in Ant’s lib directory.
Then, in your build.xml, declare the ant-contrib tasks:
Now you’re ready to post some files. We use the
foreach task to
iterate through a bunch of files, and the
postMethod task to send them
ant update to send all the files up to Solr (or to another
REST-oriented service). The
update task passes each file to the
dopost task in the
Why not set up targets to commit and optimize as well:
This will come in very handy in my Ant-based approach to large xslt projects.