Search in sources :

Example 1 with MavenProjectModifications

use of org.eclipse.che.plugin.maven.server.core.project.MavenProjectModifications in project che by eclipse.

the class MavenProjectManager method resolveMavenProject.

public void resolveMavenProject(IProject project, MavenProject mavenProject) {
    MavenServerWrapper mavenServer = wrapperManager.getMavenServer(MavenWrapperManager.ServerType.RESOLVE);
    try {
        mavenNotifier.setText("Resolving project: " + mavenProject.getName());
        mavenServer.customize(copyWorkspaceCache(), terminal, mavenNotifier, false, true);
        MavenProjectModifications modifications = mavenProject.resolve(project, mavenServer, serverManager);
        dispatcher.projectResolved(mavenProject, modifications);
    } finally {
        wrapperManager.release(mavenServer);
    }
}
Also used : MavenServerWrapper(org.eclipse.che.plugin.maven.server.MavenServerWrapper) MavenProjectModifications(org.eclipse.che.plugin.maven.server.core.project.MavenProjectModifications)

Example 2 with MavenProjectModifications

use of org.eclipse.che.plugin.maven.server.core.project.MavenProjectModifications in project che by eclipse.

the class MavenProjectManager method internalUpdate.

private void internalUpdate(MavenProject mavenProject, MavenProject parentProject, boolean isNew, boolean recursive, UpdateState state, Deque<MavenProject> stack) {
    if (stack.contains(mavenProject)) {
        //recursion
        return;
    }
    stack.addFirst(mavenProject);
    mavenNotifier.setText("Reading pom: " + mavenProject.getPomPath());
    List<MavenProject> oldModules = findModules(mavenProject);
    Set<MavenProject> oldChilds = new HashSet<>();
    if (!isNew) {
        oldChilds.addAll(findChildProjects(mavenProject));
    }
    writeLock.lock();
    try {
        if (!isNew) {
            clearMavenKeyMap(mavenProject);
        }
    } finally {
        writeLock.unlock();
    }
    MavenProjectModifications modifications = new MavenProjectModifications();
    //re read maven project meta info from pom.xml
    modifications = modifications.addChanges(mavenProject.read(serverManager));
    writeLock.lock();
    try {
        fillMavenKeyMap(mavenProject);
        projectToMavenProjectMap.put(mavenProject.getProject(), mavenProject);
    } finally {
        writeLock.unlock();
    }
    if (isNew) {
        addToChild(parentProject, mavenProject);
    } else {
        updateChild(parentProject, mavenProject);
    }
    //        if (hasparent) {
    state.addUpdate(mavenProject, modifications);
    //        }
    List<IProject> modules = mavenProject.getModulesProjects();
    List<MavenProject> removedModules = oldModules.stream().filter(oldModule -> !modules.contains(oldModule.getProject())).collect(Collectors.toList());
    for (MavenProject removedModule : removedModules) {
        removeModule(mavenProject, removedModule);
        internalDelete(mavenProject, removedModule, state);
        oldChilds.removeAll(state.removedProjects);
    }
    for (IProject module : modules) {
        MavenProject project = findMavenProject(module);
        boolean isNewProject = project == null;
        if (isNewProject) {
            project = new MavenProject(module, workspaceProvider.get());
        } else {
            MavenProject parent = findParentProject(project);
            if (parent != null && parent != mavenProject) {
                //TODO add log
                continue;
            }
        }
        if (isNewProject || recursive) {
            internalUpdate(project, mavenProject, isNewProject, recursive, state, stack);
        } else {
            if (updateChild(mavenProject, project)) {
                state.addUpdate(project, new MavenProjectModifications());
            }
        }
    }
    oldChilds.addAll(findChildProjects(mavenProject));
    for (MavenProject oldModule : oldChilds) {
        internalUpdate(oldModule, findParentProject(oldModule), false, false, state, stack);
    }
    stack.pop();
}
Also used : MavenServerManager(org.eclipse.che.plugin.maven.server.MavenServerManager) MavenWrapperManager(org.eclipse.che.plugin.maven.server.MavenWrapperManager) Proxy(java.lang.reflect.Proxy) Inject(com.google.inject.Inject) HashMap(java.util.HashMap) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) MavenArtifact(org.eclipse.che.maven.data.MavenArtifact) Deque(java.util.Deque) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) IProject(org.eclipse.core.resources.IProject) IWorkspace(org.eclipse.core.resources.IWorkspace) Map(java.util.Map) LinkedList(java.util.LinkedList) Set(java.util.Set) MavenServerWrapper(org.eclipse.che.plugin.maven.server.MavenServerWrapper) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) MavenProjectModifications(org.eclipse.che.plugin.maven.server.core.project.MavenProjectModifications) Provider(com.google.inject.Provider) MavenKey(org.eclipse.che.maven.data.MavenKey) List(java.util.List) Lock(java.util.concurrent.locks.Lock) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) MavenWorkspaceCache(org.eclipse.che.maven.data.MavenWorkspaceCache) Collections(java.util.Collections) Singleton(com.google.inject.Singleton) MavenTerminal(org.eclipse.che.maven.server.MavenTerminal) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) MavenProject(org.eclipse.che.plugin.maven.server.core.project.MavenProject) MavenProjectModifications(org.eclipse.che.plugin.maven.server.core.project.MavenProjectModifications) IProject(org.eclipse.core.resources.IProject) HashSet(java.util.HashSet)

Aggregations

MavenServerWrapper (org.eclipse.che.plugin.maven.server.MavenServerWrapper)2 MavenProjectModifications (org.eclipse.che.plugin.maven.server.core.project.MavenProjectModifications)2 Inject (com.google.inject.Inject)1 Provider (com.google.inject.Provider)1 Singleton (com.google.inject.Singleton)1 Proxy (java.lang.reflect.Proxy)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 Deque (java.util.Deque)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Set (java.util.Set)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Lock (java.util.concurrent.locks.Lock)1 ReentrantReadWriteLock (java.util.concurrent.locks.ReentrantReadWriteLock)1 Collectors (java.util.stream.Collectors)1