Ant

Last modified by Sebastian Marsching on 2022/05/27 22:17

Classpath trouble with ant

Problem
If you have a <taskdef> in your build.xml, ant will evaluate the specified classpath when processing the <taskdef>. However, if you are using a loaderRef, ant will only evaluate the classpath at the first time a <taskdef> with the specified loaderRef is instantiated and reuse this classloader later. This can cause problems when the classpath reference changes later (e.g. because JAR files are placed in a directory that is used in the FileSet used to define the classpath reference).
Solution
Define tasks as late as possible and only use a common classloader if you have to share objects between tasks.