android - 如何引用公共(public)目录(不是库)中的外部 jar 文件来使用 ant

我想使用 ant 构建几个引用相同 jar 文件的 android 项目。我不想将 jar 文件复制到项目中的每个 libs 目录中(由于源代码控制树的设置方式)。 answers我 find这里说“将它们放在 libs 目录中”并不能解决这个问题。

所以问题是,如何配置我的 android ant 构建脚本以引用项目外部单独目录中的公共(public) jar(不在“libs”中)?

最佳答案

在sdk中,tools/ant下有ant文件。在 main_rules.xml 中,您可以找到以下代码部分:

<!-- Directory for the third party java libraries -->
<property name="jar.libs.dir" value="libs" />
<property name="jar.libs.absolute.dir" location="${jar.libs.dir}" />
<!-- create a path with all the jar files, from the main project and the
     libraries -->
<path id="jar.libs.ref">
    <fileset dir="${jar.libs.absolute.dir}" includes="*.jar" />
    <path refid="project.libraries.jars" />
</path>

这就是 ant 构建代码确定从哪里获取 jar 的方式。您可以在 build.properties 中重载 jar.libs.dir 的值,因为这是在本节之前读取的,并且会重载该值。指向您打算使用的公共(public)目录将执行您的建议。您可能需要对其进行一些操作才能使其以您想要的方式工作。

需要注意的是,我不确定这是否会对其他构建生命周期 Activity 产生负面影响。

关于android - 如何引用公共(public)目录(不是库)中的外部 jar 文件来使用 ant 构建 android 项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5312478/

相关文章:

javascript - 为 JavaScript 构建过程工具

unit-testing - 如何从 Go 测试覆盖中忽略生成的文件

git - 如何将修订和构建日期添加到源?

java - 创建新的 ClassLoader 以重新加载 Class

build - 了解 CMake 背后的目的

c# - TeamCity 8 中的 DotCover 不起作用

c# - 如何在夜间构建期间自动设置程序集版本?

tfs - 让 TFS 将变更集放入程序集版本中

eclipse - 如何查看 Eclipse 中触发 "Build workspace"的原因

build - TeamCity 工件;排除单个文件