use of java.util.jar.Attributes in project android_frameworks_base by ResurrectionRemix.
the class StrictJarManifest method write.
/**
* Writes out the attribute information of the specified manifest to the
* specified {@code OutputStream}
*
* @param manifest
* the manifest to write out.
* @param out
* The {@code OutputStream} to write to.
* @throws IOException
* If an error occurs writing the {@code StrictJarManifest}.
*/
static void write(StrictJarManifest manifest, OutputStream out) throws IOException {
CharsetEncoder encoder = StandardCharsets.UTF_8.newEncoder();
ByteBuffer buffer = ByteBuffer.allocate(LINE_LENGTH_LIMIT);
Attributes.Name versionName = Attributes.Name.MANIFEST_VERSION;
String version = manifest.mainAttributes.getValue(versionName);
if (version == null) {
versionName = Attributes.Name.SIGNATURE_VERSION;
version = manifest.mainAttributes.getValue(versionName);
}
if (version != null) {
writeEntry(out, versionName, version, encoder, buffer);
Iterator<?> entries = manifest.mainAttributes.keySet().iterator();
while (entries.hasNext()) {
Attributes.Name name = (Attributes.Name) entries.next();
if (!name.equals(versionName)) {
writeEntry(out, name, manifest.mainAttributes.getValue(name), encoder, buffer);
}
}
}
out.write(LINE_SEPARATOR);
Iterator<String> i = manifest.getEntries().keySet().iterator();
while (i.hasNext()) {
String key = i.next();
writeEntry(out, Attributes.Name.NAME, key, encoder, buffer);
Attributes attributes = manifest.entries.get(key);
Iterator<?> entries = attributes.keySet().iterator();
while (entries.hasNext()) {
Attributes.Name name = (Attributes.Name) entries.next();
writeEntry(out, name, attributes.getValue(name), encoder, buffer);
}
out.write(LINE_SEPARATOR);
}
}
use of java.util.jar.Attributes in project tdi-studio-se by Talend.
the class JarBuilder method getManifest.
private Manifest getManifest() {
Manifest manifest = new Manifest();
Attributes a = new Attributes();
//$NON-NLS-1$
a.put(Attributes.Name.IMPLEMENTATION_VERSION, "1.0");
//$NON-NLS-1$
a.put(Attributes.Name.IMPLEMENTATION_VENDOR, "Talend Open Studio");
manifest.getEntries().put(jarFile.getName(), a);
return manifest;
}
use of java.util.jar.Attributes in project intellij-community by JetBrains.
the class XsltDebuggerExtension method isValidXalanPresent.
@Nullable
private static Boolean isValidXalanPresent(SimpleJavaParameters parameters) {
final List<VirtualFile> files = parameters.getClassPath().getVirtualFiles();
for (VirtualFile file : files) {
if (file.getName().matches(".*xalan.*\\.jar")) {
final VirtualFile root = JarFileSystem.getInstance().getJarRootForLocalFile(file);
final VirtualFile manifestFile = root != null ? root.findFileByRelativePath("META-INF/MANIFEST.MF") : null;
if (manifestFile != null) {
try {
Manifest manifest = manifestFile.getUserData(MANIFEST);
if (manifest == null) {
manifest = new Manifest(manifestFile.getInputStream());
manifestFile.putUserData(MANIFEST, manifest);
}
Attributes attributes = manifest.getAttributes("org/apache/xalan/");
if (attributes == null) {
attributes = manifest.getAttributes("org/apache/xalan");
}
if (attributes == null) {
LOG.info("No manifest attributes for 'org/apache/xalan/' in " + manifestFile.getPresentableUrl());
continue;
}
final String version = attributes.getValue("Implementation-Version");
if (version != null) {
final String[] parts = version.split("\\.");
if (parts.length >= 2) {
if (Integer.parseInt(parts[0]) >= 2 && Integer.parseInt(parts[1]) >= 6) {
return true;
}
}
LOG.info("Unsupported Xalan version: " + version);
} else {
LOG.info("No Xalan version information in " + file.getPath());
}
} catch (IOException e) {
LOG.warn("Unable to read manifest from " + file.getName(), e);
}
} else {
LOG.info("No manifest file in " + file.getPath());
}
return false;
}
}
return null;
}
use of java.util.jar.Attributes in project ProjectRails by Project-Rails.
the class Rails method run.
/**
* Runs ProjectRails stuff. Called in
* {@link org.projectrainbow._DiwUtils#Startup()}
*/
public static void run() {
Attributes a = Rail_Updater.getManifest(Rail_Updater.class).getMainAttributes();
String hash = a.getValue("GitCommitHash");
if (hash.endsWith("-dirty"))
hash = hash.replace("-dirty", "");
_DiwUtils.version = "git-ProjectRails-" + hash;
_DiwUtils.upstream_version = String.valueOf(upstream);
config.saveDefaultConfig();
ServerWrapper.getInstance().registerCommand(new CmdRails());
}
use of java.util.jar.Attributes in project ACS by ACS-Community.
the class JarSourceExtractorRunner method needsProcessing.
/**
* Encapsulates evaluation of possible flags (properties) that may restrict the set of jar files to be processed
* for source extraction, for example based on the manifest information.
* <p>
* Currently only looks at the boolean property <code>jarExtract.onlyGeneratedJars</code>.
*
* @param jarFile
* @return
* @throws IOException
*/
static boolean needsProcessing(JarFile jarFile) throws IOException {
// flag to
boolean onlyGeneratedJars = Boolean.getBoolean(PROPERTY_EXTRACT_ONLY_GENERATED_JARS);
boolean needed = !onlyGeneratedJars;
// only look inside if we are not already sure that this jar file is needed
if (!needed) {
Manifest mani = jarFile.getManifest();
if (mani != null) {
Map<String, Attributes> entries = mani.getEntries();
// System.out.println("\n\nManifest for file " + jarFile.getName());
Attributes mainAttrs = mani.getMainAttributes();
for (Iterator mainAttrIter = mainAttrs.keySet().iterator(); mainAttrIter.hasNext(); ) {
String attr = ((Attributes.Name) mainAttrIter.next()).toString();
String value = mainAttrs.getValue(attr);
if (attr.equals(Manifest_Attr_ACSGeneratedFromFile)) {
needed = true;
break;
}
// System.out.println(attr + "=" + value);
}
}
}
return needed;
}
Aggregations