Search in sources :

Example 11 with MavenKey

use of org.eclipse.che.maven.data.MavenKey in project che by eclipse.

the class MavenProjectManager method fillMavenKeyMap.

private void fillMavenKeyMap(MavenProject mavenProject) {
    MavenKey mavenKey = mavenProject.getMavenKey();
    mavenWorkspaceCache.put(mavenKey, mavenProject.getPomFile());
    keyToProjectMap.put(mavenKey, mavenProject);
}
Also used : MavenKey(org.eclipse.che.maven.data.MavenKey)

Example 12 with MavenKey

use of org.eclipse.che.maven.data.MavenKey in project che by eclipse.

the class MavenModelReader method fillModelByDefaults.

private void fillModelByDefaults(MavenModel model) {
    model.setMavenKey(new MavenKey("unknown", "unknown", "unknown"));
    final MavenKey parentKey = new MavenKey("unknown", "unknown", "unknown");
    model.setParent(new MavenParent(parentKey, "../pom.xml"));
    model.setPackaging("jar");
    model.setModules(emptyList());
    final MavenBuild build = model.getBuild();
    build.setSources(singletonList(DEFAULT_SOURCE_FOLDER));
    build.setTestSources(singletonList(DEFAULT_TEST_SOURCE_FOLDER));
    build.setResources(singletonList(new MavenResource(DEFAULT_RESOURCES_FOLDER, false, null, Collections.emptyList(), Collections.emptyList())));
    build.setTestResources(singletonList(new MavenResource(DEFAULT_TEST_RESOURCES_FOLDER, false, null, Collections.emptyList(), Collections.emptyList())));
}
Also used : MavenBuild(org.eclipse.che.maven.data.MavenBuild) MavenKey(org.eclipse.che.maven.data.MavenKey) MavenResource(org.eclipse.che.maven.data.MavenResource) MavenParent(org.eclipse.che.maven.data.MavenParent)

Example 13 with MavenKey

use of org.eclipse.che.maven.data.MavenKey in project che by eclipse.

the class MavenProjectManagerTest method testUpdateProject.

@Test
public void testUpdateProject() throws Exception {
    when(project.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(pom);
    when(pom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/FirstProject/pom.xml").getFile()));
    when(pom.getFullPath()).thenReturn(new Path("/FirstProject/pom.xml"));
    when(project.getFullPath()).thenReturn(new Path("/FirstProject/"));
    projectManager.addListener(listener);
    MavenProject mavenProject = new MavenProject(project, workspace);
    mavenProject.read(project, manager);
    MavenKey mavenKey = mavenProject.getMavenKey();
    assertThat(mavenKey).isNotNull();
    projectManager.update(Collections.singletonList(project), true);
    verify(listener).projectUpdated(mapArgument.capture(), any());
}
Also used : Path(org.eclipse.core.runtime.Path) MavenKey(org.eclipse.che.maven.data.MavenKey) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) Test(org.testng.annotations.Test)

Example 14 with MavenKey

use of org.eclipse.che.maven.data.MavenKey in project che by eclipse.

the class MavenProjectManagerTest method testUpdateMultimoduleProject.

@Test
public void testUpdateMultimoduleProject() throws Exception {
    IProject testProject = mock(IProject.class);
    IFile testPom = mock(IFile.class);
    IProject subModuleProject = mock(IProject.class);
    IFile subPom = mock(IFile.class);
    IFile testFile = mock(IFile.class);
    when(project.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(pom);
    when(pom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/multimoduleProject/pom.xml").getFile()));
    when(pom.getFullPath()).thenReturn(new Path("/multimoduleProject/pom.xml"));
    when(project.getFullPath()).thenReturn(new Path("/multimoduleProject/"));
    when(testProject.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(testPom);
    when(subModuleProject.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(subPom);
    when(testProject.getFullPath()).thenReturn(new Path("/multimoduleProject/test"));
    when(subModuleProject.getFullPath()).thenReturn(new Path("/multimoduleProject/subModule"));
    when(testPom.getFullPath()).thenReturn(new Path("/multimoduleProject/test/pom.xml"));
    when(subPom.getFullPath()).thenReturn(new Path("/multimoduleProject/subModule/pom.xml"));
    when(testPom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/multimoduleProject/test/pom.xml").getFile()));
    when(subPom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/multimoduleProject/subModule/pom.xml").getFile()));
    when(workspaceRoot.getProject("/multimoduleProject/test")).thenReturn(testProject);
    when(workspaceRoot.getProject("/multimoduleProject/subModule")).thenReturn(subModuleProject);
    when(workspaceRoot.getFile(any())).thenReturn(testFile);
    when(testFile.exists()).thenReturn(false);
    projectManager.addListener(listener);
    MavenProject mavenProject = new MavenProject(project, workspace);
    mavenProject.read(project, manager);
    MavenKey mavenKey = mavenProject.getMavenKey();
    assertThat(mavenKey).isNotNull();
    projectManager.update(Collections.singletonList(project), true);
    verify(listener).projectUpdated(mapArgument.capture(), any());
}
Also used : Path(org.eclipse.core.runtime.Path) MavenKey(org.eclipse.che.maven.data.MavenKey) IFile(org.eclipse.core.resources.IFile) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) IProject(org.eclipse.core.resources.IProject) Test(org.testng.annotations.Test)

Example 15 with MavenKey

use of org.eclipse.che.maven.data.MavenKey in project che by eclipse.

the class MavenProjectManagerTest method testResolveProject.

@Test
public void testResolveProject() throws Exception {
    when(project.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(pom);
    when(pom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/FirstProject/pom.xml").getFile()));
    when(pom.getFullPath()).thenReturn(new Path("/FirstProject/pom.xml"));
    when(project.getFullPath()).thenReturn(new Path("/FirstProject/"));
    projectManager.addListener(listener);
    MavenProject mavenProject = new MavenProject(project, workspace);
    mavenProject.read(project, manager);
    MavenKey mavenKey = mavenProject.getMavenKey();
    assertThat(mavenKey).isNotNull();
    projectManager.resolveMavenProject(project, mavenProject);
    verify(listener).projectResolved(any(), any());
}
Also used : Path(org.eclipse.core.runtime.Path) MavenKey(org.eclipse.che.maven.data.MavenKey) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) Test(org.testng.annotations.Test)

Aggregations

MavenKey (org.eclipse.che.maven.data.MavenKey)17 MavenModel (org.eclipse.che.maven.data.MavenModel)6 MavenProject (org.eclipse.che.plugin.maven.server.core.project.MavenProject)6 Test (org.testng.annotations.Test)6 HashSet (java.util.HashSet)4 MavenParent (org.eclipse.che.maven.data.MavenParent)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 MavenArtifact (org.eclipse.che.maven.data.MavenArtifact)3 MavenBuild (org.eclipse.che.maven.data.MavenBuild)3 MavenWorkspaceCache (org.eclipse.che.maven.data.MavenWorkspaceCache)3 IProject (org.eclipse.core.resources.IProject)3 Path (org.eclipse.core.runtime.Path)3 HashMap (java.util.HashMap)2 Properties (java.util.Properties)2 Parent (org.apache.maven.model.Parent)2 MavenProjectProblem (org.eclipse.che.maven.data.MavenProjectProblem)2 Inject (com.google.inject.Inject)1 Provider (com.google.inject.Provider)1 Singleton (com.google.inject.Singleton)1