Hello Ivy developers, FYI:
I'm trying to use Ivy 2.3.0 OSGi support on Windows to develop an Eclipse plugin and followed exactly the instructions of the sample "Building an Eclipse plugin" from the Ivy docs. I only changed the value of the module attribute in the ivy.xml from the sample (see attached ivy.xml). After calling ant task ivy:resolve for this ivy.xml on a Windows machine with JRE 6 the resolve failed with the following output: "Problem occurred while parsing ivy file: Unsupported repository, resources names are not uris in file:/C:/java/workspace/de.metalevel.eclipse.mlbuild/ivy.xml" The problem was that in method parseDescriptor of class OSGiManifestParser an URISyntaxException occured when constructing the URI to set for bundleInfo (line 67) because res.getName() returned C:\java\workspace\de.metalevel.eclipse.mlbuild\META-INF\MANIFEST.MF . I attached the output of svn diff for the changes I did in class OSGiManifestParser (SVN base revision was 1532780), see attachment OSGiManifestParser.diff. I also added a "quick and dirty" test to reproduce the problem to test class OSGiManifestParserTest, see attachment OSGiManifestParserTest.diff. After I did the change this test is successful. I also ran the whole test suite of unit tests for Ivy (ant task "test") and it was successful, so it seems my dirty fix did not break anything. This was my first contact with Ivy source code and I'm sure that there are more elegant ways to fix the problem, so I leave it to the experts to fix it right :-) Thanks to all Ivy developers for such a great tool! Greetings, Riccardo -- META-LEVEL Software AG Saarbrücker Str. 51 66130 Saarbrücken Deutschland Tel: +49 - 681 / 99687-0 Fax: +49 - 681 / 99687-99 Mail: i...@meta-level.de Web: www.meta-level.de Rechtsform: Aktiengesellschaft Sitz: Saarbrücken HR B Nr. 13 380 Amtsgericht Saarbrücken USt-IdNr. DE 1 38 166667 Vorstände: Dipl.-Inform. Peter Badt und Dipl.-Inform. Peter Raber Vorsitzender des Aufsichtsrats: Reinhard Kuhn
<?xml version="1.0"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <ivy-module version="2.2" xmlns:o="http://ant.apache.org/ivy/osgi"> <info organisation="bundle" module="mlbuild"> <extends organisation="bundle" module="de.metalevel.eclipse.mlbuild.ivyPDE" revision="1.0.0.qualifier" location="META-INF/MANIFEST.MF"/> </info> <configurations> <conf name="compile" extends="default,embedded" description="Dependencies for the compilation" /> <conf name="embedded" description="Dependencies embedded into the plugin's jar" /> <conf name="win32" extends="compile" description="To run on Microsoft Windows" /> <conf name="macos" extends="compile" description="To run on Mac OS X" /> <conf name="linux" extends="compile" description="To run on Linux" /> </configurations> <dependencies> <!-- example of a dependency that we can't declare in the MANIFEST.MF because we want it to be embedded --> <!--dependency osgi="bundle" org="" module="org.apache.commons.httpcore" rev="4.1.0" conf="embedded->default" /--> <!-- Ivy-Osgi doesn't understand bundle fragment --> <dependency org="bundle" name="org.eclipse.swt.win32.win32.x86" rev="3.+" conf="win32->default" /> <dependency org="bundle" name="org.eclipse.swt.cocoa.macosx.x86_64" rev="3.+" conf="macos->default" /> <dependency org="bundle" name="org.eclipse.swt.gtk.linux.x86" rev="3.+" conf="linux->default" /> </dependencies> </ivy-module>
Index: test/java/org/apache/ivy/osgi/core/OSGiManifestParserTest.java =================================================================== --- test/java/org/apache/ivy/osgi/core/OSGiManifestParserTest.java (revision 1532780) +++ test/java/org/apache/ivy/osgi/core/OSGiManifestParserTest.java (working copy) @@ -23,7 +23,9 @@ import org.apache.ivy.core.module.descriptor.Configuration; import org.apache.ivy.core.module.descriptor.ModuleDescriptor; import org.apache.ivy.core.settings.IvySettings; +import org.apache.ivy.core.settings.IvyVariableContainerImpl; import org.apache.ivy.plugins.parser.AbstractModuleDescriptorParserTester; +import org.apache.ivy.plugins.repository.file.FileResource; import org.apache.ivy.util.DefaultMessageLogger; import org.apache.ivy.util.Message; @@ -58,4 +60,23 @@ assertNotNull(md.getDependencies()); assertEquals(0, md.getDependencies().length); } + + public void testParseDescriptorWithWindowsPathToManifest() throws Exception { + // GIVEN + IvySettings ivySettings = new IvySettings(); + ivySettings.load(new File("C:/java/workspace/ivysettings.xml")); + File manifestFile = new File( + "C:/java/workspace/de.metalevel.eclipse.mlbuild/META-INF/MANIFEST.MF" + ); + // WHEN + FileResource res = new FileResource(null, manifestFile); + ModuleDescriptor md = OSGiManifestParser.getInstance().parseDescriptor( + ivySettings, manifestFile.toURL(), res, true); + + // THEN + assertNotNull(md); + assertEquals("bundle", md.getModuleRevisionId().getOrganisation()); + assertEquals("de.metalevel.eclipse.mlbuild.ivyPDE", md.getModuleRevisionId().getName()); + assertEquals("1.0.0.qualifier", md.getModuleRevisionId().getRevision()); + } }
Index: src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java =================================================================== --- src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java (revision 1532780) +++ src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java (working copy) @@ -63,8 +63,9 @@ Resource res, boolean validate) throws ParseException, IOException { Manifest m = new Manifest(res.openStream()); BundleInfo bundleInfo = ManifestParser.parseManifest(m); + URL url = new File(res.getName()).toURL(); try { - bundleInfo.setUri(new URI(res.getName())); + bundleInfo.setUri(new URI(url.toExternalForm())); } catch (URISyntaxException e) { throw new RuntimeException("Unsupported repository, resources names are not uris", e); }
--------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@ant.apache.org For additional commands, e-mail: dev-h...@ant.apache.org