將檔案內容載入為 Apache Ant 屬性。這等同於 <property file|resource=
,但它支援巢狀的 ...
/><filterchain>
元素。此外,如果檔案不存在,則會以錯誤中止建置,而不是印出警告。
注意:此任務的 prefixValues 屬性的預設值與 <property>
任務中同一個屬性的預設值不同。
屬性 | 說明 | 必要 |
---|---|---|
srcFile | 來源檔案 | 下列其中一個或巢狀資源 |
resource | 屬性檔案的資源名稱 | |
encoding | 載入檔案時要使用的編碼 | 否 |
classpath | 尋找資源時要使用的類別路徑。 | 否 |
classpathref | 尋找資源時要使用的類別路徑,以 參考 在其他地方定義的 <path> 提供。 |
否 |
prefix | 套用至載入屬性的前置詞。自 Ant 1.8.1 起 | 否;預設為 . |
prefixValues | 擴充屬性的右側時,是否套用前置詞。自 Ant 1.8.2 起 | 否;預設為 true |
自 Ant 1.7 起
指定的資源將用作 srcFile 或 resource。
與 resource 屬性搭配使用。
將 file.properties 的內容載入為 Ant 屬性。
<loadproperties srcFile="file.properties"/>
或
<loadproperties> <file file="file.properties"/> </loadproperties>
從檔案 file.properties 中讀取包含字串 import.
的行,並將它們載入為 Ant 屬性。
<loadproperties srcFile="file.properties"> <filterchain> <linecontains> <contains value="import."/> </linecontains> </filterchain> </loadproperties>
載入 https://example.org/url.properties.gz 的內容,即時解壓縮,並將內容載入為 Ant 屬性。
<loadproperties> <gzipresource> <url url="https://example.org/url.properties.gz"/> </gzipresource> </loadproperties>