use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.
the class CreateBaseProjectTypeHandler method onCreateProject.
@Override
public void onCreateProject(Path projectPath, Map<String, AttributeValue> attributes, Map<String, String> options) throws ForbiddenException, ConflictException, ServerException {
VirtualFileSystem vfs = virtualFileSystemProvider.getVirtualFileSystem();
FolderEntry baseFolder = new FolderEntry(vfs.getRoot().createFolder(projectPath.toString()));
baseFolder.createFile(README_FILE_NAME, getReadmeContent());
}
use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.
the class PythonProjectGenerator method onCreateProject.
@Override
public void onCreateProject(Path projectPath, Map<String, AttributeValue> attributes, Map<String, String> options) throws ForbiddenException, ConflictException, ServerException {
VirtualFileSystem vfs = virtualFileSystemProvider.getVirtualFileSystem();
FolderEntry baseFolder = new FolderEntry(vfs.getRoot().createFolder(projectPath.toString()));
baseFolder.createFile(FILE_NAME, getClass().getClassLoader().getResourceAsStream("files/default_python_content"));
}
use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.
the class SimpleGeneratorStrategy method generateProject.
@Override
public void generateProject(Path projectPath, Map<String, AttributeValue> attributes, Map<String, String> options) throws ForbiddenException, ConflictException, ServerException {
AttributeValue artifactId = attributes.get(ARTIFACT_ID);
AttributeValue groupId = attributes.get(GROUP_ID);
AttributeValue version = attributes.get(VERSION);
if (artifactId == null) {
throw new ConflictException("Missed required attribute artifactId");
}
if (groupId == null) {
throw new ConflictException("Missed required attribute groupId");
}
if (version == null) {
throw new ConflictException("Missed required attribute version");
}
Model model = Model.createModel();
model.setModelVersion("4.0.0");
final FolderEntry baseFolder = new FolderEntry(vfs.getRoot().createFolder(projectPath.toString()));
if (baseFolder.getChild("pom.xml") == null) {
baseFolder.createFile("pom.xml", new byte[0]);
}
AttributeValue parentArtifactId = attributes.get(PARENT_ARTIFACT_ID);
if (parentArtifactId != null) {
model.setArtifactId(parentArtifactId.getString());
}
AttributeValue parentGroupId = attributes.get(PARENT_GROUP_ID);
if (parentGroupId != null) {
model.setGroupId(parentGroupId.getString());
}
AttributeValue parentVersion = attributes.get(PARENT_VERSION);
if (parentVersion != null) {
model.setVersion(parentVersion.getString());
}
model.setArtifactId(artifactId.getString());
model.setGroupId(groupId.getString());
model.setVersion(version.getString());
AttributeValue packaging = attributes.get(PACKAGING);
if (packaging != null) {
model.setPackaging(packaging.getString());
}
AttributeValue sourceFolders = attributes.get(SOURCE_FOLDER);
if (sourceFolders != null) {
final String sourceFolder = sourceFolders.getString();
baseFolder.createFolder(sourceFolder);
if (!DEFAULT_SOURCE_FOLDER.equals(sourceFolder)) {
model.setBuild(new Build().setSourceDirectory(sourceFolder));
}
}
AttributeValue testSourceFolders = attributes.get(TEST_SOURCE_FOLDER);
if (testSourceFolders != null) {
final String testSourceFolder = testSourceFolders.getString();
baseFolder.createFolder(testSourceFolder);
if (!DEFAULT_TEST_SOURCE_FOLDER.equals(testSourceFolder)) {
Build build = model.getBuild();
if (build != null) {
build.setTestSourceDirectory(testSourceFolder);
} else {
model.setBuild(new Build().setTestSourceDirectory(testSourceFolder));
}
}
}
model.writeTo(baseFolder.getChild("pom.xml").getVirtualFile());
}
use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.
the class WorkspaceTest method testRemovingModule.
@Test
public void testRemovingModule() throws Exception {
FolderEntry parentFolder = createMultimoduleProject();
IProject parent = ResourcesPlugin.getWorkspace().getRoot().getProject("parent");
mavenWorkspace.update(Collections.singletonList(parent));
mavenWorkspace.waitForUpdate();
assertThat(projectRegistry.getProjects()).hasSize(3).onProperty("path").containsOnly("/parent", "/parent/module1", "/parent/module2");
VirtualFile parentPom = parentFolder.getChild("pom.xml").getVirtualFile();
Model model = Model.readFrom(parentPom);
List<String> modules = new ArrayList<>(model.getModules());
ListIterator<String> listIterator = modules.listIterator();
while (listIterator.hasNext()) {
if ("module2".equals(listIterator.next())) {
listIterator.remove();
break;
}
}
model.setModules(modules);
model.writeTo(parentPom);
mavenWorkspace.update(Collections.singletonList(parent));
mavenWorkspace.waitForUpdate();
assertThat(projectRegistry.getProjects()).hasSize(2).onProperty("path").containsOnly("/parent", "/parent/module1");
}
use of org.eclipse.che.api.project.server.FolderEntry in project che by eclipse.
the class BaseTest method createTestProjectWithPackages.
protected void createTestProjectWithPackages(String projectName, String pom, String... packages) throws ForbiddenException, ConflictException, NotFoundException, ServerException {
FolderEntry testProject = createTestProject(projectName, pom);
FolderEntry src = testProject.createFolder("src/main/java");
for (String aPackage : packages) {
src.createFolder(aPackage.replace(".", "/"));
}
}
Aggregations