プロパティ ファイルがあり、すべてのキーと値をコマンドに渡したいのですが、どうすればよいですか?
プロパティファイルがファイルに見えると言います
size=small
perf=true
アリのタスクは次のようになります
<exec executable="${prog}" failonerror="true">
<!-- I want to add all properties from file as argument here, -->
</exec>
そのため、実行時の動作は
<exec executable="${prog}" failonerror="true">
<arg value = "size"/>
<arg value = "small"/>
<arg value = "perf"/>
<arg value = "true"/>
</exec>
どうやってやるの?ありがとう
編集:
Vadzim の提案に従って、現在スクリプトを使用しています。
<property file="test.properties" prefix="testproperty"/>
<target name = "test1">
<script language="javascript"> <![CDATA[
properties = project.getUserProperties()
echo = project.createTask( "echo" );
anotation = project.getProperty("testproperty.size")
echo.setMessage(anotation);
echo.perform();
for(key in properties) {
echo.setMessage(key);
echo.perform();
echo.setMessage(properties[key]);
echo.perform();
}
]]> </script>
</target>
ただし、getProperty() は機能していますが、getProperties には notify() などの Java 関数しか含まれていません。
$ant test1
test1:
[echo] small
[echo] notifyAll
[echo] function notifyAll() {/*
[echo] void notifyAll()
[echo] */}
[echo] values
[echo] function values() {/*
[echo] java.util.Collection values()
[echo] */}
[echo] containsKey
[echo] function containsKey() {/*
[echo] boolean containsKey(java.lang.Object)
[echo] */}
[echo] entrySet
[echo] function entrySet() {/*
[echo] java.util.Set entrySet()
[echo] */}
[echo] keySet
[echo] function keySet() {/*
[echo] java.util.Set keySet()
[echo] */}
[echo] put
[echo] function put() {/*
[echo] java.lang.Object put(java.lang.Object,java.lang.Object)
[echo] */}
[echo] contains
[echo] function contains() {/*
[echo] boolean contains(java.lang.Object)
[echo] */}
[echo] empty
[echo] false
[echo] equals
[echo] function equals() {/*
[echo] boolean equals(java.lang.Object)
[echo] */}
[echo] notify
[echo] function notify() {/*
[echo] void notify()
[echo] */}
[echo] class
[echo] class java.util.Hashtable
[echo] elements
[echo] function elements() {/*
[echo] java.util.Enumeration elements()
[echo] */}
[echo] keys
[echo] function keys() {/*
[echo] java.util.Enumeration keys()
[echo] */}
[echo] isEmpty
[echo] function isEmpty() {/*
[echo] boolean isEmpty()
[echo] */}
[echo] size
[echo] function size() {/*
[echo] int size()
[echo] */}
[echo] putAll
[echo] function putAll() {/*
[echo] void putAll(java.util.Map)
[echo] */}
[echo] clear
[echo] function clear() {/*
[echo] void clear()
[echo] */}
[echo] wait
[echo] function wait() {/*
[echo] void wait()
[echo] void wait(long)
[echo] void wait(long,int)
[echo] */}
[echo] containsValue
[echo] function containsValue() {/*
[echo] boolean containsValue(java.lang.Object)
[echo] */}
[echo] toString
[echo] function toString() {/*
[echo] java.lang.String toString()
[echo] */}
[echo] hashCode
[echo] function hashCode() {/*
[echo] int hashCode()
[echo] */}
[echo] clone
[echo] function clone() {/*
[echo] java.lang.Object clone()
[echo] */}
[echo] get
[echo] function get() {/*
[echo] java.lang.Object get(java.lang.Object)
[echo] */}
[echo] getClass
[echo] function getClass() {/*
[echo] java.lang.Class getClass()
[echo] */}
[echo] remove
[echo] function remove() {/*
[echo] java.lang.Object remove(java.lang.Object)
[echo] */}
BUILD SUCCESSFUL
Total time: 0 seconds
getProperties() の結果を反復する正しい方法は何ですか?
どんな提案でも大歓迎です
EDIT2:
jbeard4の優れた説明がここにあります。JavaScriptの問題について。だから正しい方法は
<script language="javascript"> <![CDATA[
properties = project.getUserProperties()
var keyIter = properties.keySet().iterator();
while(keyIter.hasNext()) {
var key = keyIter.next();
var value = properties.get(key);
echo.setMessage(key+value);
echo.perform();
}
]]> </script>