You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2011/03/21 13:53:58 UTC
DO NOT REPLY [Bug 50953] New: Tasks defined with an antlib within a
jar in succeeds with Ant 1.7.1 and fails with 1.8.2
https://issues.apache.org/bugzilla/show_bug.cgi?id=50953
Summary: Tasks defined with an antlib within a jar in succeeds
with Ant 1.7.1 and fails with 1.8.2
Product: Ant
Version: 1.8.2
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: normal
Priority: P2
Component: Core
AssignedTo: notifications@ant.apache.org
ReportedBy: antuser@mindspring.com
Here is the project build.xml:
<?xml version="1.0" encoding="utf-8"?>
<project name="build" default="all" xmlns:test="antlib:com.test.tools.ant">
<typedef resource="com/test/tools/ant/extensions.xml" />
<typedef uri="antlib:com.test.tools.ant"
resource="com/test/tools/ant/extensions.xml"/>
<test:importProjectDefinition/>
<echo message="${test}"/>
</project>
Here is a properties file to be imported that resides in the same directory as
the build.xml. It contains:
<project name="properties">
<property name="test" value="test_value"/>
</project>
test.jar contains an antlib in extensions.xml:
<?xml version="1.0"?>
<antlib xmlns:current="ant:current" xmlns:test="antlib:com.test.tools.ant">
<macrodef name="importProjectDefinition">
<sequential>
<import file="${basedir}\properties.xml" />
</sequential>
</macrodef>
</antlib>
When you build on Windows the project fails with the following traceback when
attempting the import. The import only fails when the antlib is inside of a
jar. In the debugger it appears that the file in the jar does not exist and
the code then tests for a URL
(C:\EclipseDevelopment\test_4_head\test_case\script/properties.xml) which of
course would be malformed as a URL. The same build fails on linux with a
similar traceback. Here is the relevant section of the Windows log:
[import] java.net.MalformedURLException: unknown protocol: c
BUILD FAILED
C:\EclipseDevelopment\test_4_head\test_case\script\build.xml:5: The following
error occurred while executing this line:
jar:file:/C:/EclipseDevelopment/test_4_head/eclipse.proxy.project/output/build/test/4.0/staging/ant/lib/test.jar!/com/
test/tools/ant/extensions.xml:5: failed to resolve
C:\EclipseDevelopment\test_4_head\test_case\script\properties.xml relative to
jar:file:/C:/EclipseDevelopment/test_4_head/eclipse.proxy.project/output/build/test/4.0/staging/ant/lib/test.jar!/com/test/tools/ant/extensions.xml
at
org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHelper.java:551)
at
org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:401)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
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:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at
org.apache.tools.ant.helper.ProjectHelper2.parse(ProjectHelper2.java:180)
at
org.eclipse.ant.internal.launching.remote.InternalAntRunner.parseBuildFile(InternalAntRunner.java:191)
at
org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:400)
at
org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:137)
Caused by:
jar:file:/C:/EclipseDevelopment/test_4_head/eclipse.proxy.project/output/build/test/4.0/staging/ant/lib/test.jar!/com/test/tools/ant/extensions.xml:5:
failed to resolve
C:\EclipseDevelopment\test_4_head\test_case\script\properties.xml relative to
jar:file:/C:/EclipseDevelopment/test_4_head/eclipse.proxy.project/output/build/test/4.0/staging/ant/lib/test.jar!/com/test/tools/ant/extensions.xml
at
org.apache.tools.ant.taskdefs.ImportTask.getFileAttributeResource(ImportTask.java:262)
at org.apache.tools.ant.taskdefs.ImportTask.execute(ImportTask.java:158)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
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:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
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:585)
at
org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at
org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:398)
... 12 more
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
[Bug 50953] Tasks defined with an antlib within a jar in succeeds
with Ant 1.7.1 and fails with 1.8.2
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50953
Stefan Bodewig <bo...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |1.9.4
--- Comment #3 from Stefan Bodewig <bo...@apache.org> ---
fixed with svn revision 1554392
--
You are receiving this mail because:
You are the assignee for the bug.
[Bug 50953] Tasks defined with an antlib within a jar in succeeds
with Ant 1.7.1 and fails with 1.8.2
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50953
--- Comment #1 from Dekel Cohen <de...@gmail.com> ---
The reason for the bug is a change in ImportTask.java:
ImportTask.getFileAttributeResource was added:
* if (buildFile.exists()) - incorrectly added in ant 1.8.x
) This is the bug: buildFile extensions.xml is within a jar (so special !jar
path) --> FS api.exist() fails to find it --> import to properties.xml (the
importedFile) fails
* In 1.7.1 there is no check that buildfile exist, but rather a check that
importedFile exist:
File buildFileParent = new File(buildFile.getParent());
File importedFile = FILE_UTILS.resolveFile(buildFileParent, file);
...
if (!importedFile.exists()) {
--
You are receiving this mail because:
You are the assignee for the bug.
DO NOT REPLY [Bug 50953] Tasks defined with an antlib within a jar
in succeeds with Ant 1.7.1 and fails with 1.8.2
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50953
antuser@mindspring.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |regression
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
[Bug 50953] Tasks defined with an antlib within a jar in succeeds
with Ant 1.7.1 and fails with 1.8.2
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50953
--- Comment #2 from Stefan Bodewig <bo...@apache.org> ---
Ah, good catch.
The code is supposed to make sure we resolve an imported file relative to the
importing buildifle - which may come from a jar just like in this example.
What we are missing is a test whether the file to import is already specified
via an absolute path (or URI).
--
You are receiving this mail because:
You are the assignee for the bug.
DO NOT REPLY [Bug 50953] Tasks defined with an antlib within a jar
in succeeds with Ant 1.7.1 and fails with 1.8.2
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50953
antuser@mindspring.com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |antuser@mindspring.com
Platform|PC |All
OS/Version|Windows XP |All
--
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.