I need to write a goal to invoke the main() method of a class in my Maven project. Following suggestions in a recent thread on this list, I am attempting this with the <ant:java/> tag. The problem I am having is with the classpath, which needs to include the project's dependencies. First I tried to use ${maven.dependency.classpath}, like so: <goal name="perfmon:run"> <echo>maven.dependency.classpath=${maven.dependency.classpath}</echo> <ant:java jar="${basedir}/target/perfmon-0.1.jar" fork="true"> <ant:classpath> <ant:path path="${maven.dependency.classpath}"/> </ant:classpath> </ant:java> </goal>
...which fails because apparently maven.dependency.classpath is not set (according to the <echo/> tag). My second attempt was to hardcode the necessary dependencies, but this fails for a different reason: <goal name="perfmon:run"> <ant:java jar="${basedir}/target/perfmon-0.1.jar" fork="true"> <ant:classpath> <ant:pathelement location="${maven.repo.local}\springframework\jars\spring-1.0.jar"/> </ant:classpath> </ant:java> </goal> >From 'maven -X perfmon:run', this appears to construct the correct arguments: [java] [DEBUG] Execute:Java13CommandLauncher: Executing 'java.exe' with arguments: '-classpath' 'C:\Documents and Settings\dcparsons\.maven\repository\springframework\jars\spring-1.0.jar ' '-jar' 'C:\p4\dev\ims\test\perfmon\target\perfmon-0.1.jar' However, I still see [java] java.lang.NoClassDefFoundError: org/springframework/beans/factory/xml/XmlBeanFactory Any ideas? I'm running Maven 1.0RC2, under Windows. Is it having trouble with the spaces in my maven.repo.local ("C:\Documents and Settings\dcparsons\.maven\repository")? I've tried many variations on constructing the path, like refids and fileSets, etc., but the behaviour is the same: no ${maven.dependency.classpath}, and no class found. Stumped - David