开发者

Java Ant build with external libraries

I have followin开发者_如何学Gog target in mz ant script to build my java application

<target name="jar" depends="compile" description="generate jar">
    <jar jarfile="${build.dir}/jar/final.jar" basedir="${build.dir}/classes">
        <manifest>
            <attribute name="Main-Class" value="my.package.Main" />
        </manifest>
    </jar>
</target>

What I need is to somehow include log4j into the jar, as it throws a NoClassDefFoundError when running with

java -jar final.jar

What is the best way to achieve that?

Best, Will


I could solve my problem with zipgroupfileset

    <jar jarfile="${build.dir}/jar/final.jar">
        <fileset dir="${build.dir}/classes" />
        <zipgroupfileset dir="${lib.dir}" includes="*.jar"/>
        <manifest>
            <attribute name="Main-Class" value="my.pacakge.Main" />
        </manifest>
    </jar>


try adding includes parametersettings to it, like

includes="<path-to-log4j-folder>/*.jar"

Detailed syntax is here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