Menu

#40 Can't add custom ant tasks like ant-contrib.jar

open
nobody
None
5
2007-06-13
2007-06-13
No

The documentation indicates that it's possible to add an antlib directory to a non-extracting jar file, to extend the classpath of antinstaller:

http://antinstaller.sourceforge.net/classpathresources.html
"It is currently possible to include a directory called antlib this will be passed to the Ant launcher with the normal ant -lib parameter.
With self extracting jars all classes should be packaged in the root of the Jar file."

I tried adding the ant-contrib.jar in my jar, under antlib, but got taskdef errors from ant for the antcontrib task I was trying to use (foreach).

I tried several other variations, like adding the files from ant-contrib.jar directly to the jar at the top level, but this caused a cryptic stack trace that did not provide enough information for debugging.

Discussion

  • teknopaul

    teknopaul - 2007-07-17

    Logged In: YES
    user_id=616485
    Originator: NO

    AI comes with a few custom ant tasks that are defined in code, but the task defining should work in the scripts too.

    I have added an example to the /unittest/ directory in SVN, this uses the fillowing XML to define a task at the project level.

    <taskdef name="chown" classname="org.apache.tools.ant.taskdefs.optional.unix.Chown" />

    N.B. to add the required classes to the installers CP I added the following to the build that creates the non-extracting Jar
    <zipgroupfileset dir="${installDir}/antlib" includes="ant-nodeps.jar"/>

    And it seems to work fine in a non-extractor case.

    The /antlib/ directory is left there for scripted installs (e.g. from CDs) and ease of porting existing Ant scripts but I think the second way you tried to add the class files directly to the installer Jar is the best mechanism, and correct for packed installers.

    Can you send me the cryptic stack trace? It may be something specific to ant-contrib.jar.

     
  • Anonymous

    Anonymous - 2007-07-20

    Pop-up error message

     
  • Anonymous

    Anonymous - 2007-07-20

    Logged In: YES
    user_id=532979
    Originator: YES

    I put the ant-contrib.jar into the non-extracting jar, like so:

    205129 Sun Jul 01 20:31:26 EDT 2007 antlib/ant-contrib.jar

    I have the following taskdef in my build.xml:

    <taskdef resource="net/sf/antcontrib/antcontrib.properties" format="properties"/>

    An error box popped up, image attached, and a stack trace was printed, also attached.
    File Added: antcontrib-error.png

     
  • Anonymous

    Anonymous - 2007-07-20

    Logged In: YES
    user_id=532979
    Originator: YES

    File Added: ant-contrib-stack-trace.txt

     
  • Anonymous

    Anonymous - 2007-07-20

    Stack trace

     
  • Anonymous

    Anonymous - 2007-07-20

    Logged In: YES
    user_id=532979
    Originator: YES

    File Added: ant-contrib-stack-trace.txt

     

Log in to post a comment.