@Override protected ConfigurationMetadata writeMetaData() { super.writeMetaData(); try { File metadataFile = new File(this.outputLocation, "META-INF/spring-configuration-metadata.json"); if (metadataFile.isFile()) { this.metadata = new JsonMarshaller() .read(new FileInputStream(metadataFile)); } else { this.metadata = new ConfigurationMetadata(); } return this.metadata; } catch (IOException e) { throw new RuntimeException("Failed to read metadata from disk", e); } }
public void writeMetadata(ConfigurationMetadata metadata) throws IOException { if (!metadata.getItems().isEmpty()) { OutputStream outputStream = createMetadataResource().openOutputStream(); try { new JsonMarshaller().write(metadata, outputStream); } finally { outputStream.close(); } } }