Search in sources :

Example 1 with IProjectConfigurationManager

use of org.eclipse.m2e.core.project.IProjectConfigurationManager in project liferay-ide by liferay.

the class MavenUtil method importProject.

public static List<IMavenProjectImportResult> importProject(String location, IProgressMonitor monitor) throws CoreException, InterruptedException {
    MavenModelManager mavenModelManager = MavenPlugin.getMavenModelManager();
    IWorkspaceRoot workspaceRoot = CoreUtil.getWorkspaceRoot();
    File root = workspaceRoot.getLocation().toFile();
    AbstractProjectScanner<MavenProjectInfo> scanner = new LocalProjectScanner(root, location, false, mavenModelManager);
    scanner.run(monitor);
    List<MavenProjectInfo> projects = scanner.getProjects();
    List<MavenProjectInfo> mavenProjects = new ArrayList<>();
    _findChildMavenProjects(mavenProjects, projects);
    mavenProjects = _filterProjects(mavenProjects);
    ProjectImportConfiguration importConfiguration = new ProjectImportConfiguration();
    IProjectConfigurationManager projectConfigurationManager = MavenPlugin.getProjectConfigurationManager();
    return projectConfigurationManager.importProjects(mavenProjects, importConfiguration, monitor);
}
Also used : IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) ProjectImportConfiguration(org.eclipse.m2e.core.project.ProjectImportConfiguration) LocalProjectScanner(org.eclipse.m2e.core.project.LocalProjectScanner) MavenProjectInfo(org.eclipse.m2e.core.project.MavenProjectInfo) ArrayList(java.util.ArrayList) IProjectConfigurationManager(org.eclipse.m2e.core.project.IProjectConfigurationManager) MavenModelManager(org.eclipse.m2e.core.embedder.MavenModelManager) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 2 with IProjectConfigurationManager

use of org.eclipse.m2e.core.project.IProjectConfigurationManager in project liferay-ide by liferay.

the class LiferayMavenProjectCustomJSPValidationTest method testCustomJspValidationConfigured.

@Test
@Ignore
public void testCustomJspValidationConfigured() throws Exception {
    final IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(LiferayMavenCore.PLUGIN_ID);
    ;
    prefs.putBoolean(LiferayMavenCore.PREF_DISABLE_CUSTOM_JSP_VALIDATION, true);
    IProject project = importProject("projects/configurators/customJspValidation/pom.xml");
    assertNotNull(project);
    IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().create(project, monitor);
    assertNotNull(facade);
    assertTrue(CoreUtil.isLiferayProject(project));
    final IProjectConfigurationManager projectConfigurationManager = MavenPlugin.getProjectConfigurationManager();
    projectConfigurationManager.updateProjectConfiguration(new MavenUpdateRequest(project, mavenConfiguration.isOffline(), true), monitor);
    waitForBuildAndValidation(project);
    final IMarker[] markers = project.findMarkers("org.eclipse.jst.jsp.core.validationMarker", true, IResource.DEPTH_INFINITE);
    for (IMarker marker : markers) {
        assertEquals(false, marker.getAttribute(IMarker.SEVERITY).equals(IMarker.SEVERITY_ERROR));
    }
    project.delete(true, monitor);
}
Also used : MavenUpdateRequest(org.eclipse.m2e.core.project.MavenUpdateRequest) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IProjectConfigurationManager(org.eclipse.m2e.core.project.IProjectConfigurationManager) IMarker(org.eclipse.core.resources.IMarker) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) IProject(org.eclipse.core.resources.IProject) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with IProjectConfigurationManager

use of org.eclipse.m2e.core.project.IProjectConfigurationManager in project jbosstools-openshift by jbosstools.

the class MavenProjectImportOperation method importToWorkspace.

public List<IProject> importToWorkspace(IProgressMonitor monitor) throws CoreException, InterruptedException {
    MavenPluginActivator mavenPlugin = MavenPluginActivator.getDefault();
    IProjectConfigurationManager configurationManager = mavenPlugin.getProjectConfigurationManager();
    MavenModelManager modelManager = mavenPlugin.getMavenModelManager();
    Set<MavenProjectInfo> projectInfos = getMavenProjects(getProjectDirectory(), filters, modelManager, monitor);
    ProjectImportConfiguration projectImportConfiguration = new ProjectImportConfiguration();
    if (overwriteMavenProjects(projectInfos, projectImportConfiguration, monitor)) {
        List<IMavenProjectImportResult> importResults = configurationManager.importProjects(projectInfos, projectImportConfiguration, monitor);
        return validate(toProjects(importResults));
    } else {
        return Collections.emptyList();
    }
}
Also used : MavenPluginActivator(org.eclipse.m2e.core.internal.MavenPluginActivator) IMavenProjectImportResult(org.eclipse.m2e.core.project.IMavenProjectImportResult) ProjectImportConfiguration(org.eclipse.m2e.core.project.ProjectImportConfiguration) IProjectConfigurationManager(org.eclipse.m2e.core.project.IProjectConfigurationManager) MavenProjectInfo(org.eclipse.m2e.core.project.MavenProjectInfo) MavenModelManager(org.eclipse.m2e.core.embedder.MavenModelManager)

