private void write(Serializer serializer, String path, EntityType type) throws IOException {
File targetFile = new File(targetFolder, path);
classes.add(targetFile.getPath());
StringWriter w = new StringWriter();
CodeWriter writer = createScalaSources ? new ScalaWriter(w) : new JavaWriter(w);
serializer.serialize(type, SimpleSerializerConfig.DEFAULT, writer);
// conditional creation
boolean generate = true;
byte[] bytes = w.toString().getBytes(sourceEncoding);