Search in sources :

Example 1 with ProjectConfigurationManager

use of org.eclipse.m2e.core.internal.project.ProjectConfigurationManager in project m2e-core-tests by tesla.

the class ImportSortOrderTestCase method testCollectionSortProject.

@Test
public void testCollectionSortProject() throws Exception {
    ProjectConfigurationManager manager = (ProjectConfigurationManager) MavenPlugin.getProjectConfigurationManager();
    List<IMavenProjectFacade> facades = createFacades();
    manager.sortProjects(facades, monitor);
    Map<String, Integer> aMap = new HashMap<>();
    for (int i = 0; i < facades.size(); i++) {
        aMap.put(facades.get(i).getArtifactKey().getArtifactId(), Integer.valueOf(i));
    }
    assertResultMap(aMap);
}
Also used : ProjectConfigurationManager(org.eclipse.m2e.core.internal.project.ProjectConfigurationManager) HashMap(java.util.HashMap) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) Test(org.junit.Test)

Example 2 with ProjectConfigurationManager

use of org.eclipse.m2e.core.internal.project.ProjectConfigurationManager in project tesb-studio-se by Talend.

the class ExportServiceAction method createSimpleProject.

private ITalendProcessJavaProject createSimpleProject(IProgressMonitor monitor, IProject p, Model model, ProjectImportConfiguration importConfiguration) throws CoreException {
    final String[] directories = getFolders();
    ProjectConfigurationManager projectConfigurationManager = (ProjectConfigurationManager) MavenPlugin.getProjectConfigurationManager();
    String projectName = p.getName();
    monitor.beginTask(NLS.bind(Messages.ProjectConfigurationManager_task_creating, projectName), 5);
    monitor.subTask(Messages.ProjectConfigurationManager_task_creating_workspace);
    ITalendProcessJavaProject javaProject = TalendJavaProjectManager.getTalendJobJavaProject(serviceItem.getProperty());
    // ITalendProcessJavaProject javaProject =
    // TalendJavaProjectManager.getTalendCodeJavaProject(ERepositoryObjectType.PROCESS);
    p.open(monitor);
    monitor.worked(1);
    // hideNestedProjectsFromParents(Collections.singletonList(p));
    monitor.worked(1);
    monitor.subTask(Messages.ProjectConfigurationManager_task_creating_pom);
    IFile pomFile = p.getFile(TalendMavenConstants.POM_FILE_NAME);
    if (!pomFile.exists()) {
        MavenPlugin.getMavenModelManager().createMavenModel(pomFile, model);
    }
    monitor.worked(1);
    monitor.subTask(Messages.ProjectConfigurationManager_task_creating_folders);
    for (int i = 0; i < directories.length; i++) {
        ProjectConfigurationManager.createFolder(p.getFolder(directories[i]), false);
    }
    monitor.worked(1);
    monitor.subTask(Messages.ProjectConfigurationManager_task_creating_project);
    projectConfigurationManager.enableMavenNature(p, importConfiguration.getResolverConfiguration(), monitor);
    monitor.worked(1);
    return javaProject;
}
Also used : IFile(org.eclipse.core.resources.IFile) ProjectConfigurationManager(org.eclipse.m2e.core.internal.project.ProjectConfigurationManager) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject)

Example 3 with ProjectConfigurationManager

use of org.eclipse.m2e.core.internal.project.ProjectConfigurationManager in project m2e-core by eclipse-m2e.

the class UpdateMavenProjectJob method runInWorkspace.

