Author: hibou
Date: Sat May 3 16:22:05 2014
New Revision: 1592238
URL: http://svn.apache.org/r1592238
Log:
When parsing an OSGi MANIFEST, add its entries in the extra infos of the module
descriptor
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/ConvertManifestTask.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/ant/ConvertManifestTask.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/ant/ConvertManifestTask.java?rev=1592238&r1=1592237&r2=1592238&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/ant/ConvertManifestTask.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/ant/ConvertManifestTask.java Sat
May 3 16:22:05 2014
@@ -84,7 +84,7 @@ public class ConvertManifestTask extends
throw new BuildException("Incorrect manifest file '" + manifest +
"'", e);
}
ModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(
- OSGiManifestParser.getInstance(), null, bundleInfo,
profileProvider);
+ OSGiManifestParser.getInstance(), null, bundleInfo, m,
profileProvider);
try {
XmlModuleDescriptorWriter.write(md, ivyFile);
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java?rev=1592238&r1=1592237&r2=1592238&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/BundleInfoAdapter.java
Sat May 3 16:22:05 2014
@@ -27,7 +27,9 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
+import java.util.jar.Manifest;
import org.apache.ivy.Ivy;
import org.apache.ivy.core.module.descriptor.Artifact;
@@ -68,19 +70,21 @@ public class BundleInfoAdapter {
public static final String EXTRA_INFO_EXPORT_PREFIX = "_osgi_export_";
+ public static DefaultModuleDescriptor
toModuleDescriptor(ModuleDescriptorParser parser,
+ URI baseUri, BundleInfo bundle,
ExecutionEnvironmentProfileProvider profileProvider) {
+ return toModuleDescriptor(parser, baseUri, bundle, null,
profileProvider);
+ }
+
/**
*
* @param baseUri
* uri to help build the absolute url if the bundle info has a
relative uri.
- * @param bundle
- * @param profileProvider
- * @param parser
* @return
* @throws ProfileNotFoundException
*/
public static DefaultModuleDescriptor
toModuleDescriptor(ModuleDescriptorParser parser,
- URI baseUri, BundleInfo bundle,
ExecutionEnvironmentProfileProvider profileProvider)
- throws ProfileNotFoundException {
+ URI baseUri, BundleInfo bundle, Manifest manifest,
+ ExecutionEnvironmentProfileProvider profileProvider) throws
ProfileNotFoundException {
DefaultModuleDescriptor md = new DefaultModuleDescriptor(parser, null);
md.addExtraAttributeNamespace("o", Ivy.getIvyHomeURL() + "osgi");
ModuleRevisionId mrid = asMrid(BundleInfo.BUNDLE_TYPE,
bundle.getSymbolicName(),
@@ -160,6 +164,12 @@ public class BundleInfoAdapter {
}
}
+ if (manifest != null) {
+ for (Entry<Object, Object> entries :
manifest.getMainAttributes().entrySet()) {
+ md.addExtraInfo(entries.getKey().toString(),
entries.getValue().toString());
+ }
+ }
+
return md;
}
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java?rev=1592238&r1=1592237&r2=1592238&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/osgi/core/OSGiManifestParser.java
Sat May 3 16:22:05 2014
@@ -69,7 +69,7 @@ public class OSGiManifestParser implemen
} catch (URISyntaxException e) {
throw new RuntimeException("Unsupported repository, resources
names are not uris", e);
}
- return BundleInfoAdapter.toModuleDescriptor(this, null, bundleInfo,
profileProvider);
+ return BundleInfoAdapter.toModuleDescriptor(this, null, bundleInfo, m,
profileProvider);
}
public void toIvyFile(InputStream is, Resource res, File destFile,
ModuleDescriptor md)
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java?rev=1592238&r1=1592237&r2=1592238&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
Sat May 3 16:22:05 2014
@@ -561,6 +561,8 @@ public class XmlModuleDescriptorParser e
Namespace parentNamespace = ((DefaultModuleDescriptor)
parent).getNamespace();
descriptor.setNamespace(parentNamespace);
}
+
+ descriptor.getExtraInfo().putAll(parent.getExtraInfo());
}
private static String mergeRevisionValue(String inherited, String
override) {
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java?rev=1592238&r1=1592237&r2=1592238&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
(original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/osgi/obr/OBRResolverTest.java
Sat May 3 16:22:05 2014
@@ -25,6 +25,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.jar.JarInputStream;
+import java.util.jar.Manifest;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
@@ -294,9 +295,9 @@ public class OBRResolverTest extends Tes
private void genericTestResolve(String jarName, String conf,
ModuleRevisionId[] expectedMrids,
ModuleRevisionId[] expected2Mrids) throws Exception {
- JarInputStream in = new JarInputStream(new
FileInputStream("test/test-repo/bundlerepo/"
- + jarName));
- BundleInfo bundleInfo = ManifestParser.parseManifest(in.getManifest());
+ Manifest manifest = new JarInputStream(new
FileInputStream("test/test-repo/bundlerepo/"
+ + jarName)).getManifest();
+ BundleInfo bundleInfo = ManifestParser.parseManifest(manifest);
bundleInfo.addArtifact(new BundleArtifact(false, new
File("test/test-repo/bundlerepo/"
+ jarName).toURI(), null));
DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(
@@ -326,13 +327,13 @@ public class OBRResolverTest extends Tes
}
private void genericTestFailingResolve(String jarName, String conf) throws
Exception {
- JarInputStream in = new JarInputStream(new
FileInputStream("test/test-repo/bundlerepo/"
- + jarName));
- BundleInfo bundleInfo = ManifestParser.parseManifest(in.getManifest());
+ Manifest manifest = new JarInputStream(new
FileInputStream("test/test-repo/bundlerepo/"
+ + jarName)).getManifest();
+ BundleInfo bundleInfo = ManifestParser.parseManifest(manifest);
bundleInfo.addArtifact(new BundleArtifact(false, new
File("test/test-repo/bundlerepo/"
+ jarName).toURI(), null));
DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(
- OSGiManifestParser.getInstance(), null, bundleInfo,
profileProvider);
+ OSGiManifestParser.getInstance(), null, bundleInfo, manifest,
profileProvider);
ResolveReport resolveReport = ivy.resolve(md,
new ResolveOptions().setConfs(new String[]
{conf}).setOutputReport(false));
assertTrue(resolveReport.hasError());