List of usage examples for java.util.jar Manifest Manifest
public Manifest()
From source file:org.reficio.p2.bundler.impl.AquteHelper.java
private static Jar getInputJarWithBlankManifest(ArtifactBundlerRequest request) throws Exception { File parentFolder = request.getBinaryInputFile().getParentFile(); File jarBlankManifest = new File(parentFolder, request.getBinaryInputFile().getName() + "." + UUID.randomUUID()); Jar jar = new Jar(request.getBinaryInputFile()); try {/*from w w w . j a va 2s .co m*/ jar.setManifest(new Manifest()); jar.write(jarBlankManifest); return new Jar(jarBlankManifest); } finally { FileUtils.deleteQuietly(jarBlankManifest); // do not close the newly created jar, analyzer will do it } }
From source file:org.reficio.p2.utils.BundleUtilsTest.java
@Test public void newManifest_hasMainAttributes() { assertNotNull(new Manifest().getMainAttributes()); }
From source file:com.asual.summer.core.util.ResourceUtils.java
public static String getManifestAttribute(String key) { try {/*from w w w. j a v a 2s . co m*/ if (!attributes.containsKey(key)) { String path = "META-INF/MANIFEST.MF"; Manifest mf = new Manifest(); URL resource = RequestUtils.getServletContext().getResource("/" + path); if (resource == null) { resource = getClasspathResources(path, false).get(0); } mf.read(new FileInputStream(resource.getFile())); attributes.put(key, mf.getMainAttributes().getValue(key)); } return attributes.get(key); } catch (Exception e) { return ""; } }
From source file:org.echocat.nodoodle.transport.HandlerPacker.java
protected Manifest createManifest(String dataFileName, Collection<String> dependencyFileNames) { if (dataFileName == null) { throw new NullPointerException(); }/*from w w w . j ava2 s . com*/ if (dependencyFileNames == null) { throw new NullPointerException(); } final Manifest manifest = new Manifest(); final Attributes mainAttributes = manifest.getMainAttributes(); mainAttributes.put(MANIFEST_VERSION, "1.0"); mainAttributes.put(new Attributes.Name("Created-By"), getSmappserVersionString()); mainAttributes.put(CLASS_PATH, StringUtils.join(dependencyFileNames, ' ')); final Attributes extensionAttributes = new Attributes(); extensionAttributes.put(MANIFEST_DATE_FILE, dataFileName); manifest.getEntries().put(MANIFEST_EXTENSION_NAME, extensionAttributes); return manifest; }
From source file:org.apache.hadoop.util.TestJarFinder.java
@Test public void testExistingManifest() throws Exception { File dir = GenericTestUtils.getTestDir(TestJarFinder.class.getName() + "-testExistingManifest"); delete(dir);//from w ww.j av a 2 s .co m dir.mkdirs(); File metaInfDir = new File(dir, "META-INF"); metaInfDir.mkdirs(); File manifestFile = new File(metaInfDir, "MANIFEST.MF"); Manifest manifest = new Manifest(); OutputStream os = new FileOutputStream(manifestFile); manifest.write(os); os.close(); File propsFile = new File(dir, "props.properties"); Writer writer = new FileWriter(propsFile); new Properties().store(writer, ""); writer.close(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); JarOutputStream zos = new JarOutputStream(baos); JarFinder.jarDir(dir, "", zos); JarInputStream jis = new JarInputStream(new ByteArrayInputStream(baos.toByteArray())); Assert.assertNotNull(jis.getManifest()); jis.close(); }
From source file:org.apache.hadoop.hbase.mapreduce.hadoopbackport.TestJarFinder.java
@Test public void testExistingManifest() throws Exception { File dir = new File(System.getProperty("test.build.dir", "target/test-dir"), TestJarFinder.class.getName() + "-testExistingManifest"); delete(dir);/*from w ww .j av a2s . c om*/ dir.mkdirs(); File metaInfDir = new File(dir, "META-INF"); metaInfDir.mkdirs(); File manifestFile = new File(metaInfDir, "MANIFEST.MF"); Manifest manifest = new Manifest(); OutputStream os = new FileOutputStream(manifestFile); manifest.write(os); os.close(); File propsFile = new File(dir, "props.properties"); Writer writer = new FileWriter(propsFile); new Properties().store(writer, ""); writer.close(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); JarOutputStream zos = new JarOutputStream(baos); JarFinder.jarDir(dir, "", zos); JarInputStream jis = new JarInputStream(new ByteArrayInputStream(baos.toByteArray())); Assert.assertNotNull(jis.getManifest()); jis.close(); }
From source file:org.reficio.p2.FeatureBuilder.java
public void generate(File destinationFolder) { try {//from w ww.j a va 2s. c om File featureContent = new File(destinationFolder, this.getFeatureFullName()); featureContent.mkdir(); this.buildXml(); XmlUtils.writeXml(this.xmlDoc, new File(featureContent, "feature.xml")); //we must be generating the feature file from the pom FileOutputStream fos = new FileOutputStream( new File(destinationFolder, this.getFeatureFullName() + ".jar")); Manifest mf = new Manifest(); JarOutputStream jar = new JarOutputStream(fos, mf); addToJar(jar, featureContent); } catch (Exception e) { throw new RuntimeException("Cannot generate feature", e); } }
From source file:com.redhat.rcm.maven.plugin.buildmetadata.util.ManifestHelper.java
private Manifest createManifestInstance(final Properties buildMetaDataProperties) { final Manifest manifest = new Manifest(); final Attributes attributes = fetchAttributes(manifest); manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); for (final Map.Entry<Object, Object> entry : buildMetaDataProperties.entrySet()) { final String key = ObjectUtils.toString(entry.getKey(), null); if (key.length() > MANIFEST_KEY_MAX_LENGTH) { continue; }//www. j a va 2 s .c o m final String normalizedKey = normalize(key); final String value = ObjectUtils.toString(entry.getValue(), null); attributes.putValue(normalizedKey, value); } return manifest; }
From source file:org.gradle.api.java.archives.internal.DefaultManifest.java
static Manifest generateJavaManifest(org.gradle.api.java.archives.Manifest gradleManifest) { Manifest javaManifest = new Manifest(); addMainAttributesToJavaManifest(gradleManifest, javaManifest); addSectionAttributesToJavaManifest(gradleManifest, javaManifest); return javaManifest; }
From source file:com.navercorp.pinpoint.bootstrap.AgentDirGenerator.java
private void createJarFile(File parentDir, String filepath) throws IOException { final String jarPath = parentDir.getPath() + File.separator + filepath; logger.debug("create jar:{}", jarPath); JarOutputStream jos = null;//from w w w . j av a 2 s . c o m try { Manifest manifest = new Manifest(); FileOutputStream out = new FileOutputStream(jarPath); jos = new JarOutputStream(out, manifest); } finally { IOUtils.closeQuietly(jos); } }