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/26 09:46:25 UTC

Error building struts

Hi!

After building struts, directories "build" and "dist" would be created
under "jakarta-struts" as well the $jakarta_home. The reason for it is
the line in $jakarta-struts/build.xml

    <property name="build.dir"      value="../build/taglibs"/>
...
  <target name="jspspec">
    <ant dir="./jspspec" target="dist"/>
  </target>

However, the property cannot be replaced by the
$jakara-struts/jspspec/web.xml (with inner scope)

    <property name="build.dir"      value="../../build/taglibs"/>

Is there any fix for the current implementation of ant?

Thanks

Arion

--
[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

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

Posted by Arion Yu <ar...@stt.com.hk>.
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: Error building struts

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "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

Re: Error building struts

Posted by Arion Yu <ar...@stt.com.hk>.
Hi!

Sorry I haven't state my question clearly.

The problem is the property sevlet.jar. The parameter can be set from
the environment. The value may indicate a relative path (eg
"../jakarta-servletapi/lib/servlet.jar") or absolute path (eg
c:\servletapi\servlet.jar)

What I want to do is, for the first case:
<ant>
<property name="servlet.jar" value="../${servlet.jar}">
</ant>

and untoucth the value for the second case.

What should I do?

Arion

Stefan Bodewig wrote:

> >>>>> "AY" == Arion Yu <ar...@stt.com.hk> writes:
>
>  AY> Hi!  What should I do if the path maybe absolute?
>
> The dir attribute of the ant task or the value of the build.dir
> property? What is the problem you face?
>
> 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: Error building struts

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

 AY> Hi!  What should I do if the path maybe absolute?

The dir attribute of the ant task or the value of the build.dir
property? What is the problem you face?

Stefan

Re: Badly resolved files in Ant task

Posted by Peter Donald <do...@mad.scientist.com>.
At 05:02  26/7/00 +0200, you wrote:
>>>>>> "PD" == Peter Donald <do...@mad.scientist.com> writes:
>
> PD> <ant antfile="one.xml" dir="1.0"/>
>
> PD> resolves to "one.xml" not "1.0/one.xml".
>
>I think you are wrong here Pete. dir is a File not a String so the
>slash shouldn't matter (talking of the CVS version).

yup your right.

>The problem seems to persist with the latest CVS version though. I'm
>having another look.

Hmmm .... I was thinking basedir property is actually overidden when the
second one.xml is read - resetting the directory to "." most likely. Which
would make sense in single project but in two project set up where second
build file is another directory we have to have some way of making the
basedir specified in build.xml relative to the basedir supplied in Ant
task. Does that make sense ???
Cheers,

Pete

*------------------------------------------------------*
| "Nearly all men can stand adversity, but if you want |
| to test a man's character, give him power."          |
|       -Abraham Lincoln                               |
*------------------------------------------------------*

Re: Badly resolved files in Ant task

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "PD" == Peter Donald <do...@mad.scientist.com> writes:

 PD> <ant antfile="one.xml" dir="1.0"/>

 PD> resolves to "one.xml" not "1.0/one.xml".

I think you are wrong here Pete. dir is a File not a String so the
slash shouldn't matter (talking of the CVS version).

The problem seems to persist with the latest CVS version though. I'm
having another look.

Stefan

Badly resolved files in Ant task

Posted by Peter Donald <do...@mad.scientist.com>.
Hi,

There was just a report on users list of badly resolving names and dirs in
ant task. 


The problem is that

<ant antfile="one.xml" dir="1.0"/>

resolves to "one.xml" not "1.0/one.xml". The reason is that on line 179 of
Ant.java you use "new File(dir, antFile)" which because dir doesn't end
with a file seperator doesn't resolve properly. To fix check if dir ends in
a seperator and if not add one. (Alternatively you could fix it the same
way I said a while back re fixing similar case in Javadoc task)



Cheers,

Pete

*------------------------------------------------------*
| "Nearly all men can stand adversity, but if you want |
| to test a man's character, give him power."          |
|       -Abraham Lincoln                               |
*------------------------------------------------------*

Re: Error building struts

Posted by Arion Yu <ar...@stt.com.hk>.
Hi!

What should I do if the path maybe absolute? How can I distinguish
between the two and write the appropriate thing?

Thanks

Arion

Stefan Bodewig wrote:

> >>>>> "AY" == Arion Yu <ar...@stt.com.hk> writes:
>
>  AY> Is there any fix for the current implementation of ant?
>
> Try
>
> <target name="jspspec">
>   <ant dir="./jspspec" target="dist">
>     <property name="build.dir" value="../../build/taglibs"/>
>   </ant>
> </target>
>
> Does this work?
>
> 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: Error building struts

Posted by Arion Yu <ar...@stt.com.hk>.
Hi!

Yes, it works. Thank you.

Arion

Stefan Bodewig wrote:

> >>>>> "AY" == Arion Yu <ar...@stt.com.hk> writes:
>
>  AY> Is there any fix for the current implementation of ant?
>
> Try
>
> <target name="jspspec">
>   <ant dir="./jspspec" target="dist">
>     <property name="build.dir" value="../../build/taglibs"/>
>   </ant>
> </target>
>
> Does this work?
>
> 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: Error building struts

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

 AY> Is there any fix for the current implementation of ant?

Try

<target name="jspspec"> 
  <ant dir="./jspspec" target="dist">
    <property name="build.dir" value="../../build/taglibs"/>
  </ant>
</target>

Does this work?

Stefan