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

The Archive Base Latest Questions

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

All, Can someone please help on how to include a directory in a path

  • 0

All,

Can someone please help on how to include a directory in a path element conditionally if the directory exists: So like below

<path id="lib.path.ref">
    <fileset dir="${lib.dir}" includes="*.jar"/>
    <path location="${build.dir}" if="${build.dir.exist}"  />
</path>

This currently does not work because path element does not support the if attribute. In my case, I want to include build.dir if only it exists.

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-06-03T10:40:23+00:00Added an answer on June 3, 2026 at 10:40 am

    Without installing Ant-Contrib or similar Ant extensions, you can accomplish what you want with the following XML:

    <project default="echo-lib-path">
        <property name="lib.dir" value="lib"/>
        <property name="build.dir" value="build"/>
        <available file="${build.dir}" type="dir" property="build.dir.exists"/>
    
        <target name="-set-path-with-build-dir" if="build.dir.exists">
            <echo message="Executed -set-path-with-build-dir"/>
            <path id="lib.path.ref">
                <fileset dir="${lib.dir}" includes="*.jar"/>
                <path location="${build.dir}" />
            </path>
        </target>
    
        <target name="-set-path-without-build-dir" unless="build.dir.exists">
            <echo message="Executed -set-path-without-build-dir"/>
            <path id="lib.path.ref">
                <fileset dir="${lib.dir}" includes="*.jar"/>
            </path>
        </target>
    
        <target name="-init" depends="-set-path-with-build-dir, -set-path-without-build-dir"/>
    
        <target name="echo-lib-path" depends="-init">
            <property name="lib.path.property" refid="lib.path.ref"/>
            <echo message="${lib.path.property}"/>
        </target>
    </project>
    

    The important part here is what happens in the -init target. It depends upon the -set-path-with-build-dir and -set-path-without-build-dir targets, but Ant only executes one target based upon whether build.dir.exists is set or not.

    Read more about the Available Task here: http://ant.apache.org/manual/Tasks/available.html.

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

Sidebar

Related Questions

the following regexp is wrong - can someone please help to find all :-)
Can someone please help me out... I've tried all kinds of things (including help
HI all Can someone please please help me been trying to suss this for
Dear all..before i give up after multiple trial and error attempts,can someone please help
Can someone please tell me how to show all privileges/rules from a specific user
Can someone help me with this: This is a program to find all the
Can someone help me get started with a button timeout feature. All I want
Can someone please help me with this preg_match if (preg_match('~[^A-Za-z0-9_\./\]~', $filepath)) // Show Error
Can someone please help me out? My code for splitting the strings is working
Can someone please help me to find out why I can't update Eclipse so

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.