use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class ClasspathBuilderTest method rawClasspathShouldBeContained3Arguments.
@Test
public void rawClasspathShouldBeContained3Arguments() throws Exception {
createTestProject();
library.add("/lib");
sourceFolders.add("/src");
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("/project");
IJavaProject iJavaProject = JavaCore.create(project);
classpathBuilder.generateClasspath(iJavaProject, sourceFolders, library);
List<IClasspathEntry> classpathEntries = Arrays.asList(iJavaProject.getRawClasspath());
assertThat(classpathEntries).onProperty("path").containsOnly(new Path(JREContainerInitializer.JRE_CONTAINER), new Path("/project/src"), new Path(root + "/project/lib/a.jar"));
}
use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class JavaProjectHelper method delete.
/**
* Removes an IJavaElement's resource. Retries if deletion failed (e.g. because the indexer
* still locks the file).
*
* @param elem the element to delete
* @throws CoreException if operation failed
* @see #ASSERT_NO_MIXED_LINE_DELIMIERS
*/
public static void delete(final IJavaElement elem) throws CoreException {
// MixedLineDelimiterDetector.assertNoMixedLineDelimiters(elem);
if (elem instanceof JavaProject) {
((JavaProject) elem).close();
JavaModelManager.getJavaModelManager().removePerProjectInfo((JavaProject) elem, true);
}
JavaModelManager.getJavaModelManager().resetTemporaryCache();
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
// performDummySearch();
if (elem instanceof IJavaProject) {
IJavaProject jproject = (IJavaProject) elem;
jproject.setRawClasspath(new IClasspathEntry[0], jproject.getProject().getFullPath(), null);
}
delete(elem.getResource());
}
};
ResourcesPlugin.getWorkspace().run(runnable, null);
// emptyDisplayLoop();
}
use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class ProjectTestSetup method createAndInitializeProject.
protected IJavaProject createAndInitializeProject() throws CoreException {
IJavaProject javaProject = JavaProjectHelper.createJavaProject(PROJECT_NAME, "bin");
javaProject.setRawClasspath(getDefaultClasspath(), null);
TestOptions.initializeProjectOptions(javaProject);
return javaProject;
}
use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class ClasspathUpdaterService method updateClasspath.
/**
* Updates the information about classpath.
*
* @param projectPath
* path to the current project
* @param entries
* list of classpath entries which need to set
* @throws JavaModelException
* if JavaModel has a failure
* @throws ServerException
* if some server error
* @throws ForbiddenException
* if operation is forbidden
* @throws ConflictException
* if update operation causes conflicts
* @throws NotFoundException
* if Project with specified path doesn't exist in workspace
* @throws IOException
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
public void updateClasspath(@QueryParam("projectpath") String projectPath, List<ClasspathEntryDto> entries) throws JavaModelException, ServerException, ForbiddenException, ConflictException, NotFoundException, IOException {
IJavaProject javaProject = model.getJavaProject(projectPath);
javaProject.setRawClasspath(createModifiedEntry(entries), javaProject.getOutputLocation(), new NullProgressMonitor());
updateProjectConfig(projectPath);
}
use of org.eclipse.jdt.core.IJavaProject in project che by eclipse.
the class PlainJavaProjectGeneratorTest method projectShouldBeCreatedWithDefaultContent.
@Test
public void projectShouldBeCreatedWithDefaultContent() throws Exception {
attributes = new HashMap<>();
options = new HashMap<>();
PlainJavaProjectGenerator generator = new PlainJavaProjectGenerator(vfsProvider, classpathBuilder);
generator.onCreateProject(Path.of("project"), attributes, options);
IJavaProject project = JavaModelManager.getJavaModelManager().getJavaModel().getJavaProject("project");
assertTrue(project.exists());
verify(classpathBuilder).generateClasspath(project, singletonList(DEFAULT_SOURCE_FOLDER_VALUE), singletonList(DEFAULT_LIBRARY_FOLDER_VALUE));
}
Aggregations