http://maven.apache.org/plugins/maven-antrun-plugin/classpaths.html
"Using optional ant tasks"

On 3/9/06, Laurie Harper <[EMAIL PROTECTED]> wrote:
> I'm trying to integrate a third-party, ant-based build into a Maven2
> build using the antrun plugin. The problem is the ant build uses
> optional tasks, and I can't figure out how to get that to work.
>
> The ant build as shipped copies the required dependencies (jar files)
> for the optional tasks to ~/.ant/lib to make them available to ant and
> this works fine when calling ant from the command line, but not when
> invoking ant from Maven. In any case, I'd rather skip that requirement
> by putting the jars on ant's classpath via some configuration in my POM.
>
> I've tried everything I can think of, but the antrun plugin always gives
> me the standard ant error message, 'Ant could not find the task or a
> class this task relies upon.'. For example, a simple test:
>
> build.xml:
> <?xml version="1.0" encoding="iso-8859-1"?>
> <project name="script-test" default="script-test" basedir=".">
>    <target name="script-test">
>      <script language="javascript"><![CDATA[
>        //alert("Javascript OK");
>      ]]></script>
>    </target>
> </project>
>
> pom.xml:
> <project xmlns="...>
>    <modelVersion>4.0.0</modelVersion>
>
>    <groupId>tmp</groupId>
>    <artifactId>tmp</artifactId>
>    <version>1.0-SNAPSHOT</version>
>
>    <build>
>      <plugins>
>        <plugin>
>          <artifactId>maven-antrun-plugin</artifactId>
>          <executions>
>            <execution>
>              <phase>compile</phase>
>              <!--<phase>generate-resources</phase>-->
>              <configuration>
>                <tasks>
>                  <ant dir="."/>
>                </tasks>
>              </configuration>
>              <goals>
>                <goal>run</goal>
>              </goals>
>            </execution>
>          </executions>
>        </plugin>
>      </plugins>
>    </build>
>
>    <dependencies>
>      <dependency>
>        <groupId>ant</groupId>
>        <artifactId>ant-optional</artifactId>
>        <version>1.5.2</version>
>        <scope>compile</scope>
>      </dependency>
>      <dependency>
>        <groupId>bsf</groupId>
>        <artifactId>bsf</artifactId>
>        <systemPath>${basedir}/bsf.jar</systemPath>
>        <version>BUNDLED</version>
>        <scope>system</scope>
>      </dependency>
>      <dependency>
>        <groupId>js</groupId>
>        <artifactId>js</artifactId>
>        <systemPath>${basedir}/js.jar</systemPath>
>        <version>BUNDLED</version>
>        <scope>system</scope>
>      </dependency>
>    </dependencies>
> </project>
>
> Result:
> $ mvn compile
> [INFO] Scanning for projects...
> [INFO]
> ----------------------------------------------------------------------------
> [INFO] Building Unnamed - tmp:tmp:jar:1.0-SNAPSHOT
> [INFO]    task-segment: [compile]
> [INFO]
> ----------------------------------------------------------------------------
> [INFO] [resources:resources]
> [INFO] Using default encoding to copy filtered resources.
> [INFO] [compiler:compile]
> [INFO] No sources to compile
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>
> script-test:
> [INFO]
> ----------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO]
> ----------------------------------------------------------------------------
> [INFO] Error executing ant tasks
>
> Embedded error: The following error occurred while executing this line:
> /Users/laurie/tmp/mvn-ant-script/build.xml:4: Could not create task or
> type of type: script.
>
> Ant could not find the task or a class this task relies upon.
>
> This is common and has a number of causes; the usual
> solutions are to read the manual pages then download and
> install needed JAR files, or fix the build file:
>   - You have misspelt 'script'.
>     Fix: check your spelling.
>   - The task needs an external JAR file to execute
>       and this is not found at the right place in the classpath.
>     Fix: check the documentation for dependencies.
>     Fix: declare the task.
>   - The task is an Ant optional task and the JAR file and/or libraries
>       implementing the functionality were not found at the time you
>       yourself built your installation of Ant from the Ant sources.
>     Fix: Look in the ANT_HOME/lib for the 'ant-' JAR corresponding to the
>       task and make sure it contains more than merely a
> META-INF/MANIFEST.MF.
>       If all it contains is the manifest, then rebuild Ant with the needed
>       libraries present in ${ant.home}/lib/optional/ , or alternatively,
>       download a pre-built release version from apache.org
>   - The build file was written for a later version of Ant
>     Fix: upgrade to at least the latest release version of Ant
>   - The task is not an Ant core or optional task
>       and needs to be declared using <taskdef>.
>   - You are attempting to use a task defined using
>      <presetdef> or <macrodef> but have spelt wrong or not
>     defined it at the point of use
>
> Remember that for JAR files to be visible to Ant tasks implemented
> in ANT_HOME/lib, the files must be in the same directory or on the
> classpath
>
> Please neither file bug reports on this problem, nor email the
> Ant mailing lists, until all of these causes have been explored,
> as this is not an Ant bug.
> [INFO]
> ----------------------------------------------------------------------------
> [INFO] For more information, run Maven with the -e switch
> [INFO]
> ----------------------------------------------------------------------------
> [INFO] Total time: 8 seconds
> [INFO] Finished at: Thu Mar 09 22:23:20 EST 2006
> [INFO] Final Memory: 3M/7M
> [INFO]
> ----------------------------------------------------------------------------
>
>
> Note: I'm using <scope>system</scope> because some of the JAR files used
> by the third-party bulid script are custom versions that ship with that
> product.
>
> Note: I want to hook the call to ant into the generate-resources
> lifecycle phase if possible, though I could live with hooking it into
> the compile phase if necessary to get the right classpath passed in to Ant.
>
> Note: I've tried various combinations of inheritAll and inheritRefs on
> the <ant/> task in pom.xml without any luck.
>
> Is there something simple I've missed, or is it just not possible to use
> Ant optional tasks with the antrun plugin?
>
> Thanks,
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


--
I could give you my word as a Spaniard.
No good. I've known too many Spaniards.
                             -- The Princess Bride

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

Reply via email to