Example 4 with IProjectConfigurationManager

use of org.eclipse.m2e.core.project.IProjectConfigurationManager in project mdw-designer by CenturyLinkCloud.

the class ProjectConfigurator method addMavenNature.

@SuppressWarnings("deprecation")
public void addMavenNature(IProgressMonitor monitor) throws CoreException {
    ResolverConfiguration configuration = new ResolverConfiguration();
    configuration.setResolveWorkspaceProjects(false);
    configuration.setActiveProfiles("");
    IProjectConfigurationManager configurationManager = MavenPlugin.getProjectConfigurationManager();
    configurationManager.enableMavenNature(project.getSourceProject(), configuration, monitor);
    configurationManager.updateProjectConfiguration(project.getSourceProject(), monitor);
}
Also used : ResolverConfiguration(org.eclipse.m2e.core.project.ResolverConfiguration) IProjectConfigurationManager(org.eclipse.m2e.core.project.IProjectConfigurationManager)

Example 5 with IProjectConfigurationManager

use of org.eclipse.m2e.core.project.IProjectConfigurationManager in project liferay-ide by liferay.

the class LiferayMavenProjectCustomJSPValidationTest method testNoCustomJspValidationConfigured.

@Test
@Ignore
public void testNoCustomJspValidationConfigured() throws Exception {
    final IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(LiferayMavenCore.PLUGIN_ID);
    ;
    prefs.putBoolean(LiferayMavenCore.PREF_DISABLE_CUSTOM_JSP_VALIDATION, false);
    IProject project = importProject("projects/configurators/customJspValidation/pom.xml");
    assertNotNull(project);
    IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().create(project, monitor);
    assertNotNull(facade);
    assertTrue(CoreUtil.isLiferayProject(project));
    final IProjectConfigurationManager projectConfigurationManager = MavenPlugin.getProjectConfigurationManager();
    projectConfigurationManager.updateProjectConfiguration(new MavenUpdateRequest(project, mavenConfiguration.isOffline(), true), monitor);
    waitForBuildAndValidation(project);
    final IMarker[] markers = project.findMarkers("org.eclipse.jst.jsp.core.validationMarker", true, IResource.DEPTH_INFINITE);
    for (IMarker marker : markers) {
        assertEquals(true, marker.getAttribute(IMarker.SEVERITY).equals(IMarker.SEVERITY_ERROR));
    }
    project.delete(true, monitor);
}
Also used : MavenUpdateRequest(org.eclipse.m2e.core.project.MavenUpdateRequest) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IProjectConfigurationManager(org.eclipse.m2e.core.project.IProjectConfigurationManager) IMarker(org.eclipse.core.resources.IMarker) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) IProject(org.eclipse.core.resources.IProject) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

IProjectConfigurationManager (org.eclipse.m2e.core.project.IProjectConfigurationManager)9 IProject (org.eclipse.core.resources.IProject)5 MavenUpdateRequest (org.eclipse.m2e.core.project.MavenUpdateRequest)4 ProjectImportConfiguration (org.eclipse.m2e.core.project.ProjectImportConfiguration)4 CoreException (org.eclipse.core.runtime.CoreException)3 MavenModelManager (org.eclipse.m2e.core.embedder.MavenModelManager)3 IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)3 ResolverConfiguration (org.eclipse.m2e.core.project.ResolverConfiguration)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 IFile (org.eclipse.core.resources.IFile)2 IMarker (org.eclipse.core.resources.IMarker)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)2 IMavenProjectImportResult (org.eclipse.m2e.core.project.IMavenProjectImportResult)2 MavenProjectInfo (org.eclipse.m2e.core.project.MavenProjectInfo)2 NewLiferayProfileOp (com.liferay.ide.maven.core.model.NewLiferayProfileOp)1 IPortletFramework (com.liferay.ide.project.core.IPortletFramework)1 NewLiferayProfile (com.liferay.ide.project.core.model.NewLiferayProfile)1 PluginType (com.liferay.ide.project.core.model.PluginType)1