0

I have unjar ant task like below that was working until I changed classpath to include one more jar file. Wondering what the trick is to unjar every jar listed in javac.classpath. Basically it is breaking once javac.classpath has more than one jar file. I am Ant newbee. I am trying to figure out a way to enumerate every jar in javac.classpath and unjar it to build.classes.dir folder.

    <unjar dest="${build.classes.dir}">
        <fileset file="${javac.classpath}" >
        </fileset>
    </unjar>
videoguy
  • 1,732
  • 2
  • 24
  • 49

1 Answers1

0

if javac.classpath points to a folder then

<unjar dest="${build.classes.dir}">
    <fileset dir="${javac.classpath}" >
    </fileset>
</unjar>

will unjar all jar files in that folder.

if javac.classpath is a comma/semicolon separated list of file paths then you should change script a little bit to use filesets instead, like;

<?xml version="1.0" encoding="UTF-8"?>
<project name="Un-jar Demo" default="un-jar">

    <fileset id="javac.classpath" dir="/path/to/jar/folder">
        <include name="jar-file-1.jar" />
        <include name="jar-file-2.jar" />
    </fileset>

    <target name="un-jar">

        <unjar dest="test">
            <fileset  refid="javac.classpath">
            </fileset>
        </unjar>

    </target>

</project>

of course, you can find some other ways to convert comma seperated list of files to a fileset

Community
  • 1
  • 1
guleryuz
  • 2,714
  • 1
  • 15
  • 19
  • Unfortunately the jars listed in classpath are in various directories. Ant tasks like for and foreach sounded promising. But they are not standard Ant tasks. I couldn't get ant-contrib lib working with Netbeans, which is what I am using to build our code. – videoguy Sep 25 '16 at 21:19