use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.
the class WorkspaceTest method testProjectNameUsedFromPom.
@Test
public void testProjectNameUsedFromPom() throws Exception {
String pom = "<groupId>test</groupId>" + "<artifactId>testArtifact</artifactId>" + "<version>42</version>" + " <name>testName</name>" + "<dependencies>" + " <dependency>" + " <groupId>junit</groupId>" + " <artifactId>junit</artifactId>" + " <version>4.12</version>" + " </dependency>" + "</dependencies>";
createTestProject("test", pom);
IProject test = ResourcesPlugin.getWorkspace().getRoot().getProject("test");
mavenWorkspace.update(Collections.singletonList(test));
mavenWorkspace.waitForUpdate();
MavenProject mavenProject = mavenProjectManager.findMavenProject(test);
String name = mavenProject.getName();
assertThat(name).isNotNull().isNotEmpty().isEqualTo("testName");
}
use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.
the class ClasspathManagerTest method setUp.
@BeforeMethod
public void setUp() throws Exception {
Provider<ProjectRegistry> projectRegistryProvider = (Provider<ProjectRegistry>) mock(Provider.class);
when(projectRegistryProvider.get()).thenReturn(projectRegistry);
MavenServerManagerTest.MyMavenServerProgressNotifier mavenNotifier = new MavenServerManagerTest.MyMavenServerProgressNotifier();
MavenTerminal terminal = (level, message, throwable) -> {
System.out.println(message);
if (throwable != null) {
throwable.printStackTrace();
}
};
localRepository = new File(new File("target/localRepo").getAbsolutePath());
localRepository.mkdirs();
mavenServerManager.setLocalRepository(localRepository);
MavenWrapperManager wrapperManager = new MavenWrapperManager(mavenServerManager);
mavenProjectManager = new MavenProjectManager(wrapperManager, mavenServerManager, terminal, mavenNotifier, new EclipseWorkspaceProvider());
classpathManager = new ClasspathManager(root.getAbsolutePath(), wrapperManager, mavenProjectManager, terminal, mavenNotifier);
mavenWorkspace = new MavenWorkspace(mavenProjectManager, mavenNotifier, new MavenExecutorService(), projectRegistryProvider, new MavenCommunication() {
@Override
public void sendUpdateMassage(Set<MavenProject> updated, List<MavenProject> removed) {
}
@Override
public void sendNotification(NotificationMessage message) {
System.out.println(message.toString());
}
@Override
public void send(JsonObject object, MessageType type) {
}
}, classpathManager, eventService, new EclipseWorkspaceProvider());
}
use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.
the class MavenProjectManagerTest method testNotValidResolveProject.
@Test
public void testNotValidResolveProject() throws Exception {
when(project.getFile(MavenConstants.POM_FILE_NAME)).thenReturn(pom);
when(pom.getLocation()).thenReturn(new Path(MavenProjectManagerTest.class.getResource("/BadProject/pom.xml").getFile()));
when(pom.getFullPath()).thenReturn(new Path("/BadProject/pom.xml"));
when(project.getFullPath()).thenReturn(new Path("/BadProject"));
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());
assertThat(mavenProject.getProblems()).isNotNull().isNotEmpty();
mavenProject.getProblems().forEach(System.out::println);
}
use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.
the class MavenProjectManager method update.
public void update(List<IProject> projects, boolean recursive) {
if (projects.isEmpty()) {
return;
}
mavenNotifier.start();
UpdateState state = new UpdateState();
Deque<MavenProject> stack = new LinkedList<>();
for (IProject project : projects) {
MavenProject mavenProject = findMavenProject(project);
if (mavenProject != null) {
internalUpdate(mavenProject, findParentProject(mavenProject), false, recursive, state, stack);
} else {
internalAddMavenProject(project, recursive, state, stack);
}
}
mavenNotifier.stop();
state.fireUpdate();
}
use of org.eclipse.che.plugin.maven.server.core.project.MavenProject in project che by eclipse.
the class MavenProjectManager method findDependentProjects.
public List<MavenProject> findDependentProjects(List<MavenProject> projects) {
readLock.lock();
try {
List<MavenProject> result = new ArrayList<>();
Set<MavenKey> mavenKeys = projects.stream().map(MavenProject::getMavenKey).collect(Collectors.toSet());
Set<String> paths = projects.stream().map(project -> project.getProject().getFullPath().toOSString()).collect(Collectors.toSet());
for (MavenProject project : projectToMavenProjectMap.values()) {
boolean isAdd = false;
for (String path : project.getModulesPath()) {
if (paths.contains(path)) {
isAdd = true;
break;
}
}
if (!isAdd) {
for (MavenArtifact artifact : project.getDependencies()) {
if (contains(mavenKeys, artifact.getArtifactId(), artifact.getGroupId(), artifact.getVersion())) {
isAdd = true;
break;
}
}
}
if (isAdd) {
result.add(project);
}
}
return result;
} finally {
readLock.unlock();
}
}
Aggregations