Here's a fairly bare-bones ant example, the one I'm using for BriefWebServer.

It makes a jar in build/jar, and optionally run the jar.

<project name="BriefWebServer" basedir="." default="jar">
    <property name="src.dir" value="src" />
    <property name="build.dir" value="build" />
    <property name="classes.dir" value="${build.dir}/classes" />
    <property name="jar.dir" value="${build.dir}/jar" />
    <property name="" value="BriefWebServer.jar" />
    <property name="" value="org.denevell.briefwebserver" />

    <target name="compile">
        <mkdir dir="${classes.dir}" />
        <javac srcdir="${src.dir}" destdir="${classes.dir}" />

    <target name="jar" depends="compile">
        <mkdir dir="${jar.dir}" />
        <jar destfile="${jar.dir}/${}" basedir="${classes.dir}">
            <attribute name="Main-Class" value="org.denevell.briefwebserver.BriefWebServer" />

    <target name="run">
        <java jar="build/jar/BriefWebServer.jar" fork="true" />

    <target name="clean">
        <delete dir="${build.dir}" />

java-ant java

Edit on github
comments powered by Disqus
Click me