I have the exact same problem, and I don't think the suggested solutions
work for me... I have top level path elements such as:
<path id="classpath.lib.runtime">
<!-- Libraries required at run-time -->
<fileset dir="${dir.lib.runtime}">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
</path>
I can't put if/unless clauses on the include elements because they're not
the part that's at issue; ${dir.lib.runtime} may point anywhere and be
absolute or relative, so I can't pick a parent directory that's known to
exist, for use with a DirSet; and I can't use DD's solution, using multiple
property definitions, because I can't guarantee that the includes won't
match something they shouldn't (I can't make assumptions about the directory
structure of the project being built).
The only solution I can think of is to split the path element into a set of
targets, something like:
<target name="set-classpath.lib.runtime"
depends="check-classpath.lig.runtime,
do-set-classpath.lib.runtime,
default-classpath.lib.runtime"/>
<target name="check-classpath.lib.runtime">
<available type="dir" file="${dir.lib.runtime}" property="exists"/>
</target>
<target name="do-set-classpath.lib.runtime" if="exists">
<path id="classpath.lib.runtime">
<!-- Libraries required at run-time -->
<fileset dir="${dir.lib.runtime}">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
</path>
</target>
<target name="default-classpath.lib.runtime" unless="exists">
<path id="classpath.lib.runtime"/>
</target>
Appart from the obvious disadvantage of how verbose this is, it has the
disadvantage that build files must change to add a reference to the
set-classpath.lib.runtime task. I'm also not sure you can define an empty
path in default-classpath.lib.runtime.
Can anyone think of a way to do this that�s robust?
L.
On 8/27/02 1:35 PM, "Nolan Ring" <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> The following is the classpath for my javac task. The problem I'm having is
> that the nightlyBuildDir directory, which is defined in a global.properties
> file, may or may not exist. If it does exist, I want its contents to be
> included in the classpath; if it doesn't exist I want it to be skipped.
> Right now, if ${nightlyBuildDir} doesn't exist my build fails.
>
> Is there some way to conditionally set include fileset based on whether or
> not ${nightlyBuildDir} exists? I thought, at first, that <available> might
> work, but don't want to run the entire target conditionally - just set this
> piece of the classpath.
>
> <classpath>
> <pathelement path="${classpath}"/>
> <pathelement path="${classesDir}"/>
> <fileset dir="${distDir}">
> <include name="**/*.jar"/>
> <include name="**/*.zip"/>
> <exclude name="${jarName}"/>
> </fileset>
> <fileset dir="${nightlyBuildDir}">
> <include name="**/*.jar" />
> <include name="**/*.zip" />
> <exclude name="${jarName}" />
> </fileset>
> <fileset dir="${libDir}">
> <include name="**/*.jar"/>
> </fileset>
> </classpath>
>
> Thanks much.
>
> Nolan Ring
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>