We have a special routine to explode files in a subfolder into extensions, which will be copied and jared into single extension files. For this special approach I wanted to
I too wasted several hours on this one, because antcontrib for
task could not be found.
Finally, I found out that for
task in not defined in antcontrib.properties
, but in antlib.xml
!
antcontrib.properties
is a pre ant 1.6 way of doing things – the modern way is to use antlib.xml
.
So, this is a maven 3.5, ant 1.8, working example:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<execution>
<id>deploy_to_distrib_folder</id>
<phase>package</phase>
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<macrodef name="deploy_extra_dir">
<attribute name="dir" />
<sequential>
<basename property="basename" file="@{dir}" />
<sync todir="${outputDir}/${basename}">
<fileset dir="@{dir}" />
</sync>
<var name="basename" unset="true" />
</sequential>
</macrodef>
<for param="dir">
<path>
<dirset dir="${project.build.directory}/maven-shared-archive-resources" includes="*" />
</path>
<sequential>
<deploy_extra_dir dir="@{dir}" />
</sequential>
</for>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</plugin>
Hope this helps!
Therefore I wasted at least one hour to find the error a little hint below ...
I use maven3 and the rest as described above, BUT I have to use maven.dependency.classpath
instead of maven.plugin.classpath
! Otherwise maven won't find the contrib tasks. Hope this helps anybody.
It looks like you're missing the taskdef that's needed to declare the ant-contrib tasks, so that Ant knows about them, hence this part of the error message:
Problem: failed to create task or type for
(It would perhaps be a little clearer if the failed task - 'for'
- were quoted.)
One way to add the taskdef is to insert it immediately prior to the for
loop:
<target>
<taskdef resource="net/sf/antcontrib/antlib.xml"
classpathref="maven.plugin.classpath" />
<for param="extension">
...
After wasting 2 hours and reading too many answers, this is what I need to check
http://www.thinkplexx.com/learn/howto/maven2/plugins/could-not-load-definitions-from-resource-antlib-xml-understanding-the-problem-and-fix-worklow
I printed all the maven classpaths using this
<property name="compile_classpath" refid="maven.compile.classpath"/>
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
<property name="test_classpath" refid="maven.test.classpath"/>
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
<echo message="compile classpath: ${compile_classpath}"/>
<echo message="runtime classpath: ${runtime_classpath}"/>
<echo message="test classpath: ${test_classpath}"/>
<echo message="plugin classpath: ${plugin_classpath}"/>
and checked which classpath contains antrib jar file. So I changed classpathhref
to maven.runtime.classpath
from maven.plugin.classpath
. So my taskdef
is
<taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.runtime.classpath" />
and the dependencies
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>