You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2010/01/21 06:36:50 UTC

svn commit: r901537 - in /ant/core/trunk/src: main/org/apache/tools/ant/util/LayoutPreservingProperties.java tests/antunit/taskdefs/optional/propertyfilelayout-test.xml

Author: bodewig
Date: Thu Jan 21 05:36:46 2010
New Revision: 901537

URL: http://svn.apache.org/viewvc?rev=901537&view=rev
Log:
only add a newline before the first new property rather than every new one

Added:
    ant/core/trunk/src/tests/antunit/taskdefs/optional/propertyfilelayout-test.xml   (with props)
Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java?rev=901537&r1=901536&r2=901537&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/LayoutPreservingProperties.java Thu Jan 21 05:36:46 2010
@@ -265,6 +265,7 @@
                 if (((Pair)line).isNew()) {
                     if (!writtenSep) {
                         osw.write(LS);
+                        writtenSep = true;
                     }
                 }
                 osw.write(line.toString() + LS);

Added: ant/core/trunk/src/tests/antunit/taskdefs/optional/propertyfilelayout-test.xml
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/optional/propertyfilelayout-test.xml?rev=901537&view=auto
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/optional/propertyfilelayout-test.xml (added)
+++ ant/core/trunk/src/tests/antunit/taskdefs/optional/propertyfilelayout-test.xml Thu Jan 21 05:36:46 2010
@@ -0,0 +1,116 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
+  <import file="../../antunit-base.xml" />
+
+  <target name="setUp">
+    <mkdir dir="${input}"/>
+    <mkdir dir="${output}"/>
+    <echo file="${input}/initial.properties"><![CDATA[#my comment
+foo=bar
+#second comment
+x=1
+]]></echo>
+  </target>
+
+  <target name="testCreateWithoutComment" depends="setUp">
+    <propertyfile file="${output}/created.properties">
+      <entry key="foo" value="bar"/>
+      <entry key="x" value="1" type="int"/>
+    </propertyfile>
+    <local name="head.in"/>
+    <local name="head.out"/>
+    <local name="tail.in"/>
+    <local name="tail.out"/>
+    <!-- skip comment -->
+    <loadfile srcfile="${input}/initial.properties" property="head.in">
+      <filterchain>
+        <headfilter lines="1" skip="1"/>
+      </filterchain>
+    </loadfile>
+    <loadfile srcfile="${input}/initial.properties" property="tail.in">
+      <filterchain>
+        <tailfilter lines="1"/>
+      </filterchain>
+    </loadfile>
+    <!-- skip date and blank line -->
+    <loadfile srcfile="${output}/created.properties" property="head.out">
+      <filterchain>
+        <headfilter lines="1" skip="2"/>
+      </filterchain>
+    </loadfile>
+    <loadfile srcfile="${output}/created.properties" property="tail.out">
+      <filterchain>
+        <tailfilter lines="1"/>
+      </filterchain>
+    </loadfile>
+    <au:assertPropertyEquals name="head.out" value="${head.in}"/>
+    <au:assertPropertyEquals name="tail.out" value="${tail.in}"/>
+  </target>
+
+  <target name="testCreateWithComment" depends="setUp">
+    <propertyfile file="${output}/created.properties" comment="my comment">
+      <entry key="foo" value="bar"/>
+      <entry key="x" value="1" type="int"/>
+    </propertyfile>
+    <local name="head.in"/>
+    <local name="head.out"/>
+    <local name="middle.in"/>
+    <local name="middle.out"/>
+    <local name="tail.in"/>
+    <local name="tail.out"/>
+    <!-- just comment -->
+    <loadfile srcfile="${input}/initial.properties" property="head.in">
+      <filterchain>
+        <headfilter lines="1"/>
+      </filterchain>
+    </loadfile>
+    <!-- skip comment -->
+    <loadfile srcfile="${input}/initial.properties" property="middle.in">
+      <filterchain>
+        <headfilter lines="1" skip="1"/>
+      </filterchain>
+    </loadfile>
+    <loadfile srcfile="${input}/initial.properties" property="tail.in">
+      <filterchain>
+        <tailfilter lines="1"/>
+      </filterchain>
+    </loadfile>
+    <!-- just comment -->
+    <loadfile srcfile="${output}/created.properties" property="head.out">
+      <filterchain>
+        <headfilter lines="1"/>
+      </filterchain>
+    </loadfile>
+    <!-- skip comment, date and blank line -->
+    <loadfile srcfile="${output}/created.properties" property="middle.out">
+      <filterchain>
+        <headfilter lines="1" skip="3"/>
+      </filterchain>
+    </loadfile>
+    <loadfile srcfile="${output}/created.properties" property="tail.out">
+      <filterchain>
+        <tailfilter lines="1"/>
+      </filterchain>
+    </loadfile>
+    <au:assertPropertyEquals name="head.out" value="${head.in}"/>
+    <au:assertPropertyEquals name="middle.out" value="${middle.in}"/>
+    <au:assertPropertyEquals name="tail.out" value="${tail.in}"/>
+  </target>
+
+</project>

Propchange: ant/core/trunk/src/tests/antunit/taskdefs/optional/propertyfilelayout-test.xml
------------------------------------------------------------------------------
    svn:eol-style = native