use of org.apache.ivy.osgi.core.BundleInfo in project ant-ivy by apache.
the class BundleRepoDescriptor method populate.
public void populate(Iterator<ManifestAndLocation> it) {
while (it.hasNext()) {
ManifestAndLocation manifestAndLocation = it.next();
try {
BundleInfo bundleInfo = ManifestParser.parseManifest(manifestAndLocation.getManifest());
bundleInfo.addArtifact(new BundleArtifact(false, manifestAndLocation.getUri(), null));
addBundle(bundleInfo);
} catch (ParseException e) {
Message.error("Rejected " + manifestAndLocation.getUri() + ": " + e.getMessage());
}
}
}
use of org.apache.ivy.osgi.core.BundleInfo in project ant-ivy by apache.
the class IvyCachePath method addToPath.
protected void addToPath(Path path, File f) throws Exception {
if (!osgi || !f.isDirectory()) {
path.createPathElement().setLocation(f);
return;
}
File manifest = new File(f, "META-INF/MANIFEST.MF");
if (!manifest.exists()) {
path.createPathElement().setLocation(f);
return;
}
BundleInfo bundleInfo = ManifestParser.parseManifest(manifest);
List<String> cp = bundleInfo.getClasspath();
if (cp == null) {
path.createPathElement().setLocation(f);
return;
}
for (String p : cp) {
if (p.equals(".")) {
path.createPathElement().setLocation(f);
} else {
path.createPathElement().setLocation(new File(f, p));
}
}
}
use of org.apache.ivy.osgi.core.BundleInfo in project ant-ivy by apache.
the class ConvertManifestTask method doExecute.
public void doExecute() throws BuildException {
if (ivyFile == null) {
throw new BuildException("destination ivy file is required for convertmanifest task");
}
if (manifest == null) {
throw new BuildException("source manifest file is required for convertmanifest task");
}
if (profileProvider == null) {
try {
profileProvider = new ExecutionEnvironmentProfileProvider();
} catch (IOException e) {
throw new BuildException("Enable to load the default environment profiles", e);
}
}
Manifest m;
try {
m = new Manifest(new FileInputStream(manifest));
} catch (FileNotFoundException e) {
throw new BuildException("the manifest file '" + manifest + "' was not found", e);
} catch (IOException e) {
throw new BuildException("the manifest file '" + manifest + "' could not be read", e);
}
BundleInfo bundleInfo;
try {
bundleInfo = ManifestParser.parseManifest(m);
} catch (ParseException e) {
throw new BuildException("Incorrect manifest file '" + manifest + "'", e);
}
ModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(OSGiManifestParser.getInstance(), null, bundleInfo, m, profileProvider);
try {
XmlModuleDescriptorWriter.write(md, ivyFile);
} catch (IOException e) {
throw new BuildException("The ivyFile '" + ivyFile + "' could not be written", e);
}
}
Aggregations