You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Thomas L Roche <tl...@us.ibm.com> on 2007/02/14 23:59:30 UTC

how to include other JARs?

Slightly offtopic, but since it's something that OP probably run
into, and I didn't see it answered in the FAQ, I thought I'd ask:
how to include other JARs with one's own? What I mean:

I'm automating some tests on a legacy batch-mode app that runs
remotely. Since

* I want to touch the remote boxes as little as possible

* this is the kind of app that bogs down one's laptop if run locally

* the remote boxes currently have Java but not Ant or JUnit

for now I'm creating a JAR containing the tests, deploying that JAR to
the remotes, shelling in and running with `java -jar`. But the tests
require external JARs, notably junit.jar. I'd like to just nest those
JARs in mine, e.g. like

  <copy todir="${target.lib.dir}">
    <fileset dir="${source.lib.dir}"/>
  </copy>

before running <jar>, but

http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html
> To load classes in JAR files within a JAR file into the class path,
> you must write custom code to load those classes.

which sounds painful. So instead I'm just doing

  <unjar ...>
    <fileset dir="${source.lib.dir}">
      <include name="**/*.jar"/>
    </fileset>
  </unjar>

before running <jar>. I'm wondering, is there a better way? E.g. is
writing the custom classloader trivial?


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org