aQute.bnd.osgi.Jar.writeManifest()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(214)

本文整理了Java中aQute.bnd.osgi.Jar.writeManifest()方法的一些代码示例,展示了Jar.writeManifest()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jar.writeManifest()方法的具体详情如下:
包路径:aQute.bnd.osgi.Jar
类名称:Jar
方法名:writeManifest

Jar.writeManifest介绍

[英]Cleanup the manifest for writing. Cleaning up consists of adding a space after any \n to prevent the manifest to see this newline as a delimiter.
[中]清理清单以进行写入。清理包括在任何空格后添加空格,\n以防止清单将此换行符视为分隔符。

代码示例

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

  1. @Override
  2. public void write(OutputStream out) throws Exception {
  3. writeManifest(out);
  4. }

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

  1. @Override
  2. public void write(OutputStream out) throws Exception {
  3. writeManifest(out);
  4. }

代码示例来源:origin: biz.aQute/bndlib

  1. private void doManifest(Set<String> done, ZipOutputStream jout) throws Exception {
  2. check();
  3. if (nomanifest)
  4. return;
  5. JarEntry ze = new JarEntry("META-INF/MANIFEST.MF");
  6. jout.putNextEntry(ze);
  7. writeManifest(jout);
  8. jout.closeEntry();
  9. done.add(ze.getName());
  10. }

代码示例来源:origin: biz.aQute.bnd/bndlib

  1. private void doManifest(Set<String> done, ZipOutputStream jout) throws Exception {
  2. check();
  3. if (nomanifest)
  4. return;
  5. JarEntry ze = new JarEntry(manifestName);
  6. ZipUtil.setModifiedTime(ze,lastModified);
  7. jout.putNextEntry(ze);
  8. writeManifest(jout);
  9. jout.closeEntry();
  10. done.add(ze.getName());
  11. }

代码示例来源:origin: biz.aQute.bnd/bnd

  1. private void doManifest(Set<String> done, ZipOutputStream jout) throws Exception {
  2. check();
  3. if (nomanifest)
  4. return;
  5. JarEntry ze = new JarEntry(manifestName);
  6. ZipUtil.setModifiedTime(ze,lastModified);
  7. jout.putNextEntry(ze);
  8. writeManifest(jout);
  9. jout.closeEntry();
  10. done.add(ze.getName());
  11. }

代码示例来源:origin: biz.aQute.bnd/bnd

  1. /**
  2. * Cleanup the manifest for writing. Cleaning up consists of adding a space
  3. * after any \n to prevent the manifest to see this newline as a delimiter.
  4. *
  5. * @param out
  6. * Output
  7. * @throws IOException
  8. */
  9. public void writeManifest(OutputStream out) throws Exception {
  10. check();
  11. writeManifest(getManifest(), out);
  12. }

代码示例来源:origin: biz.aQute/bndlib

  1. /**
  2. * Cleanup the manifest for writing. Cleaning up consists of adding a space
  3. * after any \n to prevent the manifest to see this newline as a delimiter.
  4. *
  5. * @param out
  6. * Output
  7. * @throws IOException
  8. */
  9. public void writeManifest(OutputStream out) throws Exception {
  10. check();
  11. writeManifest(getManifest(), out);
  12. }

代码示例来源:origin: biz.aQute.bnd/bndlib

  1. /**
  2. * Cleanup the manifest for writing. Cleaning up consists of adding a space
  3. * after any \n to prevent the manifest to see this newline as a delimiter.
  4. *
  5. * @param out
  6. * Output
  7. * @throws IOException
  8. */
  9. public void writeManifest(OutputStream out) throws Exception {
  10. check();
  11. writeManifest(getManifest(), out);
  12. }

代码示例来源:origin: biz.aQute/bndlib

  1. /**
  2. * Get the manifest and write it out separately if -savemanifest is set
  3. *
  4. * @param dot
  5. */
  6. private void doSaveManifest(Jar dot) throws Exception {
  7. String output = getProperty(SAVEMANIFEST);
  8. if (output == null)
  9. return;
  10. File f = getFile(output);
  11. if (f.isDirectory()) {
  12. f = new File(f, "MANIFEST.MF");
  13. }
  14. f.delete();
  15. File fp = f.getParentFile();
  16. if (!fp.exists() && !fp.mkdirs()) {
  17. throw new IOException("Could not create directory " + fp);
  18. }
  19. OutputStream out = new FileOutputStream(f);
  20. try {
  21. Jar.writeManifest(dot.getManifest(), out);
  22. }
  23. finally {
  24. out.close();
  25. }
  26. changedFile(f);
  27. }

