Package aQute.bnd.osgi

Examples of aQute.bnd.osgi.Builder


  /**
   * Builds the .jar file for the given module.
   */
  public void build(@NotNull File bndFile, @NotNull File moduleOutput, @NotNull File outputFile) throws OsgiBuildException {
    try {
      Builder builder = new ReportingBuilder(myReporter);
      builder.setPedantic(false);
      builder.setProperties(bndFile);
      builder.setClasspath(new File[]{moduleOutput});

      // check if the manifest version is missing (IDEADEV-41174)
      String manifest = builder.getProperty(aQute.bnd.osgi.Constants.MANIFEST);
      if (manifest != null) {
        File manifestFile = builder.getFile(manifest);
        if (manifestFile != null) {
          try {
            FileInputStream stream = new FileInputStream(manifestFile);
            try {
              Properties p = new Properties();
              p.load(stream);
              String value = p.getProperty(Attributes.Name.MANIFEST_VERSION.toString());
              if (StringUtil.isEmptyOrSpaces(value)) {
                String message = "Manifest misses a Manifest-Version entry. This may produce an empty manifest in the resulting bundle.";
                myReporter.warning(message, null, manifest);
              }
            }
            finally {
              stream.close();
            }
          }
          catch (Exception e) {
            myReporter.warning("Can't read manifest: " + e.getMessage(), e, manifest);
          }
        }
      }

      Jar jar = builder.build();
      jar.setName(outputFile.getName());
      jar.write(outputFile);
      builder.close();
    }
    catch (Exception e) {
      throw new OsgiBuildException("Unexpected build error", e, null);
    }
  }
View Full Code Here

TOP

Related Classes of aQute.bnd.osgi.Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.