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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:24:31+00:00 2026-05-28T17:24:31+00:00

So … I have build.xml that loads property file from basedir. Then, as the

  • 0

So … I have build.xml that loads property file from basedir.

Then, as the target I perform the following:

<var name="Var1" value="<property_from_**first**_loaded_property_file>" />
<var name="<property_from_**first**_loaded_property_file>" unset="true"/>
<property file="../<other directory>/<**second**_property_file>.properties" />
<var name="Var2" value="<property_from_**second**_loaded_property_file>"/>

The ceavat here is that both has same property name. It cannot be changed.

So, in the end, I should get the property like:

Var1=<property_from_**first**_loaded_property_file>

Var2=<property_from_**second**_loaded_property_file>

But instead –
I am getting signs that property (Var1) from first properties file is not unset and then filled with new value from second properties file. The thing that ant-contribs unset should deal with :/ … something like:

Var1 = Var2

Why I am not getting the expected result?

  • 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-28T17:24:32+00:00Added an answer on May 28, 2026 at 5:24 pm

    I think the issue is that even though you’re loading the variable into an antcontrib var, it’s still an ant property first, thus immutable.

    I know you can’t change the property files, but what kind of freedom do you have with the script itself? You can try to leverage the scoping rules and the antcallback task to scope where the variables get loaded.

    For example, the following achieves – albeit somewhat messily – what I think you’re after:

    <?xml version="1.0" encoding="utf-8"?>
    <project name="Test" basedir=".">
    
        <path id="ant.classpath">
            <fileset dir="${basedir}">
                <include name="ant-contrib_AP.jar"/>
            </fileset>
        </path>
    
        <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="ant.classpath"/>
    
        <target name="test">
    
            <antcallback target="load-more-prop" return="Var2"/>
    
            <loadproperties>
                <file file="prop1.properties"/>
            </loadproperties>
    
            <property name="Var1" value="${var}" />
    
            <echo>${Var1}</echo>
            <echo>${Var2}</echo>
    
        </target>
    
        <target name="load-more-prop">
    
            <loadproperties>
                <file file="prop2.properties"/>
            </loadproperties>
    
            <property name="Var2" value="${var}" />
        </target>
    </project>
    

    In my console I see:

    Buildfile: C:\Users\mfelzani\workspace-junk\junk\build.xml
    test:
    load-more-prop:
     [echo] 7
     [echo] 1
    BUILD SUCCESSFUL
    Total time: 905 milliseconds
    

    Which matches the values i set in prop1.properties and prop2.properties, respectively, for the var property.

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

Sidebar

Related Questions

I have this xml <entry id=1008 section=articles> <excerpt><p>&#8230; in Richtung „Aus für Tierversuche. Kosmetik-Fertigprodukte
I see that some rss on xml have strange strings. For example, ... is
I have an element like this: <span class=tool_tip title=The full title>The ful&#8230;</span> This seems
I'm trying to work out why it won't let me attach a file from
I have a PDB file. Now it has two parts separated by TER. Before
CGI.escapeHTML is pretty bad, but CGI.unescapeHTML is completely borked. For example: require 'cgi' CGI.unescapeHTML('&#8230;')
I have been making a wordpress template. i got stuck at some place... the
(tl;dr: see summary at the bottom.) I am implementing an application that pulls content
I've successfully connected to XMPP server (from android XMPP client), and I can send
I have a form, one of the fields is a select field, with 5

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.