Search in sources :

Example 1 with EclipseProjectGenerator

use of org.eclipse.vorto.codegen.ui.tasks.EclipseProjectGenerator in project vorto by eclipse.

the class ProjectCreationTask method run.

@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    try {
        EclipseProjectGenerator<IModelProjectContext> generator = new EclipseProjectGenerator<IModelProjectContext>(new LocationWrapper(workspaceLocation, projectName));
        generator.addNature(XTEXT_NATURE);
        for (String nature : getProjectNature()) {
            generator.addNature(nature);
        }
        generator.addTask(getCodeGeneratorTask());
        generator.generate(context, InvocationContext.simpleInvocationContext(), monitor);
        setIproject(generator.getProject());
        IModelProject modelProject = getIotproject(generator.getProject());
        modelProject.refresh(monitor);
        fireRefreshEvent(modelProject);
    } finally {
        monitor.done();
    }
}
Also used : IModelProjectContext(org.eclipse.vorto.codegen.ui.context.IModelProjectContext) IModelProject(org.eclipse.vorto.core.ui.model.IModelProject) EclipseProjectGenerator(org.eclipse.vorto.codegen.ui.tasks.EclipseProjectGenerator) LocationWrapper(org.eclipse.vorto.codegen.ui.tasks.LocationWrapper)

Example 2 with EclipseProjectGenerator

use of org.eclipse.vorto.codegen.ui.tasks.EclipseProjectGenerator in project vorto by eclipse.

the class ProjectCreationTask method createGeneratorProject.

private void createGeneratorProject(IProgressMonitor monitor) {
    EclipseProjectGenerator<IGeneratorProjectContext> generator = new EclipseProjectGenerator<IGeneratorProjectContext>(new LocationWrapper(context.getWorkspaceLocation(), context.getPackageName() + "." + context.getGeneratorName().toLowerCase()));
    generator.pluginNature(new PluginBuildFileTemplate(), new ManifestFileTemplate(), "src", "xtend-gen");
    generator.addNature(MavenNature.MAVEN_NATURE_STRING);
    generator.addTask(new GeneratorTemplate());
    generator.addTask(new PomTemplate());
    generator.addTask(new PluginXMLFileTemplate());
    generator.generate(context, InvocationContext.simpleInvocationContext(), monitor);
}
Also used : MicroServicePomTemplate(org.eclipse.vorto.codegen.ui.wizard.generation.templates.server.MicroServicePomTemplate) PomTemplate(org.eclipse.vorto.codegen.ui.wizard.generation.templates.PomTemplate) IGeneratorProjectContext(org.eclipse.vorto.codegen.ui.context.IGeneratorProjectContext) EclipseProjectGenerator(org.eclipse.vorto.codegen.ui.tasks.EclipseProjectGenerator) LocationWrapper(org.eclipse.vorto.codegen.ui.tasks.LocationWrapper) PluginBuildFileTemplate(org.eclipse.vorto.codegen.ui.wizard.generation.templates.PluginBuildFileTemplate) GeneratorTemplate(org.eclipse.vorto.codegen.ui.wizard.generation.templates.GeneratorTemplate) PluginXMLFileTemplate(org.eclipse.vorto.codegen.ui.wizard.generation.templates.PluginXMLFileTemplate) ManifestFileTemplate(org.eclipse.vorto.codegen.ui.wizard.generation.templates.ManifestFileTemplate)

Example 3 with EclipseProjectGenerator

use of org.eclipse.vorto.codegen.ui.tasks.EclipseProjectGenerator in project vorto by eclipse.

the class ProjectCreationTask method createMicroServiceProject.

private void createMicroServiceProject(IProgressMonitor monitor) throws JavaModelException {
    EclipseProjectGenerator<IGeneratorProjectContext> generator = new EclipseProjectGenerator<>(new LocationWrapper(context.getWorkspaceLocation(), context.getPackageName() + ".service"));
    generator.mavenNature(new MicroServicePomTemplate(), "src/main/java", "src/main/resources", "src/test/java");
    generator.addTask(new PlatformGeneratorMainTemplate());
    generator.addTask(new ApplicationPropertiesTemplate());
    generator.addTask(new ApplicationProfileProperties());
    generator.generate(context, InvocationContext.simpleInvocationContext(), monitor);
}
Also used : MicroServicePomTemplate(org.eclipse.vorto.codegen.ui.wizard.generation.templates.server.MicroServicePomTemplate) IGeneratorProjectContext(org.eclipse.vorto.codegen.ui.context.IGeneratorProjectContext) EclipseProjectGenerator(org.eclipse.vorto.codegen.ui.tasks.EclipseProjectGenerator) LocationWrapper(org.eclipse.vorto.codegen.ui.tasks.LocationWrapper) ApplicationPropertiesTemplate(org.eclipse.vorto.codegen.ui.wizard.generation.templates.server.ApplicationPropertiesTemplate) PlatformGeneratorMainTemplate(org.eclipse.vorto.codegen.ui.wizard.generation.templates.server.PlatformGeneratorMainTemplate) ApplicationProfileProperties(org.eclipse.vorto.codegen.ui.wizard.generation.templates.server.ApplicationProfileProperties)

