Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么ant中的propertiesFile任务会改变文件中属性的顺序?_Ant_Properties_Properties File - Fatal编程技术网

为什么ant中的propertiesFile任务会改变文件中属性的顺序?

为什么ant中的propertiesFile任务会改变文件中属性的顺序?,ant,properties,properties-file,Ant,Properties,Properties File,以一个属性文件为例 #File One #Section One sect1.number=Test1 sect1.sample=Test2 sect1.test=Test3 #Section Two sect2.number=Test1 sect2.sample=Test2 sect2.test=Test3 After running this ant: <property file="sample1.properties"/> <propertyfile file="sam

以一个属性文件为例

#File One #Section One sect1.number=Test1 sect1.sample=Test2 sect1.test=Test3 #Section Two sect2.number=Test1 sect2.sample=Test2 sect2.test=Test3 After running this ant:

<property file="sample1.properties"/>
<propertyfile file="sample1.properties">
   <entry key="sect1.number" value="ABC"/>
   <entry key="sect1.sample" value="B"/>
   <entry key="sect1.test" value="ABC"/>
   <entry key="sect2.number" value="B"/>                    
   <entry key="sect2.sample" value="ABC"/>
   <entry key="sect2.test" value="B"/>
</propertyfile>
The properties file will end as: #Updated on blah sect2.sample=ABC sect2.test=B sect1.sample=B sect1.number=ABC sect2.number=B sect1.test=ABC #文件一 #第一节 sect1.number=Test1 sect1.sample=Test2 第1节测试=测试3 #第二节 sect2.number=Test1 sect2.sample=Test2 第2节测试=测试3 运行此ant后:

属性文件将以以下形式结束: #更新了一些废话 第2节样本=ABC 第2节测试=B 第1节样本=B 第1节编号=ABC 第2节编号=B 第1节测试=ABC 注意,注释已消失,顺序不同

我在干什么,王,有工作吗


Grae

我猜您使用的是早于1.8的Ant版本

从1.8开始,默认情况下是“布局保留”模式,该模式保留注释(并可能保留属性顺序,但我对此不确定)

在该版本中,可以通过指定
jdkproperties=true

原始文件

$ cat sample1.properties.original
#File One
#Section One
sect1.number=Test1
sect1.sample=Test2
sect1.test=Test3

#Section Two
sect2.number=Test1
sect2.sample=Test2
sect2.test=Test3
$ mv sample1.properties sample1.properties.jdk
$ cat !$
cat sample1.properties.jdk
#Mon Jun 11 14:41:01 GMT 2012
sect2.test=B
sect1.test=ABC
sect2.sample=ABC
sect2.number=B
sect1.sample=B
sect1.number=ABC
在my Ant 1.8.2环境中使用构建文件创建的版本

$ cat sample1.properties.default
#Mon, 11 Jun 2012 14:39:08 +0000
#File One
#Section One
sect1.number=ABC
sect1.sample=B
sect1.test=ABC

#Section Two
sect2.number=B
sect2.sample=ABC
sect2.test=B
$ ant -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
在my Ant 1.8.2环境中使用构建文件创建的版本,但指定jdkproperties=“true”

我的蚂蚁环境

$ cat sample1.properties.default
#Mon, 11 Jun 2012 14:39:08 +0000
#File One
#Section One
sect1.number=ABC
sect1.sample=B
sect1.test=ABC

#Section Two
sect2.number=B
sect2.sample=ABC
sect2.test=B
$ ant -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010

有你?既然你一开始就问了这个问题,我想你的兴趣会比我的更强烈。我的结果列在上面。我使用的是1.8.3。