Search in sources :

Example 1 with IMavenProjectFacade

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

the class MavenModuleProjectTests method testMavenDependencyUpdate.

@Test
public void testMavenDependencyUpdate() throws Exception {
    String[][] dependency = new String[][] { { "com.liferay.portal", "com.liferay.portal.kernel", "2.6.0" } };
    Dependency mavenDependency = new Dependency();
    mavenDependency.setGroupId(dependency[0][0]);
    mavenDependency.setArtifactId(dependency[0][1]);
    mavenDependency.setVersion(dependency[0][2]);
    final URL wsZipUrl = Platform.getBundle("com.liferay.ide.maven.core.tests").getEntry("projects/MavenDependencyTestProject.zip");
    final File wsZipFile = new File(FileLocator.toFileURL(wsZipUrl).getFile());
    File eclipseWorkspaceLocation = CoreUtil.getWorkspaceRoot().getLocation().toFile();
    ZipUtil.unzip(wsZipFile, eclipseWorkspaceLocation);
    File mavenDependencyTestProjectFolder = new File(eclipseWorkspaceLocation, "MavenDependencyTestProject");
    MavenUtil.importProject(mavenDependencyTestProjectFolder.getAbsolutePath(), monitor);
    waitForJobsToComplete(monitor);
    IProject mavenDependencyTestProject = CoreUtil.getProject("MavenDependencyTestProject");
    assertNotNull(mavenDependencyTestProject);
    assertTrue(mavenDependencyTestProject.exists());
    IMavenProjectFacade projectFacade = MavenUtil.getProjectFacade(mavenDependencyTestProject, new NullProgressMonitor());
    assertNotNull(projectFacade);
    MavenProject mavenProject = projectFacade.getMavenProject(new NullProgressMonitor());
    List<Dependency> existedDependencies = mavenProject.getDependencies();
    assertFalse(checkDependency(existedDependencies, mavenDependency));
    ILiferayProject liferayMavenDependencyProject = LiferayCore.create(mavenDependencyTestProject);
    IProjectBuilder projectBuilder = liferayMavenDependencyProject.adapt(IProjectBuilder.class);
    projectBuilder.updateProjectDependency(mavenDependencyTestProject, Arrays.asList(dependency));
    waitForJobsToComplete(monitor);
    MavenProject updateMavenProject = projectFacade.getMavenProject(new NullProgressMonitor());
    List<Dependency> updateDependencies = updateMavenProject.getDependencies();
    assertTrue(checkDependency(updateDependencies, mavenDependency));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) MavenProject(org.apache.maven.project.MavenProject) ILiferayProject(com.liferay.ide.core.ILiferayProject) Dependency(org.apache.maven.model.Dependency) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) IProjectBuilder(com.liferay.ide.project.core.IProjectBuilder) IFile(org.eclipse.core.resources.IFile) File(java.io.File) URL(java.net.URL) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 2 with IMavenProjectFacade

use of org.eclipse.m2e.core.project.IMavenProjectFacade 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 IMavenProjectFacade

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

the class VersionsTests method testFindLiferayVersionByProperties.

@Test
public void testFindLiferayVersionByProperties() throws Exception {
    IProject project = importProject("projects/versions/properties-portlet/pom.xml");
    assertNotNull(project);
    IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry().create(project, monitor);
    assertNotNull(facade);
    final ILiferayProject lrproject = LiferayCore.create(project);
    assertNotNull(lrproject);
    final ILiferayPortal portal = lrproject.adapt(ILiferayPortal.class);
    assertNotNull(portal);
    assertEquals("6.2.1", portal.getVersion());
}
Also used : ILiferayProject(com.liferay.ide.core.ILiferayProject) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 4 with IMavenProjectFacade

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

the class MavenConfigProblemMarkerResolutionGenerator method correctMarker.

@Override
protected boolean correctMarker(IMarker marker) {
    boolean retval = false;
    IProject project = marker.getResource().getProject();
    if (FileUtil.notExists(project)) {
        return false;
    }
    IMavenProjectFacade projectFacade = MavenPlugin.getMavenProjectRegistry().getProject(marker.getResource().getProject());
    if (projectFacade != null) {
        MavenProject mavenProject = null;
        IProgressMonitor npm = new NullProgressMonitor();
        try {
            mavenProject = projectFacade.getMavenProject(npm);
        } catch (CoreException ce) {
        }
        if (mavenProject != null) {
            try {
                Plugin liferayMavenPlugin = MavenUtil.getPlugin(projectFacade, ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_KEY, npm);
                if (liferayMavenPlugin != null) {
                    retval = true;
                }
            } catch (CoreException ce) {
            }
        }
    }
    return retval;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) MavenProject(org.apache.maven.project.MavenProject) CoreException(org.eclipse.core.runtime.CoreException) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) IProject(org.eclipse.core.resources.IProject) Plugin(org.apache.maven.model.Plugin) MavenPlugin(org.eclipse.m2e.core.MavenPlugin)

Example 5 with IMavenProjectFacade

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

the class MavenUIProjectBuilder method buildSB.

@Override
public IStatus buildSB(IFile serviceXmlFile, String goal, IProgressMonitor monitor) throws CoreException {
    IFile pomFile = getProject().getFile(new Path(IMavenConstants.POM_FILE_NAME));
    IMavenProjectFacade projectFacade = projectManager.create(pomFile, false, new NullProgressMonitor());
    monitor.worked(10);
    IStatus status = runMavenGoal(projectFacade, goal, "run", monitor);
    refreshSiblingProject(projectFacade, monitor);
    monitor.worked(10);
    monitor.done();
    return status;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade)

Aggregations

IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)52 MavenProject (org.apache.maven.project.MavenProject)21 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)19 IProject (org.eclipse.core.resources.IProject)18 CoreException (org.eclipse.core.runtime.CoreException)18 IPath (org.eclipse.core.runtime.IPath)14 IFile (org.eclipse.core.resources.IFile)12 File (java.io.File)11 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)10 Path (org.eclipse.core.runtime.Path)10 IStatus (org.eclipse.core.runtime.IStatus)9 Test (org.junit.Test)9 MavenPlugin (org.eclipse.m2e.core.MavenPlugin)6 Plugin (org.apache.maven.model.Plugin)5 IFolder (org.eclipse.core.resources.IFolder)5 ICallable (org.eclipse.m2e.core.embedder.ICallable)5 IMavenExecutionContext (org.eclipse.m2e.core.embedder.IMavenExecutionContext)5 FacetedMavenProject (com.liferay.ide.maven.core.FacetedMavenProject)4 ArrayList (java.util.ArrayList)4 IMavenProjectRegistry (org.eclipse.m2e.core.project.IMavenProjectRegistry)4