• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

How to read a property from a properties file in Ant?

 
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I'm using Ant 1.6. I have this target ...

<target name="gen-web-svc-client-jar">
<clientgen
wsdl="${basedir}/wsdl_files/ProvisioningService.wsdl"
destFile="${deployment}/APP-INF/lib/ProvisioningServiceClient.jar"
packageName="com.myco.nps.regui.provisioning.client"
serviceName="ProvisioningService"
classpath="${java.class.path}"
>
<classpath>
<path refid="project.class.path" />
</classpath>
</clientgen>
</target>

For the property, 'wsdl="${basedir}/wsdl_files/ProvisioningService.wsdl"', I would prefer to read this property out of a properties file I have, which has the line ...

PROVISIONING_SERVICE_WSDL_URL=http://99.99.99.99:9999/ProvisioningAccountService/ProvisioningAccountService?WSDL


How can I tell ant to get the value from this file?

Thanks, - Dave
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use loadproperties + filterchain (if you want to read only one property) task

Have a look at http://ant.apache.org/manual/CoreTasks/loadproperties.html
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out the 'file' attribute of the Property task.
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for this info but after reading the link (http://ant.apache.org/manual/CoreTasks/loadproperties.html), I'm still unsure of how to reference the property I want in my Ant script. So I have

<loadproperties>
<file file="file.properties"/>
</loadproperties>


which fill load the properties file, but then how do I reference the "PROVISIONING_SERVICE_WSDL_URL" property within that file? - Dave
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this:




When the properties file is read, every property in that file becomes a property in Ant, which can be accessed in the typical Ant fashion of enclosing it within "${}".
 
Dave Alvarado
Ranch Hand
Posts: 436
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I added the line you suggested (with '<properties file="conf/${env}/app.properties" />') I got this error ...


build.xml:39: Could not create task or type of type: properties.

Ant could not find the task or a class this task relies upon.


I'm using Ant 1.6. Sadly, it being a company standard at the moment, I don't have an option to upgrade. Is this a version issue?

Thanks, -
 
Peter Johnson
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry, typo. Use "property" not "properties".
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic