使用jar lib构建Ant

时间:2017-09-11 06:49:38

标签: java ant

我的主意:

root

------src

------lib

------------AbsoluteLayout.jar

我想用AbsoluteLayout.jar lib

构建一个ant文件

我的代码:

<project name="TestAnt" basedir="." default="main">

<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="main-class"  value="com.socket.ServerFrame"/>
<target name="clean">
    <delete dir="${build.dir}"/>
</target>

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

<target name="jar" depends="compile">
    <mkdir dir="${jar.dir}"/>
    <mkdir dir="build/jar/lib"/>
    <copy file="lib/AbsoluteLayout.jar" todir="build/jar/lib"/> 
    <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
        <manifest>
            <attribute name="Main-Class" value="${main-class}"/>
            <attribute name="Class-Path" value="lib/AbsoluteLayout.jar"/>
        </manifest>
    </jar>
</target>

<target name="run" depends="jar">
    <java jar="${jar.dir}/${ant.project.name}.jar" fork="true"/>
</target>

<target name="clean-build" depends="clean,jar"/>

<target name="main" depends="clean,run"/>

但它不起作用。

0 个答案:

没有答案