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();
}
}
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);
}
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);
}
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();
}
}
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);
}
}
Aggregations