@Override
public IStatus runInWorkspace(IProgressMonitor monitor) {
    ProjectConfigurationManager configurationManager = (ProjectConfigurationManager) MavenPlugin.getProjectConfigurationManager();
    setProperty(IProgressConstants.ACTION_PROPERTY, new OpenMavenConsoleAction());
    MavenUpdateRequest request = new MavenUpdateRequest(projects, offline, forceUpdateDependencies);
    Map<String, IStatus> updateStatus = configurationManager.updateProjectConfiguration(request, updateConfiguration, cleanProjects, refreshFromLocal, monitor);
    Map<String, Throwable> errorMap = new LinkedHashMap<>();
    ArrayList<IStatus> errors = new ArrayList<>();
    for (Map.Entry<String, IStatus> entry : updateStatus.entrySet()) {
        if (!entry.getValue().isOK()) {
            errors.add(entry.getValue());
            errorMap.put(entry.getKey(), new CoreException(entry.getValue()));
        }
    }
    if (errorMap.size() > 0) {
        handleErrors(errorMap);
    }
    IStatus status = Status.OK_STATUS;
    if (errors.size() == 1) {
        status = errors.get(0);
    } else {
        status = new MultiStatus(M2EUIPluginActivator.PLUGIN_ID, -1, errors.toArray(new IStatus[errors.size()]), Messages.UpdateSourcesAction_error_cannot_update, null);
    }
    return status;
}
Also used : MavenUpdateRequest(org.eclipse.m2e.core.project.MavenUpdateRequest) IStatus(org.eclipse.core.runtime.IStatus) ProjectConfigurationManager(org.eclipse.m2e.core.internal.project.ProjectConfigurationManager) ArrayList(java.util.ArrayList) MultiStatus(org.eclipse.core.runtime.MultiStatus) OpenMavenConsoleAction(org.eclipse.m2e.core.ui.internal.actions.OpenMavenConsoleAction) LinkedHashMap(java.util.LinkedHashMap) CoreException(org.eclipse.core.runtime.CoreException) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 4 with ProjectConfigurationManager

use of org.eclipse.m2e.core.internal.project.ProjectConfigurationManager in project eclipse.jdt.ls by eclipse.

the class MavenBuildSupport method update.

@Override
public void update(IProject project, boolean force, IProgressMonitor monitor) throws CoreException {
    if (!applies(project)) {
        return;
    }
    Path pomPath = project.getFile("pom.xml").getLocation().toFile().toPath();
    if (digestStore.updateDigest(pomPath) || force) {
        JavaLanguageServerPlugin.logInfo("Starting Maven update for " + project.getName());
        boolean updateSnapshots = JavaLanguageServerPlugin.getPreferencesManager() == null ? false : JavaLanguageServerPlugin.getPreferencesManager().getPreferences().isMavenUpdateSnapshots();
        if (shouldCollectProjects()) {
            Set<IProject> projectSet = new LinkedHashSet<>();
            collectProjects(projectSet, project, monitor);
            IProject[] projects = projectSet.toArray(new IProject[0]);
            MavenUpdateRequest request = new MavenUpdateRequest(projects, MavenPlugin.getMavenConfiguration().isOffline(), updateSnapshots);
            ((ProjectConfigurationManager) configurationManager).updateProjectConfiguration(request, true, true, monitor);
        } else {
            MavenUpdateRequest request = new MavenUpdateRequest(project, MavenPlugin.getMavenConfiguration().isOffline(), updateSnapshots);
            configurationManager.updateProjectConfiguration(request, monitor);
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(java.nio.file.Path) LinkedHashSet(java.util.LinkedHashSet) MavenUpdateRequest(org.eclipse.m2e.core.project.MavenUpdateRequest) ProjectConfigurationManager(org.eclipse.m2e.core.internal.project.ProjectConfigurationManager) IProjectConfigurationManager(org.eclipse.m2e.core.project.IProjectConfigurationManager) IProject(org.eclipse.core.resources.IProject)

Aggregations

ProjectConfigurationManager (org.eclipse.m2e.core.internal.project.ProjectConfigurationManager)4 MavenUpdateRequest (org.eclipse.m2e.core.project.MavenUpdateRequest)2 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 IStatus (org.eclipse.core.runtime.IStatus)1 MultiStatus (org.eclipse.core.runtime.MultiStatus)1 IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)1 IProjectConfigurationManager (org.eclipse.m2e.core.project.IProjectConfigurationManager)1 OpenMavenConsoleAction (org.eclipse.m2e.core.ui.internal.actions.OpenMavenConsoleAction)1 Test (org.junit.Test)1 ITalendProcessJavaProject (org.talend.core.runtime.process.ITalendProcessJavaProject)1