Using tasks not included in Ant's default jar

To use Ant tasks not included in the Ant jar, like Ant optional or custom tasks you need to add the dependencies needed for the task to run to the plugin classpath and use the maven.plugin.classpath reference if needed.

<project>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>my-test-app</artifactId>
  <groupId>my-test-group</groupId>
  <version>1.0-SNAPSHOT</version>

  <build>
    <plugins>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-antrun-plugin</artifactId>
         <version>1.5</version>
         <executions>
           <execution>
             <id>ftp</id>
             <phase>deploy</phase>
             <configuration>
               <target>

                 <ftp action="send" server="myhost" remotedir="/home/test" userid="x" password="y" depends="yes" verbose="yes">
                   <fileset dir="${project.build.directory}">
                     <include name="*.jar" />
                   </fileset>
                 </ftp>

                 <taskdef name="myTask" classname="com.acme.MyTask" classpathref="maven.plugin.classpath"/>
                 <myTask a="b"/>

               </target>
             </configuration>
             <goals>
               <goal>run</goal>
             </goals>
           </execution>
         </executions>
         <dependencies>
           <dependency>
             <groupId>commons-net</groupId>
             <artifactId>commons-net</artifactId>
             <version>1.4.1</version>
           </dependency>
           <dependency>
             <groupId>ant</groupId>
             <artifactId>ant-commons-net</artifactId>
             <version>1.6.5</version>
           </dependency>
           <dependency>
             <groupId>ant</groupId>
             <artifactId>ant-nodeps</artifactId>
             <version>1.6.5</version>
           </dependency>
         </dependencies>
       </plugin>
    </plugins>
  </build>
</project>