代码示例来源:origin: biz.aQute.bnd/bnd

  1. /**
  2. * Get the manifest and write it out separately if -savemanifest is set
  3. *
  4. * @param dot
  5. */
  6. private void doSaveManifest(Jar dot) throws Exception {
  7. String output = getProperty(SAVEMANIFEST);
  8. if (output == null)
  9. return;
  10. File f = getFile(output);
  11. if (f.isDirectory()) {
  12. f = new File(f, "MANIFEST.MF");
  13. }
  14. f.delete();
  15. File fp = f.getParentFile();
  16. if (!fp.exists() && !fp.mkdirs()) {
  17. throw new IOException("Could not create directory " + fp);
  18. }
  19. OutputStream out = new FileOutputStream(f);
  20. try {
  21. Jar.writeManifest(dot.getManifest(), out);
  22. }
  23. finally {
  24. out.close();
  25. }
  26. changedFile(f);
  27. }

代码示例来源:origin: biz.aQute.bnd/bndlib

  1. /**
  2. * Get the manifest and write it out separately if -savemanifest is set
  3. *
  4. * @param dot
  5. */
  6. private void doSaveManifest(Jar dot) throws Exception {
  7. String output = getProperty(SAVEMANIFEST);
  8. if (output == null)
  9. return;
  10. File f = getFile(output);
  11. if (f.isDirectory()) {
  12. f = new File(f, "MANIFEST.MF");
  13. }
  14. f.delete();
  15. File fp = f.getParentFile();
  16. if (!fp.exists() && !fp.mkdirs()) {
  17. throw new IOException("Could not create directory " + fp);
  18. }
  19. OutputStream out = new FileOutputStream(f);
  20. try {
  21. Jar.writeManifest(dot.getManifest(), out);
  22. }
  23. finally {
  24. out.close();
  25. }
  26. changedFile(f);
  27. }

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

  1. /**
  2. * Cleanup the manifest for writing. Cleaning up consists of adding a space
  3. * after any \n to prevent the manifest to see this newline as a delimiter.
  4. *
  5. * @param out Output
  6. * @throws IOException
  7. */
  8. public void writeManifest(OutputStream out) throws Exception {
  9. check();
  10. stripSignatures();
  11. writeManifest(getManifest(), out);
  12. }

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

  1. /**
  2. * Cleanup the manifest for writing. Cleaning up consists of adding a space
  3. * after any \n to prevent the manifest to see this newline as a delimiter.
  4. *
  5. * @param out Output
  6. * @throws IOException
  7. */
  8. public void writeManifest(OutputStream out) throws Exception {
  9. check();
  10. stripSignatures();
  11. writeManifest(getManifest(), out);
  12. }

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

  1. IO.mkdirs(file.getParentFile());
  2. try (OutputStream fout = IO.outputStream(file)) {
  3. writeManifest(fout);
  4. done.add(manifestName);

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

  1. public byte[] getTimelessDigest() throws Exception {
  2. check();
  3. MessageDigest md = MessageDigest.getInstance("SHA1");
  4. OutputStream dout = new DigestOutputStream(IO.nullStream, md);
  5. // dout = System.out;
  6. Manifest m = getManifest();
  7. if (m != null) {
  8. Manifest m2 = new Manifest(m);
  9. Attributes main = m2.getMainAttributes();
  10. String lastmodified = (String) main.remove(new Attributes.Name(Constants.BND_LASTMODIFIED));
  11. String version = main.getValue(new Attributes.Name(Constants.BUNDLE_VERSION));
  12. if (version != null && Verifier.isVersion(version)) {
  13. Version v = new Version(version);
  14. main.putValue(Constants.BUNDLE_VERSION, v.toStringWithoutQualifier());
  15. }
  16. writeManifest(m2, dout);
  17. for (Map.Entry<String, Resource> entry : getResources().entrySet()) {
  18. String path = entry.getKey();
  19. if (path.equals(manifestName))
  20. continue;
  21. Resource resource = entry.getValue();
  22. dout.write(path.getBytes(UTF_8));
  23. resource.write(dout);
  24. }
  25. }
  26. return md.digest();
  27. }

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

  1. public byte[] getTimelessDigest() throws Exception {
  2. check();
  3. MessageDigest md = MessageDigest.getInstance("SHA1");
  4. OutputStream dout = new DigestOutputStream(IO.nullStream, md);
  5. // dout = System.out;
  6. Manifest m = getManifest();
  7. if (m != null) {
  8. Manifest m2 = new Manifest(m);
  9. Attributes main = m2.getMainAttributes();
  10. String lastmodified = (String) main.remove(new Attributes.Name(Constants.BND_LASTMODIFIED));
  11. String version = main.getValue(new Attributes.Name(Constants.BUNDLE_VERSION));
  12. if (version != null && Verifier.isVersion(version)) {
  13. Version v = new Version(version);
  14. main.putValue(Constants.BUNDLE_VERSION, v.toStringWithoutQualifier());
  15. }
  16. writeManifest(m2, dout);
  17. for (Map.Entry<String, Resource> entry : getResources().entrySet()) {
  18. String path = entry.getKey();
  19. if (path.equals(manifestName))
  20. continue;
  21. Resource resource = entry.getValue();
  22. dout.write(path.getBytes(UTF_8));
  23. resource.write(dout);
  24. }
  25. }
  26. return md.digest();
  27. }

代码示例来源:origin: biz.aQute.bnd/bndlib

  1. main.putValue( Constants.BUNDLE_VERSION, v.getWithoutQualifier().toString());
  2. writeManifest(m2, dout);

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bndlib

  1. /**
  2. * Get the manifest and write it out separately if -savemanifest is set
  3. *
  4. * @param dot
  5. */
  6. private void doSaveManifest(Jar dot) throws Exception {
  7. String output = getProperty(SAVEMANIFEST);
  8. if (output == null)
  9. return;
  10. File f = getFile(output);
  11. if (f.isDirectory()) {
  12. f = new File(f, "MANIFEST.MF");
  13. }
  14. if (!f.exists() || f.lastModified() < dot.lastModified()) {
  15. IO.delete(f);
  16. File fp = f.getParentFile();
  17. IO.mkdirs(fp);
  18. try (OutputStream out = IO.outputStream(f)) {
  19. Jar.writeManifest(dot.getManifest(), out);
  20. }
  21. changedFile(f);
  22. }
  23. }

代码示例来源:origin: biz.aQute.bnd/biz.aQute.bnd

  1. /**
  2. * Get the manifest and write it out separately if -savemanifest is set
  3. *
  4. * @param dot
  5. */
  6. private void doSaveManifest(Jar dot) throws Exception {
  7. String output = getProperty(SAVEMANIFEST);
  8. if (output == null)
  9. return;
  10. File f = getFile(output);
  11. if (f.isDirectory()) {
  12. f = new File(f, "MANIFEST.MF");
  13. }
  14. if (!f.exists() || f.lastModified() < dot.lastModified()) {
  15. IO.delete(f);
  16. File fp = f.getParentFile();
  17. IO.mkdirs(fp);
  18. try (OutputStream out = IO.outputStream(f)) {
  19. Jar.writeManifest(dot.getManifest(), out);
  20. }
  21. changedFile(f);
  22. }
  23. }

代码示例来源:origin: diffplug/goomph

  1. private static String getManifestContent(Jar jarTask, BndManifestExtension extension) throws Throwable {
  2. // if we don't want to merge, then delete the existing manifest so that bnd doesn't merge with it
  3. if (!extension.mergeWithExisting) {
  4. Files.deleteIfExists(outputManifest(jarTask));
  5. }
  6. // take the bnd action
  7. return BndManifestPlugin.takeBndAction(jarTask.getProject(), jarTask, jar -> {
  8. return StringPrinter.buildString(printer -> {
  9. try (OutputStream output = printer.toOutputStream(StandardCharsets.UTF_8)) {
  10. aQute.bnd.osgi.Jar.writeManifest(jar.getManifest(), printer.toOutputStream(StandardCharsets.UTF_8));
  11. } catch (Exception e) {
  12. throw Errors.asRuntime(e);
  13. }
  14. });
  15. });
  16. }

相关文章