use of org.whole.lang.artifacts.model.LocationURI in project whole by wholeplatform.
the class WorkspaceArtifactsGeneratorVisitor method visitProject.
public void visitProject(final Project entity) {
// unset the default folder
env().wUnset("folder");
env().wEnterScope();
if (!Matcher.matchImplAndBind(ArtifactsEntityDescriptorEnum.Name, entity.getName(), env(), "projectName"))
throw new VisitException("No Project name");
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot workspaceRoot = workspace.getRoot();
String projectName = env().wStringValue("projectName");
IProject project = workspaceRoot.getProject(projectName);
try {
if (!project.exists()) {
LocationURI locationURI = entity.getLocationURI();
if (DataTypeUtils.getDataKind(locationURI).isString()) {
try {
IProjectDescription description = workspace.newProjectDescription(projectName);
description.setLocationURI(new URI(locationURI.getValue()));
project.create(description, progressMonitor());
} catch (Exception e) {
throw new VisitException(e);
}
} else
project.create(progressMonitor());
}
project.open(progressMonitor());
env().wDefValue("project", project);
entity.getNatures().accept(this);
entity.getMetadata().accept(this);
if (project.hasNature(JavaCore.NATURE_ID))
env().wDefValue("javaProject", JavaCore.create(project));
entity.getArtifacts().accept(this);
} catch (CoreException e) {
throw new VisitException(e);
}
env().wExitScope();
}
use of org.whole.lang.artifacts.model.LocationURI in project whole by wholeplatform.
the class ResourceArtifactsGeneratorVisitor method visit.
public void visit(Project entity) {
LocationURI locationURI = entity.getLocationURI();
if (DataTypeUtils.getDataKind(locationURI).isString() || env().wIsSet("folder") || env().wIsSet("folderLocation")) {
env().wEnterScope();
if (!Matcher.matchImplAndBind(ArtifactsEntityDescriptorEnum.Name, entity.getName(), env(), "projectName"))
throw new VisitException("No project name");
entity.getMetadata().accept(this);
File folder;
if (DataTypeUtils.getDataKind(locationURI).isString()) {
try {
folder = new File(new URI(locationURI.getValue()));
} catch (URISyntaxException e) {
throw new IllegalArgumentException("Invalid project location URI specified", e);
}
} else {
File parentFolder = getParentFolder();
String path = parentFolder.getAbsolutePath();
String projectPath = path + File.separatorChar + env().wStringValue("projectName");
folder = new File(projectPath);
}
if (!folder.exists())
folder.mkdirs();
env().wDefValue("folder", folder);
entity.getNatures().accept(this);
entity.getArtifacts().accept(this);
env().wExitScope();
} else
throw new IllegalStateException("Project generation not supported yet");
}
Aggregations