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));
}
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);
}
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());
}
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;
}
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;
}
Aggregations