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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:25:08+00:00 2026-06-09T22:25:08+00:00

Here is a property file: test.url=https:\\url:port test.path=/home/folder test.location=Location test.version=1 And the following ant task:

  • 0

Here is a property file:

test.url=https:\\url:port
test.path=/home/folder
test.location=Location
test.version=1

And the following ant task:

I can pass temporary value for one run of a task:

ant -Dtest.path=new_path test_props

How can I overwrite test.path value with one I pass using -D key? In order, after the same launch, the value of test.path would change to one I pass above?

The following variants don’t work:

<entry key="test.path" value="${test.path}"/>

or

<propertycopy name="test.path" from="${test_path}"/>
  • 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-09T22:25:10+00:00Added an answer on June 9, 2026 at 10:25 pm

    If you want to permanently change a file, you could use the task.

    I’d do the following:

    Create a sample property file, like default.properties.sample.

    Create a target that receives the given -D property, then, if it’s been informed, does a replace on file default.properties.sample saving it into a default.properties file. The default.properties.sample would have these lines:

    test.url=https:\\url:port
    test.path=@test_path@
    test.location=Location
    test.version=1
    

    The action would replace the @test_path@ token with the real value of the property, as informed in the -D parameter, then save the resulting file as default.properties. Something like:

    <copy file="default.properties.sample" toFile="default.properties" />
    <replace file="default.properties" token="@test_path@" value="${test.path}" />
    

    Some adjustments need to be made, like: only replace the property if the -D parameter is informed, or else the file would be replaced every time.

    Paths and like should also be adjusted to your needs.


    I’ve tested the following scenario and it worked for me:

    I’ve created two files: a build.xml and a default.properties.sample. Their contents is as follows:

    build.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <project name="BuildTest" default="showProperties" basedir=".">
        <property file="default.properties"/>
    
        <target name="showProperties">
            <echo message="test.property=${test.property}"/>
        </target>
    
        <target name="replace">
            <fail unless="new.test.property" message="Property new.test.property should be informed via -D parameter"/>
            <copy file="default.properties.sample" toFile="default.properties"/>
            <replace file="default.properties" token="@test_property@" value="${new.test.property}"/>
        </target>
    </project>
    

    default.properties.sample:

    test.property=@test_property@
    

    And they run to the following tests:

    Default run:

    C:\Filipe\Projects\BuildTest>ant
    Buildfile: C:\Filipe\Projects\BuildTest\build.xml
    
    showProperties:
         [echo] test.property=${test.property}
    
    BUILD SUCCESSFUL
    Total time: 0 seconds
    

    Error control:

    C:\Filipe\Projects\BuildTest>ant replace
    Buildfile: C:\Filipe\Projects\BuildTest\build.xml
    
    replace:
    
    BUILD FAILED
    C:\Filipe\Projects\BuildTest\build.xml:10: Property new.test.property should be      informed via -D parameter
    Total time: 0 seconds
    

    Replace of property:

    C:\Filipe\Projects\BuildTest>ant replace -Dnew.test.property="This is a New Value"
    Buildfile: C:\Filipe\Projects\BuildTest\build.xml
    
    replace:
         [copy] Copying 1 file to C:\Filipe\Projects\BuildTest
    
    BUILD SUCCESSFUL
    Total time: 0 seconds
    

    Property file after replacement:

    C:\Filipe\Projects\BuildTest>type default.properties
    test.property=This is a New Value
    

    And in a subsequent runs the new value of the test.property is present:

    C:\Filipe\Projects\BuildTest>ant
    Buildfile: C:\Filipe\Projects\BuildTest\build.xml
    
    showProperties:
         [echo] test.property=This is a New Value
    
    BUILD SUCCESSFUL
    Total time: 0 seconds
    

    I think that is what you’re looking for.

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

Sidebar

Related Questions

I have a folder path stored in the property nightly.basepath (here the value would
I have the following property: @property (nonatomic, assign) double lastSynced; and here's my custom
I load a JavaScript file which takes current page's URL as a parameter. Here
I tried the following two ways to source the property file #!/bin/sh . import.properties
I want to load properties from property file as explained here http://www.soapui.org/Scripting-Properties/working-with-properties.html . I
In the code presented here: Gant file , there is the following code: target(dist:
Here is my simplest structure Customer CustomerID FirstName LastName ... BrokerID <- Navigation Property
Trying to implement a search similar to here .This searches properties based on city,locality,property
How can I have the property of a property set using NHibernate? Here is
I have essentially the same problem discussed here: http://khason.net/blog/dependency-property-getters-and-setters-in-multithreaded-environment/ public static readonly DependencyProperty MyPropertyProperty

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.