ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject Error in <jar> found?
Date Thu, 23 Jan 2003 08:30:07 GMT
I did a quick hack in java and created a small ant buildfile to compile and
jar the program.
No package structure and no directory structure (really a quick hack :-)
When I was <jar>ing it with 
	<jar destfile="PrintArgs.jar" includes="*.class" />
the jar doesn´t contain the class.
If I work with filesets OR if I set the basedir attribute it works.

Bug in JarTask or in Doc? The doc sais that basedir isn´t required (although
the first example uses it).

I made a small test scenario:


---8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<
-------8-<-------8-<----
public class PrintArgs {
    public static void main(String[] args) {
        System.out.println("parameters are:");
        for (int i=0; i<args.length; i++) {
            System.out.println(i + ": " + args[i]);
        }
        System.out.println();
    }
}
---8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<
-------8-<-------8-<----
<?xml version="1.0" encoding="ISO-8859-1"?>

<project default="jar">

    <target name="compile">
        <javac srcdir="." destdir="." />
    </target>

    <target name="jar" depends="compile">
        <!-- Delete the jars so that I can do this more times -->
        <delete><fileset dir="."><include name="*.jar"/></fileset></delete>

        <!-- Jar does not contain the class -->
        <!-- Maybe basedir isn´t right? See next -->
        <jar destfile="PrintArgs.jar" includes="*.class" />

        <!-- This works -->
        <jar destfile="PrintArgs2.jar" basedir="." includes="*.class" />

        <!-- And this works, too -->
        <jar destfile="PrintArgs3.jar">
            <fileset dir=".">
                <include name="*.class"/>
            </fileset>
        </jar>
    </target>

</project>
---8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<-------8-<
-------8-<-------8-<----


Jan Matèrne

Mime
View raw message