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 7901269
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:10:40+00:00 2026-06-03T09:10:40+00:00

If I pass a variable to ant by doing ant -Dsomething=blah How can I

  • 0

If I pass a variable to ant by doing

ant -Dsomething=blah

How can I refer to it in my build.xml? I tried @something@ and ${something} but neither seem to work.

Ultimately what I am trying to do is set some properties (versions) at compile time.

update: the problem of course turned out to be somewhere else – accepting the most complete looking answer with examples

  • 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-06-03T09:10:41+00:00Added an answer on June 3, 2026 at 9:10 am

    Don’t you hate it when you over think these things:

    <project name="test">
        <echo message="The value of foo is ${foo}"/>
    </project>
    

    Now, I’ll run my program. Notice that I never defined a value for property foo in my build.xml. Instead, I’ll get it from the command line:

    $ ant -Dfoo=BAR_BAR_FOO
    
    test:
         [echo] The value of foo is BAR_BAR_FOO
    
    BUILD SUCCESSFUL
     time: 0 seconds
    

    See. Nothing special at all. You treat properties set on the command line just like normal properties.

    Here’s where the fun comes in. Notice that I’ve defined the property foo in my build.xml this time around:

    <project name="test">
         <property name="foo" value="barfu"/>
         <echo message="The value of foo is ${foo}"/>
    </project>
    

    Now watch the fun:

    $ ant
    test:
         [echo] The value of foo is barfu
    
    BUILD SUCCESSFUL
     time: 0 seconds
    

    Now, we’ll set the property foo on the command line:

    $ ant -Dfoo=BAR_BAR_FOO
    test:
         [echo] The value of foo is BAR_BAR_FOO
    
    BUILD SUCCESSFUL
     time: 0 seconds
    

    See the command line overrides the value I set in the build.xml file itself. This way, you can have defaults that can be overwritten by the command line parameters.

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

Sidebar

Related Questions

How can I pass a variable value from a template using JavaScript without using
I need to pass a variable to a javascript function,but I got a little
Is it possible to pass a variable to a linked .js file? I tried
Can some one tell me how to pass variable Y to $('a:eq(0)').click() ? I
I am using javascript. I wanted to ask how can i pass variable link
How can I pass a variable by reference in scheme? An example of the
Can we pass variable number of arguments to a function in c?
I am wondering if I can pass variable to be evaluated as String inside
I want to pass variable arguments obtained in one function to other function but
Hi how i can pass variable into this function var _index = $(#sideNewsContent_menu li).index($(this))

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.