Example 4 with EclipseProjectGenerator

use of org.eclipse.vorto.codegen.ui.tasks.EclipseProjectGenerator in project vorto by eclipse.

the class VortoProjectCreationTask method run.

@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    try {
        EclipseProjectGenerator<IProjectContext> generator = new EclipseProjectGenerator<IProjectContext>(new LocationWrapper(workspaceLocation, projectName));
        generator.addNature(XTEXT_NATURE);
        generator.addNature(VortoProjectNature.VORTO_NATURE);
        for (String folder : ALL_MODEL_FOLDERS) {
            generator.addFolder(folder);
        }
        generator.generate(context, InvocationContext.simpleInvocationContext(), monitor);
        IProject iProject = generator.getProject();
        iProject.refreshLocal(IResource.DEPTH_ONE, monitor);
    } catch (CoreException e) {
        errorMessage = e.getMessage();
        throw new RuntimeException(ERROR_MESSAGE + e.getMessage(), e);
    } finally {
        monitor.done();
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IProjectContext(org.eclipse.vorto.codegen.ui.context.IProjectContext) EclipseProjectGenerator(org.eclipse.vorto.codegen.ui.tasks.EclipseProjectGenerator) LocationWrapper(org.eclipse.vorto.codegen.ui.tasks.LocationWrapper) IProject(org.eclipse.core.resources.IProject)

Example 5 with EclipseProjectGenerator

use of org.eclipse.vorto.codegen.ui.tasks.EclipseProjectGenerator 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

EclipseProjectGenerator (org.eclipse.vorto.codegen.ui.tasks.EclipseProjectGenerator)6 LocationWrapper (org.eclipse.vorto.codegen.ui.tasks.LocationWrapper)4 IProject (org.eclipse.core.resources.IProject)2 CoreException (org.eclipse.core.runtime.CoreException)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 IGeneratorProjectContext (org.eclipse.vorto.codegen.ui.context.IGeneratorProjectContext)2 MicroServicePomTemplate (org.eclipse.vorto.codegen.ui.wizard.generation.templates.server.MicroServicePomTemplate)2 IFolder (org.eclipse.core.resources.IFolder)1 IResource (org.eclipse.core.resources.IResource)1 SingleFileContentCodeGeneratorTask (org.eclipse.vorto.codegen.api.SingleFileContentCodeGeneratorTask)1 ZipContentExtractCodeGeneratorTask (org.eclipse.vorto.codegen.api.ZipContentExtractCodeGeneratorTask)1 IModelProjectContext (org.eclipse.vorto.codegen.ui.context.IModelProjectContext)1 IProjectContext (org.eclipse.vorto.codegen.ui.context.IProjectContext)1 GeneratorTemplate (org.eclipse.vorto.codegen.ui.wizard.generation.templates.GeneratorTemplate)1 ManifestFileTemplate (org.eclipse.vorto.codegen.ui.wizard.generation.templates.ManifestFileTemplate)1 PluginBuildFileTemplate (org.eclipse.vorto.codegen.ui.wizard.generation.templates.PluginBuildFileTemplate)1 PluginXMLFileTemplate (org.eclipse.vorto.codegen.ui.wizard.generation.templates.PluginXMLFileTemplate)1 PomTemplate (org.eclipse.vorto.codegen.ui.wizard.generation.templates.PomTemplate)1 ApplicationProfileProperties (org.eclipse.vorto.codegen.ui.wizard.generation.templates.server.ApplicationProfileProperties)1 ApplicationPropertiesTemplate (org.eclipse.vorto.codegen.ui.wizard.generation.templates.server.ApplicationPropertiesTemplate)1