Yes the secret is in using the task definition and seeting the dependency on 
ant-junit _at the pom level_ if you do it at the plugin level then it can't be 
seen:


<project>
  ...
  <dependencies>
    <!-- callout to ant for integration tests -->       
    <dependency>
    <groupId>ant</groupId>
    <artifactId>ant-junit</artifactId>
    <version>1.6.5</version>
    <scope>test</scope>
    </dependency>       
  </dependencies>               
  <build>
    <plugins>   
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>run-itests</id>
            <phase>integration-test</phase>
            <configuration>
              <tasks>
                <taskdef name="junit" 
                  
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">
                  <classpath>
                  <path refid="maven.test.classpath"/>
                  </classpath>
                </taskdef>                                                      
                <mkdir dir="${project.build.directory}/test-classes"/>
                <junit>
                  ...
                </junit>                                                        
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>                                  
        </executions>
        <dependencies>
          <dependency>
            <groupId>com.sun</groupId>
            <artifactId>tools</artifactId>
            <scope>system</scope>
            <version>1.5</version>
            <systemPath>${java.home}/../lib/tools.jar</systemPath>
          </dependency>                                                         
                
        </dependencies>                         
      </plugin>            
    </plugins>
  </build>
</project>



-----Original Message-----
From: news on behalf of Paul Galbraith
Sent: Mon 9/18/2006 4:51 PM
To: users@maven.apache.org
Subject:  antrun plugin, junit classpath
 
I want to use M2's antrun plugin to execute a junit task, but I keep 
getting errors indicating that ant can't find junit in the classpath.

My POM has:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-antrun-plugin</artifactId>
   <executions>
     <execution>
       <id>junit</id>
       <phase>test</phase>
       <goals>
         <goal>run</goal>
       </goals>
       <configuration>
         <tasks>
           <junit>
             ...
           </junit>
         </tasks>
       </configuration>
     </execution>
   </executions>
   <dependencies>
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
       <version>3.8.1</version>
       <scope>test</scope>
     </dependency>
   </dependencies>
</plugin>

I get the following output:

========================================================================

[DEBUG] Configuring mojo 
'org.apache.maven.plugins:maven-antrun-plugin:1.1:run'
-->
[DEBUG]   (f) artifacts = [junit:junit:jar:3.8.1:test, 
ant:ant:jar:1.6.5:runtime
, ant:ant-launcher:jar:1.6.5:runtime, 
org.apache.maven:maven-project:jar:2.0.1:r
untime, org.apache.maven:maven-plugin-api:jar:2.0.1:runtime]
[DEBUG]   (f) project = [EMAIL PROTECTED]
[DEBUG]   (f) tasks =
[DEBUG] -- end configuration --
[INFO] [antrun:run {execution: junit}]
[INFO] Executing tasks
[DEBUG] getProperty(ns=null, name=ant.reuse.loader, user=false)
[INFO] 
------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] 
------------------------------------------------------------------------
[INFO] Error executing ant tasks

Embedded error: Could not create task or type of type: junit.

Ant could not find the task or a class this task relies upon.

========================================================================

If I remember correctly, this is typical when running ant standalone, if 
junit is not on ant's classpath.

Is there any way to get this to work in M2?

Paul


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to