2012-07-24 50 views
2

之后referencing只是一个fewotherquestions,我发现这些答案都没有在我的项目中工作。将jar放入每个单独模块的/ libs文件夹中,ant build正确运行并生成输出。删除所有/ libs文件夹并在我需要的每个模块中包含一个ant.properties文件(也叫做build.properties)后,ant build停止工作。jar.libs.dir是否被正确覆盖?

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 

在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> 

至于我可以告诉大家,这些文件被正确写入 - 的寻路都是相对ant.properties正确文件,罐子应该在哪里,模块使用所有正确的类别和部件等。

想法?

回答

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> 

由于使用了<路径路径=“...”/ >,它看起来足够安全,即使默认情况下将多个JAR文件添加到路径元素中。

+2

根据我的经验,这会放弃现有的project.all.jars.path内容(试过Ant 1.8.4,1.9.0和1.9.2,得到了相同的结果)。在开始目标标记下方添加一个,并将其引用为里面的路径覆盖似乎解决了这个问题。 – 2013-08-26 13:54:30

+0

你说得对 - 我正在更新我的答案。 – Panayotis 2013-09-17 09:55:49