use of java.util.jar.Manifest in project robovm by robovm.
the class OldManifestTest method test_ConstructorLjava_util_jar_Manifest.
public void test_ConstructorLjava_util_jar_Manifest() {
// Test for method java.util.jar.Manifest()
Manifest emptyManifest = new Manifest();
Manifest emptyClone = new Manifest(emptyManifest);
assertTrue("Should have no entries", emptyClone.getEntries().isEmpty());
assertTrue("Should have no main attributes", emptyClone.getMainAttributes().isEmpty());
assertEquals(emptyClone, emptyManifest);
assertEquals(emptyClone, emptyManifest.clone());
}
use of java.util.jar.Manifest in project uavstack by uavorg.
the class FastClasspathScanner method addClasspathElement.
/**
* Add a classpath element.
*/
private void addClasspathElement(String pathElement) {
if (!pathElement.isEmpty()) {
final File pathElementFile = new File(pathElement);
if (pathElementFile.exists()) {
// Canonicalize path so that we don't get stuck in a redirect loop due to softlinks
String canonicalPath;
try {
canonicalPath = pathElementFile.getCanonicalPath();
} catch (IOException e) {
canonicalPath = pathElement;
} catch (SecurityException e) {
canonicalPath = pathElement;
}
if (classpathElementsSet.add(canonicalPath)) {
// This is the first time this classpath element has been encountered
if (verbose) {
Log.log("Found classpath element: " + pathElement);
}
classpathElements.add(pathElementFile);
// we recursively call addClasspathElement if needed each time a jar is encountered.
if (pathElementFile.isFile() && isJar(pathElement)) {
String manifestUrlStr = "jar:file:" + pathElement + "!/META-INF/MANIFEST.MF";
InputStream stream = null;
try {
stream = new URL(manifestUrlStr).openStream();
// Look for Class-Path keys within manifest files
Manifest manifest = new Manifest(stream);
String manifestClassPath = manifest.getMainAttributes().getValue("Class-Path");
if (manifestClassPath != null && !manifestClassPath.isEmpty()) {
if (verbose) {
Log.log("Found Class-Path entry in " + manifestUrlStr + ": " + manifestClassPath);
}
// Class-Path elements are space-delimited
for (String manifestClassPathElement : manifestClassPath.split(" ")) {
// Resolve Class-Path elements relative to the parent jar's containing directory
String manifestClassPathElementAbsolute = new File(pathElementFile.getParent(), manifestClassPathElement).getPath();
addClasspathElement(manifestClassPathElementAbsolute);
}
}
} catch (IOException e) {
// Jar does not contain a manifest
} finally /**
*************************** Alex Modified START ****************************
*/
{
try {
if (stream != null) {
stream.close();
}
} catch (IOException e) {
}
}
/**
*************************** XiaoSong Modified END ****************************
*/
}
}
} else if (verbose) {
Log.log("Classpath element does not exist: " + pathElement);
}
}
}
use of java.util.jar.Manifest in project graal by graphik-team.
the class Apps method printVersion.
public static void printVersion(String applicationName) {
Manifest manifest;
InputStream is;
Attributes att;
URL pathToManifest;
String version;
String vendor;
String buildDate;
// GETÂ DATA
try {
pathToManifest = new URL(getPathToManifest());
is = pathToManifest.openStream();
manifest = new Manifest(is);
att = manifest.getMainAttributes();
version = att.getValue("Specification-Version");
vendor = att.getValue("Specification-Vendor");
buildDate = att.getValue("Built-On");
is.close();
} catch (IOException ex) {
version = vendor = buildDate = "?";
}
// PRINTÂ DATA
System.out.print(applicationName);
System.out.print(" version \"");
System.out.print(version);
System.out.println("\"");
System.out.print("Built on ");
System.out.println(buildDate);
System.out.print("Produced by ");
System.out.println(vendor);
}
use of java.util.jar.Manifest in project felix by apache.
the class BundleTransformer method canHandle.
public boolean canHandle(File artifact) {
JarFile jar = null;
try {
// Handle OSGi bundles with the default deployer
String name = artifact.getName();
if (!artifact.canRead() || name.endsWith(".txt") || name.endsWith(".xml") || name.endsWith(".properties") || name.endsWith(".cfg")) {
// exception in the log
return false;
}
jar = new JarFile(artifact);
Manifest m = jar.getManifest();
if (m != null && m.getMainAttributes().getValue(new Attributes.Name("Bundle-SymbolicName")) != null) {
return true;
}
} catch (Exception e) {
// Ignore
} finally {
if (jar != null) {
try {
jar.close();
} catch (IOException e) {
// Ignore
}
}
}
return false;
}
use of java.util.jar.Manifest in project felix by apache.
the class DPSigner method sign.
public void sign(DeploymentPackageBuilder builder, PrivateKey privKey, X509Certificate cert, OutputStream os) throws Exception {
Manifest manifest = builder.createManifest();
List<ArtifactData> artifacts = builder.getArtifactList();
sign(manifest, artifacts, privKey, cert, os);
}
Aggregations