In case its useful, here's a fledgling unit test for excercising the PropertyFile task- You should only need to unzip it onto your ant source distribution and invoke it with the commands below.
%ANT_HOME%$ ant run-single-test -Dtestcase=org.apache.tools.ant.taskdefs.optional.PropertyFileTest Presently, it only confirms the tasks ability to update existing properties, but I have more plans for it in the future. Eventually, I'll get ambitious and implement a PropertyFile.load(InputStream) method that doesn't ignore comments and whitespace.. Regards, Levi Cook -----Original Message----- From: Erik Hatcher [mailto:[EMAIL PROTECTED] Sent: Wednesday, October 03, 2001 11:31 AM To: [email protected]; ant-dev Subject: Re: problem with propertyfile task Chuck, This looks and smells just like a bug to me! :) I've tried it out and was not able to use it in the manner you desire (with Ant 1.4). There have been no changes in <propertyfile> from 1.3 to 1.4 - so that bug has been there for a while. I'll file it in Bugzilla today, and attempt fixing it and submitting a patch. I'm copying ant-dev on this in case there is some known workaround and to alert them of the issue. Erik ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[email protected]> Sent: Wednesday, October 03, 2001 8:55 AM Subject: RE: problem with propertyfile task > Hmm, maybe the functionality that I want doesn't exist. If the > property is not present (or not set), I want the property to be added > with the default value. If the property is already in the property > file (and it's value is not equal to the default), the value should be > left unmodified. Is there a way to get this behavior? > > BTW I'm using ant 1.3 that comes with NetBeans. Does and 1.4 have > enhanced propertytype functionality and/or documentation? > > Thanks > > Chuck > > > -----Original Message----- > > From: jakarta-ant [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, October 03, 2001 9:57 AM > > To: ant-user > > Cc: jakarta-ant > > Subject: Re: problem with propertyfile task > > > > > > Even though the documentation says that "value" is required for the > > <entry> elements, its not 100% accurate. It defaults int values to > > 1. Use 'value' > > to set the value, and use default to set a value if its not > > already set. > > This could probably be considered a bug, or at least is > > somewhat confusing. > > In your case you may want to use value and default, depending > > on your needs. > > > > Erik > > > > > > ----- Original Message ----- > > From: <[EMAIL PROTECTED]> > > To: <[email protected]> > > Sent: Wednesday, October 03, 2001 7:46 AM > > Subject: help: problem with propertyfile task > > > > > > > I'm not able to get entry elements with default attributes of the > > > optional propertyfile task to work correctly. For example, and > > > entry element of: > > > > > > <entry key="CICS_TRANSACTION_GATEWAY_PORT" default="2006"/> > > > > > > produces a property file entry of: > > > > > > CICS_TRANSACTION_GATEWAY_PORT=1 <--- expecting value of 2006 !? > > > > > > My complete propertyfile task and resulting property file > > are attached > > > below. Your help is greatly appreciated. > > > > > > Chuck > > > > > > ************************* propertyfile task > > > ************************************* > > > > > > <propertyfile > > > file="${classes.home}/com/sprint/fms/constants.properties"> > > > <entry key="CICS_TRANSACTION_GATEWAY_HOST" > > > type="string" > > > default="199.14.219.100"/> > > > <entry key="CICS_TRANSACTION_GATEWAY_PORT" default="2006"/> > > > <entry key="CICS_SERVER_NAME" default="DA131"/> > > > <entry key="CICS_PROGRAM_NAME" default="FHXM0P"/> > > > <entry key="GetCktWfmList_MESSAGE_ID" > > value="GET-CKT-WFM-LIST"/> > > > <entry key="GetCktWfmList_COPYBOOK_PREFIX" value="FHXKC1"/> > > > <entry key="GetCktWfmList_COPYBOOK_NAME" value="FMFHXKC1"/> > > > <entry key="GetCktWfmList_XSTL_STYLESHEET" > > > value="GetCktWfmListStylesheet.xml"/> > > > <entry key="GetFRPhysAssign_MESSAGE_ID" > > value="GET-FR-PHYS-ASGN"/> > > > <entry key="GetFRPhysAssign_COPYBOOK_NAME" value="FMFHXJC1"/> > > > <entry key="GetFRPhysAssign_COPYBOOK_PREFIX" value="FHXJC1"/> > > > <entry key="GetFRPhysAssign_XSTL_STYLESHEET" > > > value="GetFRPhysAssignStylesheet.xml"/> > > > <entry key="UpdFRPhysAssign_MESSAGE_ID" > > value="UPD-FR-PHYS-ASGN"/> > > > <entry key="UpdFRPhysAssign_COPYBOOK_NAME" value="FMFHXJC1"/> > > > <entry key="UpdFRPhysAssign_COPYBOOK_PREFIX" value="FHXJC1"/> > > > <entry key="UpdFRPhysAssign_XSTL_STYLESHEET" > > > value="UpdFRPhysAssignStylesheet.xml"/> > > > <entry key="LogonToFms_MESSAGE_ID" value="LOGON-TO-FMS"/> > > > <entry key="LogonToFms_COPYBOOK_PREFIX" value="COMM06"/> > > > <entry key="GENERIC_COPYBOOK_PREFIX" value="COMM06"/> > > > <entry key="GENERIC_COPYBOOK_NAME" value="FMCOMM06"/> > > > <entry key="GENERIC_XSTL_STYLESHEET" > > > value="GENERICStylesheet.xml"/> > > > </propertyfile> > > > > > > ******************************** Generated property file > > > **************************** > > > #Tue Oct 02 21:03:42 CDT 2001 > > > UpdFRPhysAssign_XSTL_STYLESHEET=UpdFRPhysAssignStylesheet.xml > > > GetCktWfmList_COPYBOOK_NAME=FMFHXKC1 > > > CICS_TRANSACTION_GATEWAY_PORT=1 CICS_TRANSACTION_GATEWAY_HOST=1 > > > GetCktWfmList_MESSAGE_ID=GET-CKT-WFM-LIST > > > UpdFRPhysAssign_MESSAGE_ID=UPD-FR-PHYS-ASGN > > > GetCktWfmList_COPYBOOK_PREFIX=FHXKC1 > > > GetFRPhysAssign_COPYBOOK_PREFIX=FHXJC1 > > > GetFRPhysAssign_COPYBOOK_NAME=FMFHXJC1 > > > GENERIC_COPYBOOK_PREFIX=COMM06 > > > GetCktWfmList_XSTL_STYLESHEET=GetCktWfmListStylesheet.xml > > > LogonToFms_MESSAGE_ID=LOGON-TO-FMS > > > LogonToFms_COPYBOOK_PREFIX=COMM06 > > > GetFRPhysAssign_XSTL_STYLESHEET=GetFRPhysAssignStylesheet.xml > > > UpdFRPhysAssign_COPYBOOK_NAME=FMFHXJC1 > > > GENERIC_XSTL_STYLESHEET=GENERICStylesheet.xml > > > GetFRPhysAssign_MESSAGE_ID=GET-FR-PHYS-ASGN > > > CICS_PROGRAM_NAME=1 > > > GENERIC_COPYBOOK_NAME=FMCOMM06 > > > UpdFRPhysAssign_COPYBOOK_PREFIX=FHXJC1 > > > CICS_SERVER_NAME=1 > > > > > > > > > > > >
<<attachment: src.zip>>
