Search in sources :

Example 11 with IProject

use of org.eclipse.core.resources.IProject in project che by eclipse.

the class AbstractJavaInitHandler method onProjectInitialized.

@Override
public final void onProjectInitialized(ProjectRegistry registry, FolderEntry projectFolder) throws ServerException, ForbiddenException, ConflictException, NotFoundException {
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectFolder.getPath().toString());
    IJavaProject javaProject = JavaCore.create(project);
    initializeClasspath(javaProject);
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) IProject(org.eclipse.core.resources.IProject)

Example 12 with IProject

use of org.eclipse.core.resources.IProject in project che by eclipse.

the class PomChangeListener method updateProms.

//    @ScheduleDelay(initialDelay = 30, delay = 3)
protected void updateProms() {
    try {
        if (projectToUpdate.size() == 0) {
            return;
        }
        Set<String> projects = new HashSet<>(projectToUpdate);
        projectToUpdate.clear();
        IWorkspace workspace = eclipseWorkspaceProvider.get();
        List<IProject> projectsList = projects.stream().map(project -> workspace.getRoot().getProject(project)).collect(Collectors.toList());
        mavenWorkspace.update(projectsList);
    } catch (Throwable t) {
        JavaPlugin.log(t);
    }
}
Also used : JavaPlugin(org.eclipse.jdt.internal.ui.JavaPlugin) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) EventSubscriber(org.eclipse.che.api.core.notification.EventSubscriber) PomModifiedEventDto(org.eclipse.che.api.project.shared.dto.event.PomModifiedEventDto) Inject(com.google.inject.Inject) Set(java.util.Set) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) CopyOnWriteArraySet(java.util.concurrent.CopyOnWriteArraySet) ProjectItemModifiedEvent(org.eclipse.che.api.project.server.notification.ProjectItemModifiedEvent) Collectors(java.util.stream.Collectors) File(java.io.File) HashSet(java.util.HashSet) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) IProject(org.eclipse.core.resources.IProject) IWorkspace(org.eclipse.core.resources.IWorkspace) ThreadPullLauncher(org.eclipse.che.commons.schedule.executor.ThreadPullLauncher) Model(org.eclipse.che.ide.maven.tools.Model) Path(org.eclipse.core.runtime.Path) Named(com.google.inject.name.Named) Singleton(com.google.inject.Singleton) EventService(org.eclipse.che.api.core.notification.EventService) IWorkspace(org.eclipse.core.resources.IWorkspace) IProject(org.eclipse.core.resources.IProject) HashSet(java.util.HashSet)

Example 13 with IProject

use of org.eclipse.core.resources.IProject in project che by eclipse.

the class MavenServerService method reimportDependencies.

@POST
@Path("reimport")
@ApiOperation(value = "Re-import maven model")
@ApiResponses({ @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 500, message = "Internal Server Error") })
public Response reimportDependencies(@ApiParam(value = "The paths to projects which need to be reimported") @QueryParam("projectPath") List<String> paths) throws ServerException {
    IWorkspace workspace = eclipseWorkspaceProvider.get();
    List<IProject> projectsList = paths.stream().map(projectPath -> workspace.getRoot().getProject(projectPath)).collect(Collectors.toList());
    mavenWorkspace.update(projectsList);
    return Response.ok().build();
}
Also used : MavenWrapperManager(org.eclipse.che.plugin.maven.server.MavenWrapperManager) EclipseWorkspaceProvider(org.eclipse.che.plugin.maven.server.core.EclipseWorkspaceProvider) ResourcesPlugin(org.eclipse.core.resources.ResourcesPlugin) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ProjectRegistry(org.eclipse.che.api.project.server.ProjectRegistry) Inject(com.google.inject.Inject) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) XMLTreeException(org.eclipse.che.commons.xml.XMLTreeException) MavenProjectProblem(org.eclipse.che.maven.data.MavenProjectProblem) LoggerFactory(org.slf4j.LoggerFactory) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) MavenWorkspace(org.eclipse.che.plugin.maven.server.core.MavenWorkspace) ApiResponses(io.swagger.annotations.ApiResponses) ArrayList(java.util.ArrayList) ApiOperation(io.swagger.annotations.ApiOperation) Document(org.eclipse.jface.text.Document) MavenProgressNotifier(org.eclipse.che.plugin.maven.server.core.MavenProgressNotifier) QueryParam(javax.ws.rs.QueryParam) IProject(org.eclipse.core.resources.IProject) IWorkspace(org.eclipse.core.resources.IWorkspace) Model(org.eclipse.che.ide.maven.tools.Model) BadLocationException(org.eclipse.jface.text.BadLocationException) DtoFactory(org.eclipse.che.dto.server.DtoFactory) ClasspathManager(org.eclipse.che.plugin.maven.server.core.classpath.ClasspathManager) Logger(org.slf4j.Logger) POST(javax.ws.rs.POST) TEXT_XML(javax.ws.rs.core.MediaType.TEXT_XML) MavenServerWrapper(org.eclipse.che.plugin.maven.server.MavenServerWrapper) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) NotFoundException(org.eclipse.che.api.core.NotFoundException) SAXParseException(org.xml.sax.SAXParseException) List(java.util.List) ServerException(org.eclipse.che.api.core.ServerException) Response(javax.ws.rs.core.Response) MavenProjectManager(org.eclipse.che.plugin.maven.server.core.MavenProjectManager) ApiResponse(io.swagger.annotations.ApiResponse) ForbiddenException(org.eclipse.che.api.core.ForbiddenException) RegisteredProject(org.eclipse.che.api.project.server.RegisteredProject) Problem(org.eclipse.che.ide.ext.java.shared.dto.Problem) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) ProjectManager(org.eclipse.che.api.project.server.ProjectManager) Collections(java.util.Collections) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) IWorkspace(org.eclipse.core.resources.IWorkspace) IProject(org.eclipse.core.resources.IProject) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 14 with IProject

