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

Phi*_*itt 2 java xml ant android

之后引用短短几个 其他 的问题,我发现没有这些问题的答案在我的项目都在工作.将jar放入每个单独模块的/ libs文件夹中,ant build正确运行并产生输出.删除所有/ libs文件夹并在我需要的每个模块中包含一个ant.properties文件(aka 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
Run Code Online (Sandbox Code Playgroud)

在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>
Run Code Online (Sandbox Code Playgroud)

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

思考?

Pan*_*tis 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>
Run Code Online (Sandbox Code Playgroud)

由于使用了<path path ="..."/>,因此即使默认情况下向路径元素添加了多个JAR文件,它看起来也足够安全.

  • 根据我的经验,这将丢弃现有的project.all.jars.path内容(尝试过Ant 1.8.4,1.9.0和1.9.2,得到了相同的结果).在开始目标标记的正下方添加<property name ="project.all.jars.path.temp"value ="$ {toString:project.all.jars.path}"/>,并将其引用为<path path ="路径覆盖中的$ {project.all.jars.path.temp}"/>似乎解决了这个问题. (2认同)