Bug 61442

Summary: echoproperties ant 1.6.1 vs ant 1.10.1
Product: Ant Reporter: Chandra shekar r chekuri <chandra.chekuri>
Component: Core tasksAssignee: Ant Notifications List <notifications>
Status: NEEDINFO ---    
Severity: normal CC: chandra.chekuri
Priority: P2    
Version: 1.10.1   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X 10.1   
Attachments: was unable to attach to files so both output from 1.6.1 and 1.10.1 are in this files

Description Chandra shekar r chekuri 2017-08-17 20:37:31 UTC
Created attachment 35248 [details]
was unable to attach to files so both output from 1.6.1 and 1.10.1 are in this files

we are migrating our ant version from 1.6.1 to 1.10.1 which was due since ages.

when we use ant 1.6.2 the following code generates file as shown in echopropeties.txt ( in attachments) , and when we use ant 1.10.1  generates the file as echopropeties.txt(in attachments).

The issue we are having is that in 1.10.1 it is writing the properties with empty string into the .txt file(refer echopropeties_1_10_1.txt ), is there way to omit these values in the destfile?

for example 
in .xml file 
     <ExcludedFeatureTypeList>
                               <ExcludedFeatureType></ExcludedFeatureType>
                               <ExcludedFeatureType></ExcludedFeatureType>
                               <ExcludedFeatureType></ExcludedFeatureType>
                               <ExcludedFeatureType></ExcludedFeatureType>
                                <ExcludedFeatureType></ExcludedFeatureType>
      </ExcludedFeatureTypeList>

in ant 1.6.2 , there was no entry in .txt file but in 1.10.1

ConversionSpec.ExcludedFeatureTypeList.ExcludedFeatureType=,,,,
ConversionSpec.Midpoint.SGMidpoint.MidpointInputFile=


<echoproperties destfile="echoproperties.txt" failonerror="false">
  <propertyset>
      <propertyref prefix="ProductSpec."/>
      <propertyref prefix="ConversionSpec."/>
      <propertyref prefix="ExtendedListingsSpec."/>
      <propertyref prefix="Has."/>
      <propertyref name="DATA_RELDATE"/>
      <propertyref name="VOICE_RELDATE"/>
      <propertyref name="UK_RELDATE"/>
      <propertyref name="CAN_RELDATE"/>
	  <propertyref name="SGP_RELDATE"/>
	  <propertyref name="BRA_RELDATE"/>
      <propertyref name="OracleServerHostName"/>
      <propertyref name="OracleDBInstance"/>
      <propertyref name="oracleNetServiceName"/>
      <propertyref name="rdfUserName"/>
      <propertyref name="rdfPassword"/>
      <propertyref name="xmobUserName"/>
      <propertyref name="xmobPassword"/>
      <propertyref name="xmobSID"/>
      <propertyref name="xmobUserNameSec"/>
      <propertyref name="xmobPasswordSec"/>
      <propertyref name="IS_CMOB"/>
      <propertyref name="ExcludedCIFeature"/>
      <propertyref name="ExcludedCIValue"/>
      <propertyref name="PublishDiscoverCities"/>
      <propertyref name="PublishXtdl"/>
      <propertyref name="Publish4WD"/>
      <propertyref name="PublishCityModels"/>
      <propertyref name="Publish3DJunctions"/>
      <propertyref name="PublishPriority"/>
	  <propertyref name="AdminCountryInclude"/>	  
	  <propertyref name="AdminCountryExclude"/>		  
    </propertyset>
</echoproperties>
Comment 1 Stefan Bodewig 2017-08-18 13:58:47 UTC
I'm afraid I don't see what you describe - or misunderstand what you are saying

$ cat 61442.xml 
<project default="test">
  <property name="a" value=""/>
  <property name="b" value="x"/>
  <target name="test">
    <echoproperties>
      <propertyset>
        <propertyref name="ant.version"/>
        <propertyref name="a"/>
        <propertyref name="b"/>
        <propertyref name="c"/>
      </propertyset>
    </echoproperties>
  </target>
</project>

I echo ant.version just to be sure, a non-existent property with "c", a property with an empty value with "a" and a "normal" property with "b". Here are the results

$ /devel/ASF/apache-ant-1.6.1/bin/ant -f /tmp/61442.xml 
Buildfile: /tmp/61442.xml

test:
[echoproperties] #Ant properties
[echoproperties] #Fri Aug 18 15:57:22 CEST 2017
[echoproperties] b=x
[echoproperties] a=
[echoproperties] ant.version=Apache Ant version 1.6.1 compiled on February 12 2004

BUILD SUCCESSFUL
Total time: 0 seconds

$ ant -f /tmp/61442.xml 
Buildfile: /tmp/61442.xml

test:
[echoproperties] #Ant properties
[echoproperties] #Fri Aug 18 15:57:41 CEST 2017
[echoproperties] a=
[echoproperties] ant.version=Apache Ant(TM) version 1.10.2alpha compiled on July 23 2017
[echoproperties] b=x

BUILD SUCCESSFUL
Total time: 0 seconds

As you can see 1.6.1 both seem to behave the same, both echo the property a with an empty value and neither echoes anything for a non-existent property.
Comment 2 Chandra shekar r chekuri 2017-08-18 14:47:34 UTC
sorry for not being clear.

when i run using ant 1.6.1 , I do not see the properties which are empty .

but now when we are using ant 1.10.1 , we are seeing the properties which are empty and thats causing our existing workflow to fail.

as shown in attachment the output of 1.6.1 and 1.10.1 

ConversionSpec.ExcludedFeatureTypeList.ExcludedFeatureType=,,,,

the above property was not echoed when used with 1.6.1

my question is there a option not to echo properties which are empty?
Comment 3 Stefan Bodewig 2017-08-18 16:12:37 UTC
As I've shown I do see properties with empty values in 1.6.1 a well.

There must be something different going on in your case, can you create a small self-contained example like the one I've shown that creates different results for 1.6.1 and 1.10.1?

Similar to bug 61315 I suspect it is the way you set properties (and you don't tell us how it happens).

Back in bug 61315 I suspected you'd use xmlproperty to read properties and bug 26286 could indeed explain why you see properties with empty values now that you didn't see in 1.6.1. If this is the case then the properties simply don't exist in your 1.6.1 build and the reason is not whether their values is empty. So in this case we would simply be looking at the wrong task and we'd need to talk about xmlproperty reading things rather than echoproperties writing things.
Comment 4 Stefan Bodewig 2017-09-03 15:22:43 UTC
is there anything we can do to resolve this?