开发者

Ant : adding multiple jars in classpath dynamically

How to dynamically add jars to javac classpath in ant ?

e.g.

the properties file should be (this list can change and include different jars in dif开发者_如何学Pythonferent directories): dyna.jars=../../dir1/api1.jar;../dir2/api2.jar

in build.xml

            <javac
                srcdir="${javac.srcdir}"
                .....
            >
            <classpath refid="${dyna.jars}" />

            </javac>

Thank you.


I can't quite tell if dir1 and dir2 are going to be changing also or just the JARs in those directories but assuming those directories are going to be named the same, the following will include all JARs under dir and dir2 and create a <path> with id="dyna.jars". Note that it should be refid="dyna.jars" and not refid="${dyna.jars}"

<path id="dyna.jars">
    <fileset dir="../../dir1">
        <include name="**/*.jar"/>
    </fileset>
    <fileset dir="../../dir2">
        <include name="**/*.jar"/>
    </fileset>
</path>

<javac srcdir="${javac.srcdir}" .....>
    <classpath refid="dyna.jars" />
</javac>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