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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T04:02:07+00:00 2026-05-29T04:02:07+00:00

I have a property that contains multiple values, and I want to execute a

  • 0

I have a property that contains multiple values, and I want to execute a command with a separate “-j” argument for each value in the property.

E.g. <property name="arguments" value="foo bar hello world"/>

Should execute: mycommand -j foo -j bar -j hello -j world

I’m using Ant 1.7.1, so I can’t use the “prefix” attribute (Ant 1.8) on the <arg> element of an <exec> task.

One workaround is to insert the “-j” directly into the property by hand and then use the “line” attribute of <arg>:

<property name="args" value="-j foo -j bar -j hello -j world"/>
<exec executable="mycommand">
    <arg line="${args}"/>
</exec>

…But I prefer to have the property be a simple list without the embedded arguments.

Edit: Actually, my arguments are paths within an XML file, so a more accurate argument list would be:

<property name="arguments" value="/foo/bar /hello/world /a/very/long/path"/>

I would like the command to then execute with arguments: “-j /foo/bar -j /hello/world -j /a/very/long/path”. Note that the slashes remain forward slashes even under Windows (these are arguments to a command, not filenames).

  • 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-29T04:02:08+00:00Added an answer on May 29, 2026 at 4:02 am

    You can use Ant resource tools for this.

    <property name="arg_list" value="foo bar hello world"/>    
    <resources id="arguments">
      <mappedresources>
        <string value="${arg_list}" />
        <filtermapper>
          <replacestring from=" " to=" -j "/>
        </filtermapper>
      </mappedresources>
    </resources>
    <property name="arguments" value="-j ${toString:arguments}" />
    

    The above will result in property arguments having the value -j foo -j bar -j hello -j world, which can then be used in the exec arg line.

    Alternatively a pathconvert task can help in this regard:

    <property name="arg_list" value="foo bar hello world"/>    
    <pathconvert property="arguments" pathsep=" ">
      <chainedmapper>
        <flattenmapper />
        <regexpmapper from="(.*)" to="-j \1" />
      </chainedmapper>
      <filelist files="${arg_list}" />
    </pathconvert>
    

    If you have absolute paths, rather than just strings in the list, then remove the flattenmapper.

    If you have relative paths, replace the flattenmapper line with:

    <globmapper from="${basedir}/*" to="*" />
    

    to prevent the paths being converted to absolute.

    In the event that you have UNIX-like paths in the arg_list on a Windows system the default settings for pathconvert won’t work – the paths get converted to Windows style. Instead, to process the list use:

    <pathconvert property="arguments" pathsep=" " targetos="unix">
      <chainedmapper>
        <regexpmapper from="C:(.*)" to="-j \1" />
      </chainedmapper>
      <filelist files="${arg_list}" />
    </pathconvert>
    

    Note the targetos setting and the revised regexmapper from argument.

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

Sidebar

Related Questions

I have a database that contains two fields that collect multiple values. For instance,
I have an NSColorWell , which is bound to a property that contains an
I have a Customer class that contains a property, MyProperty, which is of a
I have a CompositeControl that contains a DropDownList. I have set the AutoPostBack property
If I have a property that I want to let inheritors write to, but
I have a Private property that I want to access in my MS Test
I want to have a class property that allow for an expression to take
Here's the situation: I have a custom TextBox control that contains multiple other TextBox
I have a two separate tables that contain parts of user name (don't ask
I have a generic List<MyClass> where MyClass has a property InvoiceNumber which contains values

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.