Hi Jo,

One example for your reference.
I use for-each and  <script language="javascript"> in build.xml
please note maven.dependency.classpath property binding between pom.xml
and build.xml excerpts below.
Good luck.

<!-- ==  pom.xml fragment =============== -->
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <phase>pre-site</phase>
            <configuration>
              <tasks>
              <typedef
resource="org/apache/maven/artifact/ant/antlib.xml">
              <classpath refid="maven.dependency.classpath"/>
              </typedef>
             <echo message="pom.xml: maven-antrun-plugin"></echo>
                <tstamp>
                  <format locale="en" property="TODAY_UK"
pattern="d-MMM-yyyy"></format>
                </tstamp>
                <echo>pom.xml: timestamp ${TODAY_UK}</echo>
                <property refid="maven.dependency.classpath"
name="mvndepClasspath" />
                <ant inheritRefs="true" inheritAll="true"
antfile="${basedir}/src/4.bin/build.xml">
               <property environment="env"/>
               <property value="true" name="project.debug"></property>
               <property file="${user.home}/build.properties"/>
               <target name="cmn.outadate.tgt.nm" />
             </ant>     
              </tasks>
            </configuration>
            <goals>
              <goal>run</goal>
            </goals>
          </execution>
        </executions>
        <dependencies>
            <dependency>
            <groupId>org.apache.maven</groupId>
            <artifactId>maven-artifact-ant</artifactId>
            <version>2.0.4</version>
            </dependency>
            <dependency>
            <groupId>ant</groupId>
            <artifactId>ant</artifactId>
            <version>1.6.5</version>
            </dependency>
            <dependency>
            <groupId>jtidy</groupId>
            <artifactId>jtidy</artifactId>
            <version>4aug2000r7-dev</version>
            </dependency>
            <dependency>
            <groupId>ant-contrib</groupId>
            <artifactId>cpptasks</artifactId>
            <version>1.0b3</version>
            </dependency>
            <dependency>
            <groupId>ant-contrib</groupId>
            <artifactId>ant-contrib</artifactId>
            <version>1.0b2</version>
            </dependency>
            <dependency>
            <groupId>ant</groupId>
            <artifactId>optional</artifactId>
            <version>1.5.4</version>
            </dependency>
            <dependency>
            <groupId>ant</groupId>
            <artifactId>ant-antlr</artifactId>
            <version>1.6.5</version>
            </dependency>
            <dependency>
            <groupId>antlr</groupId>
            <artifactId>antlrall</artifactId>
            <version>2.7.4</version>
            </dependency>

            <dependency>
            <groupId>ant</groupId>
            <artifactId>ant-nodeps</artifactId>
            <version>1.6.5</version>
            </dependency>

             <dependency>
            <groupId>bsf</groupId>
            <artifactId>bsf</artifactId>
 
<systemPath>C:/usr/local/share/sdl/bsf-2_2/lib/bsf.jar</systemPath>
            <version>BUNDLED</version>
            <scope>system</scope>
            </dependency>
            <dependency>
        <groupId>js</groupId>
        <artifactId>js</artifactId>
 
<systemPath>C:/usr/local/share/sdl/rhino1_5R4_1/js.jar</systemPath>
        <version>BUNDLED</version>
        <scope>system</scope>
            </dependency>
        </dependencies>
      </plugin>

<!-- ==  build.xml fragment =============== -->
<?xml version="1.0"?>
<!DOCTYPE project [
   <!ENTITY bld.cmn.prps SYSTEM "file:./bld.cmn.prps.xml">
   <!ENTITY bld.cmn.tgts SYSTEM "file:./bld.cmn.tgts.xml">
   <!ENTITY bld.prj.prps SYSTEM "file:./bld.prj.prps.xml">
   <!ENTITY bld.prj.tgts SYSTEM "file:./bld.prj.tgts.xml">

]>
<project name="SCM-Test" default="cmn.proj.doc.tgt" basedir=".."
xmlns:ac="antlib:net.sf.antcontrib" >
   <taskdef classpath="${mvndepClasspath}"
resource="org/apache/maven/artifact/ant/antlib.xml">
   </taskdef>
   <echo message="inside build.xml at ${TODAY_UK}" />
   <!-- Common properties best loaded as entities -->
   &bld.cmn.prps;

   <!-- Project specific properties -->
   &bld.prj.prps;

   <!-- Project specific targets -->
   &bld.prj.tgts;

   <!-- Common target rules -->
   &bld.cmn.tgts;

</project>
-----Original Message-----
From: Jo Vandermeeren [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, February 07, 2007 9:14 AM
To: Maven Users List
Subject: Maven 2: antrun-plugin with ant-contrib tasks


Hello,

I'm trying to build an ant project with maven 2 using the antrun plugin.
The ant project uses ant-contib tasks. If I build the project with ant
("ant build"), it works without any problems, because the
ant-contrib.jar is in ${ANT_HOME}/lib.

However, if I try to build it with the maven antrun-plugin, it doesn't
build because it can't find the for-task. So, I included a taskdef for
it in the plugin's configuration, without the desired effect..

The ant build starts, some initialization stuff occur, but as soon as a
for-task is encountered, the build fails.

I have also tried to set dependencies on the plugin, but the same
result..

Any help on this would be greatly appreciated..

Thanks
Jo




Here's part of the maven project's pom.xml:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>process-classes</phase>
                        <configuration>
                            <tasks>
                                <taskdef
resource="net/sf/antcontrib/antcontrib.properties"
classpath="${env.ANT_HOME }/lib/ant-contrib.jar"/>
                                <echo>Building Trax client with
BOB..</echo>
                                <echo>* bob properties: ${env.BOB_ENV
}</echo>
                                <ant antfile="build.xml"
dir="${basedir}">
                                    <target name="build"/>
                                </ant>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
</plugin>





Here's the output of "mvn package":


[INFO] Scanning for projects...
[INFO]
------------------------------------------------------------------------
----
[INFO] Building Trax EAR module
[INFO]    task-segment: [package]
[INFO]
------------------------------------------------------------------------
----
[INFO] [ear:generate-application-xml]
[INFO] Generating application.xml
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources. [WARNING]
    Artifact ant:ant:jar:1.6.5:runtime retains local scope 'runtime'
overriding broader scope 'compile'
    given by a dependency. If this is not intended, modify or remove the
local scope.

[INFO] [antrun:run {execution: default}]
     [echo] Building Trax client with BOB..
     [echo] * bob properties: /home/jo/projects/bob.properties
Overriding previous definition of reference to bob-rt-lib Trying to
override old definition of datatype ejbc

bob:
     [echo] Remote repository = 'file:////mnt/lambda-trax/repository'
     [echo] Local repository = '/home/jo/.repository'
     [echo] Bob dir = '/home/jo/.repository/trax/bob/bob-3.2.33'
     [echo] Temp dir = '/tmp'
     [echo] Remote repository is uptodate :
'/mnt/lambda-trax/repository/remote-repository.xml'
     [echo] Check dependencies :
'bob;client-platform;server-platform;trax-webstart;framework;ogf-hiberna
te;generics;system;ystr;trax-pack-core;trax-pack-util;trax-swing-gui;ogo
odies;ojdbc14;jtds;proxyclient;proxyservlet;bob-rt;'
[INFO]
------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO]
------------------------------------------------------------------------
[INFO] The following error occurred while executing this line:
/home/jo/.repository/trax/bob/bob-3.2.33/bob-build.xml:69: The following
error occurred while executing this line:
/home/jo/.repository/trax/bob/bob-3.2.33/bob-build.xml:276: Could not
create task or type of type: for.

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

Reply via email to