You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Robert Nicholson <ro...@elastica.com> on 2001/05/16 06:57:38 UTC

How are relative paths resolved?

Consider the two sets of rules

<target name="customerejbjar" depends="init">
    <property name="customer.buildjardir"
value="${customer.home}/build/ejbjar"/>
    <mkdir dir="${customer.buildjardir}/META-INF"/>
    <copydir src="${customer.classbindir}" dest="${customer.buildjardir}" />
    <copydir src="${util.classbindir}" dest="${customer.buildjardir}" />
    <copyfile src="customer_ejb.xml"
dest="${customer.buildjardir}/META-INF/ejb-jar.xml" />
    <copyfile src="weblogic-ejb-jar.xml"
dest="${customer.buildjardir}/META-INF/weblogic-ejb-jar.xml" />
    <delete file="${customer.ejbjar}"/>
    <jar jarfile="${customer.ejbjar}" basedir="${customer.buildjardir}"/>
    <deltree dir="${customer.buildjardir}"/>
  </target>

  <target name="ejbc" depends="init">
  	<java classname="weblogic.ejbc" fork="no"
classpath="${weblogic.classpath}" args="-compiler javac ${customer.ejbjar}
${customer.ejbcjar}"/>
  </target>

Note: when a relative path ie. a path with a .. is an attribute value above
it's
resolved to an absolute path. But in the second target where I'm using
${customer.ejbjar} it doesn't have the intelligence to resolve this to an
absolute rule consequently ant
chokes.

What's confusing to me is that if I involve this via an ant target
specifycing this build.xml it will not work but if my current directory is
the same as where this
bulid.xml is then it will find that relative path.

Very confused.

Executing Target: customerejbjar
Created dir: D:\Java\jps1.1.2\src\components\customer\build\ejbjar\META-INF
Copying 48 files to D:\Java\jps1.1.2\src\components\customer\build\ejbjar
Copying 1 files to D:\Java\jps1.1.2\src\components\customer\build\ejbjar
Deleting: D:\Java\jps1.1.2\src\components\customer\build\customerEjb.jar
Building jar: D:\Java\jps1.1.2\src\components\customer\build\customerEjb.jar
Deleting: D:\Java\jps1.1.2\src\components\customer\build\ejbjar
Executing Target: ejbc
ERROR: ejb-jar file: ../build/customerEjb.jar could not be opened.

You see. every rule resolves correctly to an absolute path except this
value.

I was trying to use the ant that ships with the Petstore rather than
configure up another version and have to configure the parser factory up.

...

So how exactly are paths resolved in Ant or am I clutching at straws here?


Re: How are relative paths resolved?

Posted by Peter Donald <do...@apache.org>.
At 09:57  15/5/01 -0700, Robert Nicholson wrote:
>ERROR: ejb-jar file: ../build/customerEjb.jar could not be opened.
>
>You see. every rule resolves correctly to an absolute path except this
>value.
>
>I was trying to use the ant that ships with the Petstore rather than
>configure up another version and have to configure the parser factory up.

I would recomend getting latest version - basically for the bugfixes.

>So how exactly are paths resolved in Ant or am I clutching at straws here?

Well the only time Files are resolved is when they are attributes of tasks.
In which case they are resolved agains project directory.

In the above example you are substituting a property into a string which
means value is not resolved at all. To fix it download latest ant and look
in the documentation for property task (namely at the location attribute).



Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*