Search in sources :

Example 11 with BundleInfo

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());
        }
    }
}
Also used : BundleInfo(org.apache.ivy.osgi.core.BundleInfo) BundleArtifact(org.apache.ivy.osgi.core.BundleArtifact) ParseException(java.text.ParseException)

Example 12 with BundleInfo

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));
        }
    }
}
Also used : BundleInfo(org.apache.ivy.osgi.core.BundleInfo) File(java.io.File)

Example 13 with BundleInfo

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);
    }
}
Also used : ModuleDescriptor(org.apache.ivy.core.module.descriptor.ModuleDescriptor) BundleInfo(org.apache.ivy.osgi.core.BundleInfo) FileNotFoundException(java.io.FileNotFoundException) BuildException(org.apache.tools.ant.BuildException) ExecutionEnvironmentProfileProvider(org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider) IOException(java.io.IOException) ParseException(java.text.ParseException) Manifest(java.util.jar.Manifest) FileInputStream(java.io.FileInputStream)

Aggregations

BundleInfo (org.apache.ivy.osgi.core.BundleInfo)13 BundleArtifact (org.apache.ivy.osgi.core.BundleArtifact)9 File (java.io.File)4 FileInputStream (java.io.FileInputStream)4 URI (java.net.URI)3 ParseException (java.text.ParseException)3 Manifest (java.util.jar.Manifest)3 ModuleDescriptorWrapper (org.apache.ivy.osgi.repo.ModuleDescriptorWrapper)3 Version (org.apache.ivy.osgi.util.Version)3 JarInputStream (java.util.jar.JarInputStream)2 Artifact (org.apache.ivy.core.module.descriptor.Artifact)2 DefaultModuleDescriptor (org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor)2 ResolveReport (org.apache.ivy.core.report.ResolveReport)2 ResolveOptions (org.apache.ivy.core.resolve.ResolveOptions)2 AttributesImpl (org.xml.sax.helpers.AttributesImpl)2 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1