private void updateManifest(String symbolicName, String classPath, String bundleActivator) throws IOException { try (FileInputStream manifestInputStream = new FileInputStream(manifestLocation)) { Manifest manifest = new Manifest(manifestInputStream); Attributes mainAttributes = manifest.getMainAttributes(); if (mainAttributes.containsKey(new Attributes.Name(BUNDLE_SYMBOLICNAME))) { descriptor.markAsInvalid(Arrays.asList("Plugin JAR is invalid. MANIFEST.MF already contains header: " + BUNDLE_SYMBOLICNAME), null); return; } mainAttributes.put(new Attributes.Name(BUNDLE_SYMBOLICNAME), symbolicName); mainAttributes.put(new Attributes.Name(BUNDLE_CLASSPATH), classPath); mainAttributes.put(new Attributes.Name(BUNDLE_ACTIVATOR), bundleActivator); descriptor.updateBundleInformation(symbolicName, classPath, bundleActivator); try (FileOutputStream manifestOutputStream = new FileOutputStream(manifestLocation)) { manifest.write(manifestOutputStream); } } }
if (temp != null && temp.containsKey("hidden")) { return;
public ExistingAttribute getAttribute( String attributeName ) { Attributes.Name name = new Attributes.Name( attributeName ); return backingAttributes.containsKey( name ) ? new ExistingAttribute( backingAttributes, attributeName ) : null; }
private boolean isJavaCapabilityRequired(Attributes main) { return main.containsKey(Bundle_RequiredExecutionEnvironment) || main.containsKey(Require_Capability); }
Attributes mainAtts = mf.getMainAttributes(); if(mainAtts.containsKey(Attributes.Name.MAIN_CLASS)){ String mainClass = mainAtts.getValue(Attributes.Name.MAIN_CLASS); System.out.println(mainClass); String mainVer = mainAtts.getValue(Attributes.Name.IMPLEMENTATION_VERSION); System.out.println(mainVer); }
public static String getAdapterVersion(File jarFile) throws IOException { String version = null; JarFile jar = new JarFile(jarFile); Attributes attributes = jar.getManifest().getMainAttributes(); if (attributes.containsKey(ATTR_MODULE_IMPLEMENTATION)) { version = attributes.getValue(ATTR_MODULE_IMPLEMENTATION); } jar.close(); return version; }
public static String getAdapterAlias(File jarFile) throws IOException { String version = null; JarFile jar = new JarFile(jarFile); Attributes attributes = jar.getManifest().getMainAttributes(); if (attributes.containsKey(ATTR_MODULE_ALIAS)) { version = attributes.getValue(ATTR_MODULE_ALIAS); } jar.close(); return version; }
private boolean isJarLiblet(String path) { try { JarFile jar = new JarFile(path); Attributes manifestAttributes = jar.getManifest().getMainAttributes(); return manifestAttributes.containsKey(new Attributes.Name("LIBlet-Name")); //NOI18N } catch (IOException ex) { Logger.getLogger(ExtractTask.class.getName()).log(Level.SEVERE, null, ex); } return false; } }
private boolean manifestDoesntHaveRequiredOsgiHeader(final Manifest mf, final Entry<String, String> entry) { if (mf.getMainAttributes().containsKey(new Attributes.Name(entry.getKey()))) { return !entry.getValue().equals(mf.getMainAttributes().getValue(entry.getKey())); } return true; }
/** * {@inheritDoc} Triggers lazy-loading of the manifest. */ public boolean hasValue(String key) { return loadManifest() && manifest.getMainAttributes().containsKey(key); }
/** * {@inheritDoc} Triggers lazy-loading of the manifest. */ public boolean hasValue(String key) { return loadManifest() && manifest.getMainAttributes().containsKey(key); }
public static boolean isBundle(Manifest manifest) { if (manifest != null) { Attributes attributes = manifest.getMainAttributes(); return attributes.containsKey(new Attributes.Name(Constants.BUNDLE_SYMBOLICNAME)) && attributes.containsKey(new Attributes.Name(Constants.BUNDLE_VERSION)); } return false; }
InputStream transform(InputStream inputStream) throws MojoExecutionException { try (InputStream in = inputStream) { // No need for new variable in Java 9. Manifest manifest = new Manifest(in); Attributes attributes = manifest.getMainAttributes(); if (!attributes.containsKey(PREMAIN_CLASS)) { throw new MojoExecutionException(PREMAIN_CLASS + " not found in MANIFEST.MF. This is a bug in promagent-maven-plugin."); } attributes.put(CREATED_BY, pluginArtifactId + ":" + pluginVersion); ByteArrayOutputStream out = new ByteArrayOutputStream(); manifest.write(out); return new ByteArrayInputStream(out.toByteArray()); } catch (IOException e) { throw new MojoExecutionException("Failed to transform MANIFEST.MF: " + e.getMessage(), e); } }
private static boolean isValidBundle(Manifest manifest) { Attributes atts = manifest.getMainAttributes(); return atts.containsKey(new Attributes.Name(Constants.BUNDLE_MANIFESTVERSION)); }
public void checkDependantClasses(List<String> dependantClasses, String manifestName) throws IOException { try { for (String dependantClass : dependantClasses) { Class.forName(dependantClass); } } catch (ClassNotFoundException e) { Manifest mf = new Manifest(getClass().getResourceAsStream("/META-INF/" + manifestName)); Attributes mainAttributes = mf.getMainAttributes(); String name = mainAttributes.get(Attributes.Name.IMPLEMENTATION_TITLE).toString(); if (mainAttributes.containsKey(Attributes.Name.CLASS_PATH)) { String classPathJARs = mainAttributes.get(Attributes.Name.CLASS_PATH).toString(); String message = "%nEnsure these JARs are in the same directory as %s.jar:%n%s"; throw new IllegalStateException(format(message, name , classPathJARs), e); } else { String message = "Could not find the '%s' attribute in the manifest '%s'"; throw new IllegalStateException(format(message, Attributes.Name.CLASS_PATH, manifestName), e); } } } }
private void merge(Attributes target, Attributes source) { for (Object o : source.keySet()) { if (target.containsKey(o)) { String sep = mappings.containsKey(o.toString())?mappings.get(o.toString()):","; String newValue = target.get(o) + sep + source.get(o); target.put(o, newValue); } else { target.put(o, source.get(o)); } } }
private void merge(Attributes target, Attributes source) { for (Object o : source.keySet()) { if (target.containsKey(o)) { String sep = mappings.containsKey(o.toString())?mappings.get(o.toString()):","; String newValue = target.get(o) + sep + source.get(o); target.put(o, newValue); } else { target.put(o, source.get(o)); } } }
public ManifestAppletDefImpl(String descriptorName, ManifestModel manifest, String appletName) { super(descriptorName, manifest); this.appletName = appletName; Attributes mainAttributes = manifest.getMainAttributes(); String extensionListValue = (mainAttributes.containsKey(Name.EXTENSION_LIST) ? String.valueOf(mainAttributes .get(Name.EXTENSION_LIST)) + " " + appletName : appletName); manifest.getMainAttributes().put(Name.EXTENSION_LIST, extensionListValue); }
public ManifestAppletDefImpl(String descriptorName, ManifestModel manifest, String appletName) { super(descriptorName, manifest); this.appletName = appletName; Attributes mainAttributes = manifest.getMainAttributes(); String extensionListValue = (mainAttributes.containsKey(Name.EXTENSION_LIST) ? String.valueOf(mainAttributes .get(Name.EXTENSION_LIST)) + " " + appletName : appletName); manifest.getMainAttributes().put(Name.EXTENSION_LIST, extensionListValue); }
private void appendOriginalManifest(Manifest manifest, Attributes main) { if (originalManifest != null) { Attributes attributes = originalManifest.getMainAttributes(); for (Object key : attributes.keySet()) { if (!main.containsKey(key)) { main.put(key, attributes.get(key)); } else if (log != null) { Object oldValue = main.get(key); Object newValue = attributes.get(key); if(!Objects.equals(oldValue, newValue)) log.warning("manifest attribute provided by compiler: ignoring value from '"+key+"' for module '" + module.getNameAsString() +"'"); } } manifest.getEntries().putAll(originalManifest.getEntries()); } }