显然,我可以使用build.properties中的source.dir属性指定源文件夹 - 但是如果我想指定多个源文件夹呢?
以下评论来自Android SDK工具生成的build.xml文件:
<!-- The build.properties file can be created by you and is never touched
by the 'android' tool. This is the place to change some of the default property values
used by the Ant rules.
Here are some properties you may want to change/update:
application.package
the name of your application package as defined in the manifest. Used by the
'uninstall' rule.
source.dir
the name of the source directory. Default is 'src'.
out.dir
the name of the output directory. Default is 'bin'.
Properties related to the SDK location or the project target should be updated
using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your application and
should be checked in in Version Control Systems.
-->
注意:我不关心在Eclipse中构建 - 我使用ant设置自动构建。
答案 0 :(得分:18)
您是否尝试使用冒号分隔路径?我的build.properties看起来像这样:
source.dir=src:src2:src3:src4:src5
答案 1 :(得分:0)
在我这里的(大量定制的)build.xml中,它解决了许多其他问题,我最终不得不将编译目标拉入我的XML并在那里指定多个源路径。您也可以这样做,只需将新目标放在build.xml中的setup任务定义之上。请注意,Android SDK中存在多个文件,这些文件看起来都像您应该用来自定义的文件,其中一些看起来是错误的,或者至少使用最新的工具无法正常工作( tools / ant / main_rules.xml似乎不适用于我的Windows SDK)。我相信你想要的是最新SDK中的平台/ [platform-numer] /ant/ant_rules_r2.xml。无论如何,任务看起来像下面的任务,你可以很容易地添加另一个源目录。我没有尝试用冒号分隔,就像其他答案一样,因为正如我所说,我们的build.xml必须以多种方式进行自定义。但我知道这会奏效。
<!-- Compiles this project's .java files into .class files. -->
<target name="compile" depends="-resource-src, -aidl"
description="Compiles project's .java files into .class files">
<!-- If android rules are used for a test project, its classpath should include
tested project's location -->
<condition property="extensible.classpath"
value="${tested.project.absolute.dir}/bin/classes" else=".">
<isset property="tested.project.absolute.dir" />
</condition>
<condition property="extensible.libs.classpath"
value="${tested.project.absolute.dir}/libs" else="./libs">
<isset property="tested.project.absolute.dir" />
</condition>
<javac encoding="ascii" target="1.5" debug="true" extdirs=""
destdir="${out.classes.absolute.dir}"
bootclasspathref="android.target.classpath"
verbose="${verbose}" classpath="${extensible.classpath}"
classpathref="android.libraries.jars">
<src path="${source.absolute.dir}" />
<src path="${gen.absolute.dir}" />
<src refid="android.libraries.src" />
<classpath>
<fileset dir="${external.libs.absolute.dir}" includes="*.jar" />
<fileset dir="${extensible.libs.classpath}" includes="*.jar" />
</classpath>
</javac>
</target>