How to make <jar> include the *contents* of another JAR, rather than
just that JAR file itself? What I mean:
I inherited a project with a JAR but no build.xml :-( so I'm creating
one. The oddest thing about this project is that, under its lib/, it
has classes, not JARs:
> $ find project/lib/ -type f | fgrep -ve 'CVS' # yes, checked in
> project/lib/org/apache/commons/net/bsd/RCommandClient.class
> project/lib/org/apache/commons/net/bsd/RExecClient.class
> project/lib/org/apache/commons/net/bsd/RLoginClient.class
> project/lib/org/apache/commons/net/CharGenTCPClient.class
> project/lib/org/apache/commons/net/CharGenUDPClient.class
> project/lib/org/apache/commons/net/DatagramSocketClient.class
Pretty obviously the contents of commons-net-1.4.0.jar, so I
downloaded that to project/lib. I then compiled using it
> <target name="compile" depends="init"
> description="compile sources">
> <property name="compile.outdir" value="${build.result.folder}/bin"/>
> <mkdir dir="${compile.outdir}" />
> <javac destdir="${compile.outdir}"
> failonerror="${javacFailOnError}"
> verbose="${javac.verbose}"
> debug="${javacDebug}"
> source="${javac.source}"
> target="${javac.target}">
> <src path="${source.dir}" />
> <classpath>
> <pathelement path="${bootclasspath}"/>
> <fileset dir="${lib.dir}">
> <include name="**/*.jar"/>
> </fileset>
> </classpath>
> </javac>
> </target>
I then made a new JAR
> <target name="project.jar" depends="init, compile"
> description="Build project.jar">
> <jar
> jarfile="${build.result.folder}/project.jar">
> <fileset dir="${compile.outdir}">
> <include name="**/*.class"/>
> </fileset>
> <manifest>
> <attribute name="Main-Class" value="foo.bar.project"/>
> </manifest>
> </jar>
> </target>
However the size of the new JAR ~= sizeof(inherited JAR) +
sizeof(commons-net JAR), and I do indeed need commons-net fu at
runtime. So I tried
> <target name="project.jar" depends="init, compile"
> description="Build project.jar">
> <jar
> jarfile="${build.result.folder}/project.jar">
> <fileset dir="${compile.outdir}">
> <include name="**/*.class"/>
> </fileset>
> <fileset dir="${lib.dir}">
> <include name="**/*.jar"/>
> </fileset>
> <manifest>
> <attribute name="Main-Class" value="foo.bar.project"/>
> </manifest>
> </jar>
> </target>
but that just creates
> $ zipinfo project/build/project.jar
<snip>
> -rw-r--r-- 2.0 unx 180799 b- defN 7-May-05 21:42
commons-net-1.4.0.jar
which is useless @ runtime. However if I do
> <target name="project.jar" depends="init, compile"
> description="Build project.jar">
> <jar
> jarfile="${build.result.folder}/project.jar">
> <fileset dir="${compile.outdir}">
> <include name="**/*.class"/>
> </fileset>
> <fileset dir="${lib.dir}">
> <include name="**/*.class"/>
i.e. use the inherited project/lib/*.class files
> </fileset>
> <manifest>
> <attribute name="Main-Class" value="foo.bar.project"/>
> </manifest>
> </jar>
> </target>
the JAR works. But I very much want to get rid of the inherited
project/lib/*.class files (e.g. so I can get them out of CVS).
How best to make the <jar> task include the JAR's classes, not the JAR
itself? Please reply directly to me (as well as the list) if possible,
feel free to forward, and TIA.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]