Search in sources :

Example 1 with ExecutionEnvironmentProfileProvider

use of org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider 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

FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ParseException (java.text.ParseException)1 Manifest (java.util.jar.Manifest)1 ModuleDescriptor (org.apache.ivy.core.module.descriptor.ModuleDescriptor)1 BundleInfo (org.apache.ivy.osgi.core.BundleInfo)1 ExecutionEnvironmentProfileProvider (org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider)1 BuildException (org.apache.tools.ant.BuildException)1