use of org.eclipse.vorto.codegen.api.SingleFileContentCodeGeneratorTask in project vorto by eclipse.
the class CodeGenerationHelper method createEclipseProject.
public static void createEclipseProject(ModelId modelId, String serviceKey, IGenerationResult generatedResult) {
byte[] generated = generatedResult.getContent();
ICodeGeneratorTask<ModelId> task = null;
String name = modelId.getName() + "_" + serviceKey + "_generated";
boolean containsEclipseProject = false;
boolean generateMaven = false;
if (generatedResult.getFileName().endsWith(".zip")) {
ZipContentExtractCodeGeneratorTask tmp = new ZipContentExtractCodeGeneratorTask(generated);
tmp.preprocess();
if (tmp.getEclipseProjectName() != null) {
name = tmp.getEclipseProjectName();
containsEclipseProject = true;
} else {
generateMaven = tmp.isMavenContent();
}
task = tmp;
} else {
task = new SingleFileContentCodeGeneratorTask(generatedResult.getFileName(), generated);
}
EclipseProjectGenerator<ModelId> generator = new EclipseProjectGenerator<>(name);
generator.addTask(task);
generator.generate(modelId, containsEclipseProject ? InvocationContext.simpleInvocationContext(Collections.singletonMap(EclipseProjectGenerator.SKIP_PROJECT_CONFIGURATION, Boolean.TRUE.toString())) : InvocationContext.simpleInvocationContext(), new NullProgressMonitor());
if (generateMaven) {
createMavenProjectFromGeneratedCode(generator);
}
}
Aggregations