packageManifest.setTypes((PackageTypeMembers[]) packageTypeMembersList.toArray(new PackageTypeMembers[0]));
// Serialise it (better way to do this?)
TypeMapper typeMapper = new TypeMapper();
ByteArrayOutputStream packageBaos = new ByteArrayOutputStream();
QName packageQName = new QName("http://soap.sforce.com/2006/04/metadata", "Package");
XmlOutputStream xmlOutputStream = new XmlOutputStream(packageBaos, true);
xmlOutputStream.setPrefix("", "http://soap.sforce.com/2006/04/metadata");
xmlOutputStream.setPrefix("xsi", "http://www.w3.org/2001/XMLSchema-instance");
packageManifest.write(packageQName, xmlOutputStream, typeMapper);
xmlOutputStream.close();
packageManifestXml = new String(packageBaos.toByteArray());
}
// Download the Repository as an archive zip
RepositoryId repoId = RepositoryId.create(repoOwner, repoName);