There are a few methods of using Ant with Xindice;



Fortunately Xindice ships with its own Ant task called DeploymentTask. To use it in your ant build scripts you will first need to declare a TaskDef statement.

1) place the following before your target definitions

  <taskdef name="xindice" classname=""/>

2) here are some examples of using the Ant task


<xindice home="E:\java\xindice" Collection="xmldb:xindice://" 
Activity="export" Path="c:\test\"/>


<xindice home="E:\java\xindice" Collection="xmldb:xindice://" 
Activity="import" Path="c:\test\"/>

Check out the commands.xml file contained in /config directory, which lists all the available commands for this task.

Here is an example ant build.xml file which uses the useful Macrodef task to create xindice tasks.

<?xml version="1.0"?>
<project name="test xindice deployment task" default="test" basedir=".">
    Illustrate how to use xindice DeploymentTask.

<taskdef name="xindicedeploy" classname=""/>

<!-- xindice properties //-->
<property name="xindice.collection" value="xmldb:xindice://"/>
<property name="xindice.home" location="E:\java\xindice"/>      
<property name="xindice.path" location="c:\test\log"/>  
<property name="xindice.document_dir" location="c:\\doctest\\"/>        
<macrodef name="xindice-add-collection">
<attribute name="name"/>
<xindicedeploy Home="${xindice.home}" Name="@{name}" Collection="${xindice.collection}" Activity="add_collection" Path="${xindice.path}"/>

<macrodef name="xindice-remove-collection">
<attribute name="name"/>
<xindicedeploy Home="${xindice.home}" Name="@{name}" Collection="${xindice.collection}" Activity="delete_collection" Path="${xindice.path}"/>

<macrodef name="xindice-add-document">
<attribute name="name"/>
<xindicedeploy Home="${xindice.home}" Name="@{name}" Collection="${xindice.collection}" Activity="add_document" Path="${xindice.document_dir}"/>

<target name="test">

<xindice-add-collection name="test"/>

<xindice-add-document name="test.xml"/>

<xindice-remove-collection name="test"/>



Xindice Ant Task v.1alpha

Add and remove Xindice documents and collections. This version is an alpha prototype written within an hour to get an understanding of Xindice, it works... but use at your own risk !

Download from


1) add com.example.XindiceAntTask using taskdef to make it available to Ant

<taskdef classpath="${java.class.path}" name="xindice" classname="com.example.XindiceAntTask" />

There is no reason you need to keep the namespace, all classes are in com.example....possibly with a better version this Xindice Task may find itself within Xindice or Ant optional.

2) The following target is an example of the syntax used when adding and removing documents and collections

    <target name="test-xindice-ant-task" description="test XindiceAntTask">

            <taskdef classpath="${java.class.path}" name="xindice" classname="com.epinx.xindice.XindiceAntTask"/>

            <xindice action="add-collection" name="test collection" host="" port="8080" url="/xindice/db" collection="/db/pims">
            <xindice action="add-document" name="test" host="" port="8080" url="/xindice/db" collection="/db/pims">

            <xindice action="remove-document" name="test" host="" port="8080" url="/xindice/db" collection="/db/pims">
            <xindice action="remove-collection" name="test collection" host="" port="8080" url="/xindice/db" collection="/db/pims">


Feel free to take this code and make better, but please post back to either here or the Xindice list.


* create commercial quality java the moment its an alpha scratched up in an afternoon

* comment code

* add fileset capability when adding or removing documents from repository

* create meta data definition, as encapsulated within xindice element

* add retrieve-document function

* add BASIC/DIGEST authentication with username/password attributes

AntXindice (last edited 2009-09-20 23:23:41 by localhost)