You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Arion Yu <ar...@stt.com.hk> on 2000/07/31 09:49:23 UTC

Finding the absolute path from relative (was Re: Error building struts)

Hi!

Is there anyway to resolve the $servlet.jar from absolute/relative to
absolute?

Should the classpath be separated with : (Unix style) or ; (Windows style)
or both are acceptable?

For the second approach, would ./ do the same work as sub/../ ?

Thanks

Arion

Stefan Bodewig wrote:

> >>>>> "AY" == Arion Yu <ar...@stt.com.hk> writes:
>
>  AY> The problem is the property sevlet.jar. The parameter can be set
>  AY> from the environment. The value may indicate a relative path (eg
>  AY> "../jakarta-servletapi/lib/servlet.jar") or absolute path (eg
>  AY> c:\servletapi\servlet.jar)
>
>  AY> What I want to do is, for the first case:
>  AY> <ant>
>  AY>   <property name="servlet.jar" value="../${servlet.jar}">
>  AY> </ant>
>
>  AY> and untoucth the value for the second case.
>
>  AY> What should I do?
>
> I'm afraid there is no easy solution that will always work. If the
> property is only going to be used in CLASSPATH constructs, you could
> just simply say
>
> <ant>
>   <property name="servlet.jar" value="../${servlet.jar}:${servlet.jar}">
> </ant>
>
> the non existing part is going to be thrown out by javac, java or
> whatever you are going to use.
>
> A more general - and more ugly - solution would be
>
> <target name="check">
>   <available property="is.relative" file="sub/../${servlet.jar}" />
> </target>
>
> <target name="subrelative" depends="check" if="is.relative">
>   <ant>
>     <property name="servlet.jar" value="../${servlet.jar}">
>   </ant>
> </target>
>
> <target name="subabsolute" depends="check" unless="is.relative">
>   <ant>
> </target>
>
> <target name="sub" depends="subrelative,subabsolute" />
>
> Stefan

--
[This email and any files transmitted with it are confidential and may
contain information that is legally privileged. They are intended solely for
the addressee(s). Access to this email by anyone else is unauthorized. If
you are not the intended recipient, please delete it and notify the sender
by email immediately; you should not copy or use it for any purpose, nor
disclose its contents to any other person. Thank you.]



Re: Finding the absolute path from relative (was Re: Error building struts)

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "AY" == Arion Yu <ar...@stt.com.hk> writes:

 AY> Is there anyway to resolve the $servlet.jar from
 AY> absolute/relative to absolute?

Project.resolveFile() would do, if you code it up in Java. I don't see
any other way right now.

 AY> Should the classpath be separated with : (Unix style) or ;
 AY> (Windows style) or both are acceptable?

Whatever you prefer.

 AY> For the second approach, would ./ do the same work as sub/../ ?

I think it would. Try it 8^)

Stefan