com.tibco.bw.maven.plugin.osgi.helpers.ManifestParser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bw6-maven-plugin Show documentation
Show all versions of bw6-maven-plugin Show documentation
Plugin Code for Apache Maven and TIBCO BusinessWorks™.
This is the Maven Plugin for BW6 and BWCE Build.
package com.tibco.bw.maven.plugin.osgi.helpers;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
import com.tibco.bw.maven.plugin.utils.Constants;
public class ManifestParser {
public static Manifest parseManifest(File baseDir) {
Manifest mf = null;
File mfile = new File(baseDir , "META-INF/MANIFEST.MF");
if(mfile.exists())
{
InputStream is = null;
try {
is = new FileInputStream(mfile);
mf = new Manifest(is);
} catch(FileNotFoundException f) {
f.printStackTrace();
} catch(IOException e) {
e.printStackTrace();
} finally {
try {
if(is != null) {
is.close();
}
} catch(IOException e) {
e.printStackTrace();
}
}
}
return mf;
}
public static Manifest parseManifestFromJAR(File jarFile)
{
Manifest moduleManifest = null;
try
{
JarInputStream jarStream = new JarInputStream( new FileInputStream( jarFile ));
moduleManifest = jarStream.getManifest();
jarStream.close();
}
catch( Exception e )
{
e.printStackTrace();
}
return moduleManifest;
}
public static String getUpdatedProvideCapabilities(Manifest manifest, String oldVersion){
String updatedProvidesCapabilities = ""; //$NON-NLS-1$
Version versionObject = VersionParser.parseVersion(oldVersion);
String newVersion = versionObject.getMajor() + "." + versionObject.getMinor() + "." + versionObject.getMicro();
if(manifest != null){
String capabilities = manifest.getMainAttributes().getValue(Constants.BUNDLE_PROVIDE_CAPABILITY);
if(capabilities != null && !capabilities.isEmpty()){
String[] entries = capabilities.split(",");
boolean updated = false;
for(int i = 0; i
© 2015 - 2024 Weber Informatics LLC | Privacy Policy