use of org.eclipse.core.resources.IProject in project che by eclipse.

the class PomReconcilerTest method testReconcilePomWhenPomContainsDependecyWithIncorrectVersion.

@Test
public void testReconcilePomWhenPomContainsDependecyWithIncorrectVersion() throws Exception {
    String brokenDependency = "    <dependency>\n" + "        <groupId>junit</groupId>\n" + "        <artifactId>junit</artifactId>\n" + "        <version>33333333.8.1</version>\n" + "        <scope>test</scope>\n" + "    </dependency>\n";
    MavenServerService serverService = new MavenServerService(null, projectRegistry, pm, projectManager, null, null);
    FolderEntry testProject = createTestProject(PROJECT_NAME, getPomContentWithDependency(brokenDependency));
    VirtualFileEntry pom = testProject.getChild("pom.xml");
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
    mavenWorkspace.update(Collections.singletonList(project));
    mavenWorkspace.waitForUpdate();
    List<Problem> problems = serverService.reconcilePom(String.format("/%s/pom.xml", PROJECT_NAME));
    assertThat(problems).hasSize(1);
    assertThat(problems.get(0).isError()).isTrue();
    assertThat(pom).isNotNull();
}
Also used : FolderEntry(org.eclipse.che.api.project.server.FolderEntry) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) MavenServerService(org.eclipse.che.plugin.maven.server.rest.MavenServerService) Problem(org.eclipse.che.ide.ext.java.shared.dto.Problem) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Example 15 with IProject

use of org.eclipse.core.resources.IProject in project che by eclipse.

the class PomReconcilerTest method testReconcilePomWhenPomContainsCorrectDependency.

@Test
public void testReconcilePomWhenPomContainsCorrectDependency() throws Exception {
    String dependency = "    <dependency>\n" + "        <groupId>junit</groupId>\n" + "        <artifactId>junit</artifactId>\n" + "        <version>3.8.1</version>\n" + "        <scope>test</scope>\n" + "    </dependency>\n";
    MavenServerService serverService = new MavenServerService(null, projectRegistry, pm, projectManager, null, null);
    FolderEntry testProject = createTestProject(PROJECT_NAME, getPomContentWithDependency(dependency));
    VirtualFileEntry pom = testProject.getChild("pom.xml");
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME);
    mavenWorkspace.update(Collections.singletonList(project));
    mavenWorkspace.waitForUpdate();
    List<Problem> problems = serverService.reconcilePom(String.format("/%s/pom.xml", PROJECT_NAME));
    assertThat(problems).isEmpty();
    assertThat(pom).isNotNull();
}
Also used : FolderEntry(org.eclipse.che.api.project.server.FolderEntry) VirtualFileEntry(org.eclipse.che.api.project.server.VirtualFileEntry) MavenServerService(org.eclipse.che.plugin.maven.server.rest.MavenServerService) Problem(org.eclipse.che.ide.ext.java.shared.dto.Problem) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test) MavenServerManagerTest(org.eclipse.che.plugin.maven.server.rmi.MavenServerManagerTest)

Aggregations

IProject (org.eclipse.core.resources.IProject)2658 IFile (org.eclipse.core.resources.IFile)642 CoreException (org.eclipse.core.runtime.CoreException)598 Test (org.junit.Test)483 IPath (org.eclipse.core.runtime.IPath)408 IFolder (org.eclipse.core.resources.IFolder)339 IResource (org.eclipse.core.resources.IResource)305 File (java.io.File)279 ArrayList (java.util.ArrayList)270 Path (org.eclipse.core.runtime.Path)268 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)259 IOException (java.io.IOException)201 IJavaProject (org.eclipse.jdt.core.IJavaProject)193 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)186 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)175 IProjectDescription (org.eclipse.core.resources.IProjectDescription)161 IWorkspace (org.eclipse.core.resources.IWorkspace)138 IStatus (org.eclipse.core.runtime.IStatus)124 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)116 List (java.util.List)109