2013-02-11 48 views
0

我試圖修改build.xml文件以指定一個外部jar被添加到最終編譯的jar中。在build.xml中指定一個外部jar以便在編譯後添加到結果jar中

這裏是我的build.xml文件

<project name="cmmdcservice" default="all"> 
    <property name="kf.dir" location="E:\knopflerfish_osgi_3.4.0"/> 
    <property name="framework.jar" 
    location="${kf.dir}/osgi/framework.jar"/> 

    <target name="all" depends="init,compile,jar"/> 

    <target name="init"> 
    <mkdir dir="out/classes"/> 
    </target> 

    <target name="compile"> 
    <javac destdir = "out/classes" 
    debug = "on" 
    srcdir = "src" 
    includeantruntime="false"> 
    <classpath> 
    <pathelement location="${framework.jar}"/> 
    </classpath> 
    </javac> 
    </target> 

    <target name="jar"> 
    <jar basedir = "out/classes" 
    jarfile = "out/${ant.project.name}.jar" 
    compress = "true" 
    includes = "**/*" 
    manifest = "manifest.mf"/> 
    </target> 

    <target name="clean"> 
    <delete dir = "out"/> 
    </target> 
    </project> 

我猜不知何故目標名稱=「罐子」節中,我需要參考我的外部罐子中,但實際上卻並不知道如何..任何想法?

回答

1

您需要添加一個post-jar部分。這裏是一個例子:

<target name="-post-jar"> 
    <jar update="true" destfile="${dist.jar}"> 
    <!-- Path to your jar. --> 
    <zipfileset src="/home/user/javalibs/myjar.jar"/> 
</jar> 
</target>