Skip to content

Commit 80ba137

Browse files
committed
Fixed pretty printing of build yaml
1 parent 00709f5 commit 80ba137

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/main/java/gr/gousiosg/javacg/stat/JCallGraph.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
import org.slf4j.Logger;
5050
import org.slf4j.LoggerFactory;
5151
import org.xml.sax.SAXException;
52+
import org.yaml.snakeyaml.DumperOptions;
5253
import org.yaml.snakeyaml.Yaml;
5354

5455
import javax.xml.bind.JAXBException;
@@ -106,7 +107,10 @@ public static void main(String[] args) {
106107
break;
107108
}
108109
case "buildyaml":{
109-
Yaml yaml = new Yaml();
110+
DumperOptions options = new DumperOptions();
111+
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
112+
options.setPrettyFlow(true);
113+
Yaml yaml = new Yaml(options);
110114
JarInputStream jarFileStream = new JarInputStream(new FileInputStream(args[1]));
111115
JarFile jarFile = new JarFile(args[1]);
112116
ArrayList<JarEntry> listOfAllClasses = getAllClassesFromJar(jarFileStream);
@@ -116,13 +120,10 @@ public static void main(String[] args) {
116120
ArrayList<Map<String,String>> entryResult = new ArrayList<>();
117121
for(Pair<String, String> entry : nameEntryList)
118122
entryResult.add(Map.ofEntries(entry("name",entry.first),entry("entryPoint",entry.second)));
119-
120123
Map<String, ArrayList<Map<String,String>>> dataMap = new HashMap<>();
121-
122124
dataMap.put("properties",entryResult);
123-
// PrintWriter writer = new PrintWriter(new File("./mph-tableFull.yaml"));
124-
// yaml.dump(dataMap, writer);
125-
// ObjectMapper om = new ObjectMapper(new YAMLFactory());
125+
final FileWriter writer = new FileWriter("mph-table-full.yaml");
126+
yaml.dump(dataMap, writer);
126127
}
127128
case "test": {
128129
TestArguments arguments = new TestArguments(args);

0 commit comments

Comments
 (0)