利用ant build.xml打包一个project

项目结构如下:

build.xml

<project default="jar" name="test">
    <property name="src" value="src" />
    <property name="class" value="bin" />
    <property name="output" value="target" />
    <property name="jar" value="test.jar" />
    <property name="main" value="com.zh.tool.test" />

    <target name="init">
        <mkdir dir="${class}" />
        <mkdir dir="${output}" />
    </target>

    <target name="compile" depends="init">
        <javac srcdir="${src}" destdir="${class}">
        </javac>
    </target>

    <target name="jar" depends="compile">
        <jar destfile="${output}/${jar}" basedir="${class}">
            <manifest>
                <attribute name="Main-class" value="${main}" />
            </manifest>
        </jar>
    </target>
</project>

 

执行build.xml后的,刷新项目:

 

posted @ 2018-01-07 17:56  trypretty  阅读(1631)  评论(0编辑  收藏  举报