Search in sources :

Example 1 with SingleFileContentCodeGeneratorTask

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);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SingleFileContentCodeGeneratorTask(org.eclipse.vorto.codegen.api.SingleFileContentCodeGeneratorTask) ZipContentExtractCodeGeneratorTask(org.eclipse.vorto.codegen.api.ZipContentExtractCodeGeneratorTask) EclipseProjectGenerator(org.eclipse.vorto.codegen.ui.tasks.EclipseProjectGenerator) ModelId(org.eclipse.vorto.core.api.model.model.ModelId)

Aggregations

NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 SingleFileContentCodeGeneratorTask (org.eclipse.vorto.codegen.api.SingleFileContentCodeGeneratorTask)1 ZipContentExtractCodeGeneratorTask (org.eclipse.vorto.codegen.api.ZipContentExtractCodeGeneratorTask)1 EclipseProjectGenerator (org.eclipse.vorto.codegen.ui.tasks.EclipseProjectGenerator)1 ModelId (org.eclipse.vorto.core.api.model.model.ModelId)1