<p>I want to create an Ant buildfile, that includes some files as a sort of plugin.</p>

<p>So if I want to activate a feature in a project - say pmd-checking - I copy a pmd.xml in a directory and the build.xml get on the start the idea, that pmd.xml exists and imports it, so that new targets can be available to the build.</p>

<p>But the 'import' task can only be used as a top-level task, so I have no idea how to relize this functionality. Is this possible with Ant and if so, how can I do it?</p>

<p>EDIT: I would prefer a solution, that allows new targets to show up in the listing presented by <code>ant -p</code>.</p>

You can use the
ant
task and even parameterize the target name. Here's an example:
```
```
<ant antfile="plugins/pmd.xml" target="${pmd-target}"/>
```
```
If you want more flexibility, I recommend checking
gant
or
gradle
.