【问题标题】:Is jar.libs.dir not being overridden properly?jar.libs.dir 没有被正确覆盖吗?
【发布时间】:2012-07-23 04:24:13
【问题描述】:

referencing 只是一个few other questions 之后,我发现这些答案都不适用于我的项目。将 jar 放入每个单独模块的 /libs 文件夹中,ant 构建可以正确运行并产生输出。在删除所有 /libs 文件夹并在我需要的每个模块中包含 ant.properties 文件(又名 build.properties)后,ant 构建已停止工作。

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

构建.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 文件是正确的,jar 是它们应该在的位置,模块使用所有正确的类和部分,等等。

想法?

【问题讨论】:

    标签: java android xml ant


    【解决方案1】:

    基于另一个答案,这是我对 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>
    

    由于使用了 ,它看起来足够安全,即使默认情况下向路径元素添加了多个 JAR 文件。

    【讨论】:

    • 根据我的经验,这将丢弃现有的 project.all.jars.path 内容(尝试了 Ant 1.8.4、1.9.0 和 1.9.2,得到了相同的结果)。在开始的目标标记下方添加一个 并像 似乎可以解决问题。
    【解决方案2】:

    【讨论】:

    • 不是我要找的答案,但正确的答案都是一样的。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-04-25
    • 1970-01-01
    相关资源
    最近更新 更多