Hello, I have found a strange behaviour of <manifestclasspath>, a new task of Ant 1.7.

This is the scenario, 2 directories containing the following files:

C:\Test\MyProject\
   app.jar
   build.xml
   file1.jar

C:\Test\MyProject\lib\
   file2.jar

(size and content of jars doesn't matter for this test)

The build.xml contains this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="Manifest classpath test">
  <path id="initial.path">
    <pathelement location="${basedir}/file1.jar"/>
    <pathelement location="${basedir}/lib/file2.jar"/>
    <pathelement location="${basedir}"/>
  </path>

  <property name="path.string" refid="initial.path"/>
  <echo message="initial.path = ${path.string}"/>

<manifestclasspath property="manifest.classpath" jarfile="${basedir}/app.jar">
    <classpath refid="initial.path"/>
  </manifestclasspath>

  <echo message="manifest.classpath = ${manifest.classpath}"/>
</project>


The execution:
- - - - - - - - - - - - - - - - - - -
C:\Test\MyProject>ant
Buildfile: build.xml
[echo] initial.path = C:\Test\MyProject\file1.jar;C:\Test\MyProject\lib\file2.jar;C:\Test\MyProject
     [echo] manifest.classpath = file1.jar lib/file2.jar ../MyProject/

BUILD SUCCESSFUL
Total time: 0 seconds
- - - - - - - - - - - - - - - - - - -

The three relative paths generated by <manifestclasspath> are all technically correct. But the last is very little useful!!
It's not useful and not practical to go "up" and then go "down" in MyProject.
According to me, the relative path should be generated as . or ./ since it's the most logical.


But there is another thing more strange. Instead to put MyProject in C:\Test, try to put it in C:\ (move MyProject in C:\).

- - - - - - - - - - - - - - - - - - -
C:\MyProject>ant
Buildfile: build.xml
[echo] initial.path = C:\MyProject\file1.jar;C:\MyProject\lib\file2.jar;C:\MyProject

BUILD FAILED
java.lang.NullPointerException
        at java.lang.String.startsWith(String.java:1422)
        at java.lang.String.startsWith(String.java:1451)
at org.apache.tools.ant.taskdefs.ManifestClassPath.execute(ManifestClassPath.java:100) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        ....more....
- - - - - - - - - - - - - - - - - - -

Tested on various Windows 2000 machines with

Apache Ant version 1.7.1 compiled on June 27 2008

and

java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Client VM (build 10.0-b23, mixed mode, sharing)


IMHO, it's a bug this last exception but also the go up and down in the path ../MyProject/ of the first test.
Do you agree?


Andrea - Software/Web Developer
SCJP 5 (91%)

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to