You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by andbin <ab...@cheapnet.it> on 2008/10/14 22:46:37 UTC
Strange behaviour of
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: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Strange behaviour of
Posted by Dominique Devienne <dd...@gmail.com>.
On Wed, Oct 15, 2008 at 1:47 PM, Dominique Devienne <dd...@gmail.com> wrote:
> As Stephan mentions [...]
Stefan, not Stephan. (sorry Stefan.) Time for coffee...
> Although your paths are "usual"
I meant "unusual" here of course. --DD
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Strange behaviour of
Posted by Dominique Devienne <dd...@gmail.com>.
On Tue, Oct 14, 2008 at 3:46 PM, andbin <ab...@cheapnet.it> wrote:
> <project name="Manifest classpath test">
> <path id="initial.path">
> <pathelement location="${basedir}/file1.jar"/>
> <pathelement location="${basedir}/lib/file2.jar"/>
> <pathelement location="${basedir}"/>
> </path>
FYI: use either file="${basedir}/..." or location="...", but using
both, while OK, doesn't make much sense to me. The purpose of all
location attributes is to resolve a relative path from ${basedir}, so
to me it's redundant to say location="${basedir}/..". No big deal
though.
> C:\Test\MyProject\file1.jar;C:\Test\MyProject\lib\file2.jar;C:\Test\MyProject
> [echo] manifest.classpath = file1.jar lib/file2.jar ../MyProject/
>
> The three relative paths generated by <manifestclasspath> are all
> technically correct. But the last is very little useful!!
More than "not-useful", it's wrong. The point of having relative paths
in the manifest is such that you can "transport" all the jars to
another dir and it continues working. Using ../Project/ works only in
a .../Project directory, so it's a bug.
I find it strange to put such a dir in the classpath, but that's
another story ;)
> According to me, the relative path should be generated as . or ./ since it's
> the most logical.
The spec says dirs must end in /, so only ./ is valid. I've never
tried such a combo though.
> 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)
As Stephan mentions, this is also clearly a bug. Escaped attention has
nobody typically puts jars or classes in the root directory ;-)
Although your paths are "usual", they have uncovered real bugs, albeit
minor ones few people will notice given a more traditional project
layout. --DD
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Strange behaviour of
Posted by Stefan Bodewig <bo...@apache.org>.
On Tue, 14 Oct 2008, andbin <ab...@cheapnet.it> wrote:
> [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/
as someone familiar with the code I can see why this happens, but it
won't help you (if C:\Test\MyProject in initial.path ended with a \ it
would most likely work as expected).
I agree the result is not desirable.
> 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)
This clearly is a bug, could you please file a bugzilla issue so we
don't loose track of it?
Thanks
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org