Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4118304
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T22:56:36+00:00 2026-05-20T22:56:36+00:00

Hey guys, I am using Apache Ant and I am wondering how would I

  • 0

Hey guys, I am using Apache Ant and I am wondering how would I edit a variable in a file (e.g. database host, username, password) and pass an argument (e.g. for a subversion commit message)

Basically I want the Apache Ant task to change my database variables and then execute the subversion commit command on my current directory.

This is on Windows 7.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T22:56:36+00:00Added an answer on May 20, 2026 at 10:56 pm

    — It’s hard to know what you are asking for in detail, so the answer changes —

    If you want to copy a new value into a portion of a file (instead of allowing a user to set a variable in ant), then you use ant’s copy task coupled with a filterset.

    The copy will produce the output file from the input file, and the filterset will indicate which “tokens” need to be replaced with some value. Often this value is something that was stored in a property, but it could be composed by other means.

    <copy todir="build/source">
      <fileset dir="src"/>
      <filterset>
        <filter token="BUILD_NUMBER" value="${build.number}"/>
      </filterset>
    </copy>
    

    copies all files from src to build/src replacing @BUILD_NUMBER@ with the value of the property build.number.

    — Original post follows —

    Create a properties file, then reference it from the build.xml.

    An example of a properties file database.properties

    database.user=dbuser
    database.user.password=supersecret
    database.url=jdbc:org:driver:locahost:0000/mydatabase
    database.driver=org.example.DatabaseDriver
    

    An example of referencing the file from a build.xml file

    <property file="database.properties"/>
    

    This way you can isolate your configuration changes to a specific file. Ant doesn’t have variables, it has properties which are “set once”, so to provide default values, you need to do something like

    <property file="database.properties"/>
    <property name="database.user" value="default"/>
    

    to ensure that the database.user is always set. If a database user property is defined in the database.properties file, then the second attempt to assign the property will be ignored. If a user removes database.user=bob from the properties file, then the second attempt to set it in the build.xml file will succeed.

    In the rare event that you actually want a person to type in some value (perhaps a password), use the input task; however, it again can only set a property. Ant doesn’t have variables.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys I am trying to manipulate a word .docx file using the openXML
Hey guys. I have an app in Objective C (using xcode) that I would
Hey guys i am using edit text in my application. Problem arises if user
Hey guys I am using open id authentication on my website and after authenticating
Hey guys I'm using the latest version of XCode (3.2.2) and I've linked the
Hey guys I've been using the has_and_belongs_to_many relationship with checkboxes example from the Railscast
Hey guys..I am designing a set-up wizard using CPropertySheet and CpropertyPage in MFC application...I
Hey guys currently I am thinking of serving images using an image handler script.
Hey guys - I just wrote an app using c# and ready to deploy
Hey guys I have a gridview and below it 4 textboxes I'm using to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.