jar.libs.dir没有被正确覆盖吗?

时间:2012-07-24 19:21:08

标签: java android xml ant

referencing few other questions之后,我发现这些答案都没有在我的项目中有效。将jar放入每个单独模块的/ libs文件夹中,ant build正确运行并产生输出。在我需要的每个模块中删除所有/ libs文件夹并包含ant.properties文件(a.k.a。build.properties)后,ant build已停止工作。

ant.properties:

# This file is used to override default values used by the Ant build system.
#
# This file must be checked in Version Control Systems, as it is
# integral to the build system of your project.

# This file is only used by the Ant script.

# You can use this to override default values such as
#  'source.dir' for the location of your java source folder and
#  'out.dir' for the location of your output folder.

jar.libs.dir=../ExternalJars/libs

在build.xml         

<property file="ant.properties" />

<loadproperties srcFile="project.properties" />

<!-- version-tag: 1 -->
 <import file="${sdk.dir}/tools/ant/build.xml" />

<target name="full-debug" depends="debug">
</target>

<target name="full-release" depends="clean,release">
</target>

据我所知,文件写得正确 - 相对于ant.properties文件的路径是正确的,jars是应该的位置,模块使用所有正确的类和部分等等。

思想?

2 个答案:

答案 0 :(得分:8)

基于另一个答案,这是我对build.xml脚本实现的,以支持jar.libs.dir属性:

<target name="-pre-compile">
    <property name="project.all.jars.path.temp" value="${toString:project.all.jars.path}" />
    <path id="project.all.jars.path">
        <path path="${project.all.jars.path.temp}"/>
        <fileset dir="${jar.libs.dir}">
            <include name="*.jar"/>
        </fileset>
    </path>
</target>

由于使用了&lt; path path =“...”/&gt; ,因此即使默认情况下将多个JAR文件添加到路径元素,它看起来也足够安全。< / p>

答案 1 :(得分:3)