private void generateMetainfo(File metainfoFile, Mpack mpack) throws IOException {
    LOG.info("Generating {} for mpack {}", metainfoFile, mpack.getName());
    StackMetainfoXml generatedMetainfo = new StackMetainfoXml();
    StackMetainfoXml.Version version = new StackMetainfoXml.Version();
    version.setActive(true);
    generatedMetainfo.setVersion(version);

    Map<String, String> prerequisites = mpack.getPrerequisites();
    if (prerequisites != null && prerequisites.containsKey(MIN_JDK_PROPERTY)) {
      generatedMetainfo.setMinJdk(mpack.getPrerequisites().get(MIN_JDK_PROPERTY));
    } else {
      //this should not happen if mpack was configured correctly
      LOG.warn("Couldn't detect {} for mpack {}. Using default value {}", MIN_JDK_PROPERTY, mpack.getName(), DEFAULT_JDK_VALUE);
      generatedMetainfo.setMinJdk(DEFAULT_JDK_VALUE);
    }
    if (prerequisites != null && prerequisites.containsKey(MAX_JDK_PROPERTY)) {
      generatedMetainfo.setMaxJdk(mpack.getPrerequisites().get(MAX_JDK_PROPERTY));
    } else {
      //this should not happen if mpack was configured correctly
      LOG.warn("Couldn't detect {} for mpack {}. Using default value {}", MAX_JDK_PROPERTY, mpack.getName(), DEFAULT_JDK_VALUE);
      generatedMetainfo.setMaxJdk(DEFAULT_JDK_VALUE);
    }

    // Export generatedMetainfo to metainfo.xml
    try {
      JAXBContext ctx = JAXBContext.newInstance(StackMetainfoXml.class);
      Marshaller marshaller = ctx.createMarshaller();
      marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      FileOutputStream stackMetainfoFileStream = new FileOutputStream(metainfoFile);
      marshaller.marshal(generatedMetainfo, stackMetainfoFileStream);
      stackMetainfoFileStream.flush();
      stackMetainfoFileStream.close();
    } catch (JAXBException e) {
      e.printStackTrace();
    }
  }
Generate metainfo.xml based on prerequisites of mpack and write it to the mpack directory.
If required properties are missing in prerequisites fill them with default values.

@param metainfoFile
@param mpack
@throws IOException
ambari-server/src/test/java/org/apache/ambari/server/mpack/MpackManagerMock.java