我如何引用一个共同的目录(而不是库)外部JAR文件使用Ant来构建Android项目? [英] How do I reference external jar files in a common directory (not libs) to build android project using ant?

查看:242
本文介绍了我如何引用一个共同的目录(而不是库)外部JAR文件使用Ant来构建Android项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个参考使用蚂蚁相同的jar文件几款Android项目。我不想将JAR文件复制到每个库目录中的项目(由于源代码控制树的设置方式)。该<一href="http://stackoverflow.com/questions/2611105/how-to-specify-lib-folder-for-jars-when-using-android-generated-ant-build-file">answers我find这里说的把它们放在libs目录,这并没有解决这个问题。

I would like to build several android projects that reference the same jar files using ant. I do not want to copy the jar file to each libs directory in the project (due to how the source control tree is set up). The answers I find here say "put them in the libs directory" which does not solve this problem.

所以现在的问题是,如何配置我的android Ant构建脚本引用一个共同的罐子在一个单独的目录中的项目之外(而不是在库)?

So the question is, how do I configure my android ant build scripts to reference a common jar in a separate directory outside the project (not in "libs")?

推荐答案

在SDK中,也有在工具蚂蚁文件/蚂蚁。在 main_rules.xml ,你可以找到以下code部分:

In the sdk, there are ant files under tools/ant. In main_rules.xml, you can find the following code section:

<!-- 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构建code决定从哪里得到的罐子。你可以重载 jar.libs.dir 在你的build.properties的价值,因为是本节之前阅读并会过载值。指点,在一个共同的目录,你打算使用会做你的建议是什么。您可能需要使用它的一些玩得到它的工作,你想要的方式。

This is how the ant build code determines where to get the jars from. You could overload the value of jar.libs.dir in your build.properties since that is read before this section and would overload the value. Pointing that at a common directory you intend to use will do what you are suggesting. You may need to play with it some to get it to work the way you want.

一个需要注意的是,我不知道这是否会产生负面影响等构建生命周期的活动。

One caveat is that I'm not sure if this will negatively impact other build life cycle activities.

这篇关于我如何引用一个共同的目录(而不是库)外部JAR文件使用Ant来构建Android项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