2012-07-24 79 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