Community
Participate
Working Groups
I use the following heade in my build.xml file : <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE project [ <!ENTITY common SYSTEM "file:./common.xml"> ]> I use this to include a file common.xml that is located within the same directory as the build.xml file. This used to work until build M5.
Go to Run->External Tools->Configure and select the script you want to run. Click on edit. In the working directory option, select the desired location. That should solve your problem.
*** Bug 18817 has been marked as a duplicate of this bug. ***
*** Bug 18681 has been marked as a duplicate of this bug. ***
Hi, I tried the approach using the "External Tools" menu. I can now execute the Ant default target. :-) Unfortunately trying to add the the ant targets variable does not work, because the included .xml file cannot be found.
A Workaround ist to specify the ant target variable directly without using the menu.
Markus, just to make sure I follow what happened. You can now execute your script. The only problem is that if you try to use the External Tools UI to select a target that belongs to the other script, it is not available but you can workaround the problem by editing the command line manually. Is that correct? Moving to Platform UI for comments. If the above is true the suggestion is defer and investigate after 2.0.
I meant Platform UI - Sorry.
Hi, Actually when I'm trying to use the "Edit external Tools" UI, I can specify my ant target by entering directly "${ant_target:jar}" (that wasn't easy to find out). If I try to use the "Browse Variables" button and select the "Ant targets" to get the list of available targets for my build.xml file, I get the error message that the file ./common.xml cannot be found. This is the file my build.xml includes. It seems to me that actually the build.xml file has been parsed to find out the available target's but that at this point the working directory is not used.
*** Bug 19122 has been marked as a duplicate of this bug. ***
Rodrigo, is the failure to resolve the included path a UI or Core Ant problem?
Probably UI. It seems related to parsing the script to get the the target information.
Should consider for F3 since this is a regression from previous behaviour.
Marked for F3 since this is a regression.
Bumping up priority - this affects many people.
Markus, can you include the build.xml and common.xml you are using (or a simple example to reproduce this problem)?
Ryan changed ant build file parser to resolve correctly relative path by using the directory of the ant build file as the base directory. Checked by Simon and Tod
Sorry for the late reply. I was on vacation. actually all you need to reproduce the bug is the header I already specified and then a line to include the file : "&common". The solution described by Simon sounds to be correct. I will verify this as soon as I get the new build.
It works for me in F3. Thanks, Markus
Verified by Markus.
It still doesn't work if you don't include the protocol (which is a valid usage) e.g. <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE project [ <!ENTITY common SYSTEM "../common.xml"> ]>
Reopening problem report because of Matthew's comment above. Matthew, did you mean "../common.xml" or "./common.xml"? (note the dot count) What platform and build are you running on?
Either . or .. should fail depending on your setup - its the lack of the "file:" protocol that causes the failue, i.e. on my my machine its actually "../../Build/ant/common.xml", and fails unless I prefix with "file:" But to preserve the example it should be "." =) I'm running build F3 on Windows NT
Just to be accurate. Do you mean NT 4.0 or 2000? It works fine for me on Windows 2000 (without the file: prefix).
NT 4.0sp6 If I don't specify a protocol, when I "Run ant..." I get the error dialog: Problems reading Ant build file Reason: no protocol: ../../Build/ant/build-driver.xml But it does work ok when I run it through Run->External Tools
When you use Run Ant..., does it fail when the dialog opens, or when you hit Finish? When you use Run > External Tools dialog, select your ant file tool, edit it, select Browse Variables, and select Ant targets, does it fail? Are you using the ant.bat file? Is there a space in the complete path to your project or in your project name?
It fails before the dialog comes up. It also fails when trying to browse the ant targets in the External tools dialog. There are no spaces anywhere.
Forget to mention that I'm not using ant.bat, I was pointing ant to a 1.5beta2 ant jars, but I tried reverting to defaults, restarted workspace, but same problems
Just a comment from my side, regarding the problem with the missing "file:" protocol. I think I have had problems with this before I used Eclipse. It might therefore be a problem that has nothing to do with Eclipse. As far as I can remember I tried different XML Parsers and got different results when trying to include .xml files.
From my limited knowledge of XML, I do recall reading the spec on entities in which they refered to the system id as being in a URI format. Nevertheless, on Windows 2000, we can use a relative path like "../../somefile.xml" and it works for us. The only difference I see so far is your using NT. If we can't reproduce here, would you be willing to assist in debugging this from your end today?
Sure - just tell me where to set my breakpoints
A good start would be to set a breakpoint in AntUtil.getTargetList(IPath). public static AntTargetList getTargetList(IPath path) throws CoreException { IMemento memento = getMemento(path); return getTargetList(memento); } The exception which causes the error dialog to pop up should be coming from somwhere in here. First, find out if it's coming from getMemento(IPath) or getTargetList(IMemento). Then, step through whichever method it is coming from to find out exactly what line is causing it (feel free to step through methods being called inside these methods as well, to whatever depth you think is appropriate). This will give us a hint on what the problem might be, and we can decide what to do once we know a bit more.
Well, I found where and why an exception is getting thrown - no idea why it doesn't happen for you. AntUtil.AntEntityResolver.resolveEntity doesn't resolve any entities that don't begin with "file:", and instead returns null to allow the xml parser to do the default processing. Thus, one level up the stack from this call, org.apache.crimson.parser.ExternalEntity.getInputSource(org.xml.sax.EntityResolver) line: 92) does a "new URL(filename) which throws a MalformedURLException. You could probably fix this by handling it in your entity resolver. Not sure why the parser doesn't do something more intelligent - it might if in org.eclipse.ui.externaltools.internal.core.AntUtil.createReadRoot, line: 85, you constructed an InputSource like so: InputSource(reader, basedir) - this would then use basedir for resolving relative URLs Hope this helps, let me know if I can do anything else BTW, is there an easy way to have all the platform jars/source available when debugging a runtime workbench?
Forgot to mention, here are the files I'm using if you want to try and duplicate the problem again. Both should be in the same directory. build.xml: <!DOCTYPE project [ <!ENTITY common SYSTEM "common.xml"> ]> <project name="bug" default="all"> <target name="all" depends="hello"> <echo message="In All"/> </target> &common; </project> common.xml: <target name="hello"> <echo message="Hello world!"/> </target>
Matthew, 2 questions: 1) What VM are you using? 2) Are you using xerces shipped with Eclipse or another version (just check the Ant classpath in Window->Preferences->External Tools->Ant)?
Matthew, thanks for looking into this. In AntUtil, line 85 we construct the InputSource. You suggest passing the baseDir as a parameter - in my version of InputSource there is no two parameter constructor. If you look at line 86, we do set the baseDir for the InputSource (using setSystemId())...do you see that call in the code?
> java -version java version "1.4.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92) Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode) Ant Preferences shows that I'm using the xerces shipped with eclipse
Sorry, yes, was just working on some JDOM code which has a build(reader, basePath) method, so I guess I was thinking of that - you are doing the correct thing in your code by using setSystemId
Simon, could you test against JDK 1.4? Any possibility it could be a conflict between XML parsers? (sorry if this is a bogus question)
Actually, I think it is using the parser from jdk 1.4 - Or at least the classes it is using are coming from the 1.4 rt.jar (as shown in java package explorer when I switch to java perspective after debugging) I guess I should have guessed from the package name - org.apache.crimson is the parser that comes with the jdk, xerces is org.apache.xerces
So maybe we should handle it (dealing with relative paths) in our EntityResolver implementation and not leaving the job for the default implementation.
We could do that, but it would only fix the UI portion. Matthew, I'm assuming if you do Run > External Tools > <<your xml file>>, it fails also? During the run, we do not open the XML file at the UI level, therefore we do not go thru our entity resolver. If it fails during run, then Ant runner has the same problem? Matthew, if it does fail, can you put a break point in AntFileRunner.execute method and see if the error is the same?
Actually, if I do Run > External Tools > <<your xml file>>, it works just fine. Its just the UI parsing of the ant build file that is broken.
We will not be fixing this problem for release 2.0 (it's too late). The workaround is to use the "file:" protocol. This problem will be fixed post 2.0 (see bug 20819).
Reopening to change resolution to LATER instead of WONTFIX.
Change resolution to LATER instead of WONTFIX.
reopened for investigation
This is fixed in the 2.0.1 code stream (see bug 20819). The report (bug 22273) was created to port the fix to the 2.1 code stream.