Search in sources :

Example 6 with EclipseProjectGenerator

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

the class CodeGenerationHelper method createMavenProjectFromGeneratedCode.

private static void createMavenProjectFromGeneratedCode(EclipseProjectGenerator<ModelId> generator) {
    final IProject generatedTempProject = generator.getProject();
    try {
        for (IResource folderResource : generatedTempProject.members(IResource.FOLDER)) {
            if (!(folderResource instanceof IFolder)) {
                // it could still return eclipse project metadata files :(
                continue;
            }
            EclipseProjectGenerator<IResource> projectGenerator = new EclipseProjectGenerator<>(folderResource.getName());
            projectGenerator.addNature(MavenNature.MAVEN_NATURE_STRING);
            projectGenerator.addTask(new CopyResourceTask<IResource>(folderResource.getLocationURI().toURL(), ""));
            projectGenerator.generate(folderResource, InvocationContext.simpleInvocationContext(), new NullProgressMonitor());
        }
    } catch (Exception e) {
        throw new RuntimeException("Could not postprocess downloaded generated files", e);
    } finally {
        deleteTemporaryDownloadedProject(generatedTempProject);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) EclipseProjectGenerator(org.eclipse.vorto.codegen.ui.tasks.EclipseProjectGenerator) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource) CoreException(org.eclipse.core.runtime.CoreException) IFolder(org.eclipse.core.resources.IFolder)

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