Bug 18732 - expand properties during -propertyfile processing
Summary: expand properties during -propertyfile processing
Status: RESOLVED FIXED
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.8.1
Hardware: Other other
: P3 enhancement with 5 votes (vote)
Target Milestone: 1.8.2
Assignee: Ant Notifications List
URL:
Keywords:
: 25546 34144 (view as bug list)
Depends on: 51792
Blocks:
  Show dependency tree
 
Reported: 2003-04-05 14:09 UTC by Colbert Philippe
Modified: 2012-04-30 13:00 UTC (History)
4 users (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Colbert Philippe 2003-04-05 14:09:24 UTC
I set my ANT_OPTS='-propertyfile ant.properties'.  ANT does not recognize the 
comand-line parameter -propertyfile.  This is an obvious bug.

I suggest that ANT should always accept an optional default property file 
(possibly ant.properties).  ANT should optionally accept also accept ALL 
command-line parameters on the property file.  The ANT_OPTS is difficult to 
change and manipulate.

Also, ANT should accept macro expressions in its property file.  It does not 
accept such expression now.  For instance it should accept such thing as:
  root.path=${basedir}/sources

Regards,
Colbert Philippe
Comment 1 Conor MacNeill 2003-04-05 14:34:23 UTC
http://ant.apache.org/manual/running.html#envvars

Try using ANT_ARGS.
Comment 2 Steve Loughran 2003-04-06 06:04:54 UTC
1. like Conor says, you should be using ant_args; that part of your bugrep is
invalid.

2. ant does normally expand properties in its property files, but a quick skim
of the source implies that no, we dont seem to be working on -propertyfile
expansion.

As this is not in the spec, marking it as an enhancement and renaming the bugrep
as appropriate. 
Comment 3 peter reilly 2003-12-16 08:24:27 UTC
*** Bug 25546 has been marked as a duplicate of this bug. ***
Comment 4 Peter Reilly 2005-03-25 17:27:35 UTC
*** Bug 34144 has been marked as a duplicate of this bug. ***
Comment 5 Michael Pelz-Sherman 2008-01-14 10:00:03 UTC
At minimum, the Ant documentation should warn people that in-line property
expansion does not work when -propertyfile is used.
Comment 6 Nick Silkey 2010-06-03 17:03:50 UTC
Yeah, this behavior is bothersome and (imho) a bug.  

I have this in foo.properties:
base.path=/base/path
deploy.app=foo
deploy.path=${base.path}/${deploy.app}

I want this at runtime:
base.path=/base/path
deploy.app=foo
deploy.path=/base/path/foo

If the Ant xml includes <property file="foo.properties" />, nested properties listed in foo.properties are expanded.  

If -propertyfile is used, either from the cli @ invocation (ant -f foo.xml target -propertyfile foo.properties) or via ANT_ARGS, the nested properties (i.e. ${deploy.path} do not expand/enumerate/etc.

FWIW, running Ant in debug shows that properties slurped in via -propertyfile invocations are set to 'ro project property'.  In debug when you call to a property file directly via <property /> in your Ant XML, these are set to 'project property'.

This issue manifests in the current release (1.8.1).  And nothing in the docs seems to indicate that Ant should behave differently at runtime whether one sets properties via <property ... />, -propertyfile, or -Dproperty.foo, etc.
Comment 7 Stefan Bodewig 2010-06-15 11:47:05 UTC
should work with svn revision 954939