Created
August 6, 2019 20:09
-
-
Save CraftingGamerTom/9cd68568e8561617e9ac6af1655bcfee to your computer and use it in GitHub Desktop.
Create a YAML file and zip it - Created for passing information to Device Farm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.esotericsoftware.yamlbeans.YamlWriter; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; | |
/** | |
* WARNING: This creates a file that is never forced to be deleted. You MUST | |
* delete the file within the ExtraData object to clear space on the computer. | |
* | |
* @param run | |
* @return ExtraData object (From Amazon Device Farm | |
* @throws IOException | |
*/ | |
public ExtraData createExtraDataConfiguration(ScreenshotRun run) throws IOException { | |
File tempConfigurationFile = File.createTempFile("temp_configuration.yml", ".tmp"); | |
tempConfigurationFile.deleteOnExit(); | |
Configuration configuration = createConfiguration(run); | |
ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); | |
mapper.writeValue(tempConfigurationFile, configuration); | |
YamlWriter writer = new YamlWriter(new FileWriter(tempConfigurationFile.getAbsolutePath())); | |
writer.write(configuration); | |
writer.close(); | |
ExtraData extraData = new ExtraData(); | |
extraData.setFile(tempConfigurationFile); | |
extraData.setFileName("configuration.yml"); | |
extraData.setFileExtension(FileExtension.YML); | |
return extraData; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment