private MavenProblemInfo installNewLiferayFacet( IFacetedProject facetedProject, MavenProject mavenProject, IProgressMonitor monitor) { MavenProblemInfo retval = null; final String pluginType = getLiferayMavenPluginType(mavenProject); final Plugin liferayMavenPlugin = LiferayMavenUtil.getLiferayMavenPlugin(mavenProject); final Action action = getNewLiferayFacetInstallAction(pluginType); if (action != null) { try { facetedProject.modify(Collections.singleton(action), monitor); } catch (Exception e) { final SourceLocation location = SourceLocationHelper.findLocation(liferayMavenPlugin, null); final String problemMsg = NLS.bind( Msgs.facetInstallError, pluginType, e.getCause() != null ? e.getCause().getMessage() : e.getMessage()); retval = new MavenProblemInfo(location, e); retval.setMessage(problemMsg); LiferayMavenCore.logError( "Unable to install liferay facet " + action.getProjectFacetVersion(), e.getCause()); // $NON-NLS-1$ } final IProject project = facetedProject.getProject(); try { // IDE-817 we need to mak sure that on deployment it will have the correct suffix for // project name final IVirtualComponent projectComponent = ComponentCore.createComponent(project); if (projectComponent != null) { final String deployedName = projectComponent.getDeployedName(); if (deployedName == null || (deployedName != null && !deployedName.endsWith(pluginType))) { final String deployedFileName = project.getName() + "-" + pluginType; // $NON-NLS-1$ configureDeployedName(project, deployedFileName); projectComponent.setMetaProperty("context-root", deployedFileName); // $NON-NLS-1$ } } } catch (Exception e) { LiferayMavenCore.logError( "Unable to configure component for liferay deployment." + project.getName(), e); //$NON-NLS-1$ } } return retval; }
@Override public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException { final MavenProject mavenProject = request.getMavenProject(); final Plugin liferayMavenPlugin = LiferayMavenUtil.getLiferayMavenPlugin(mavenProject); if (!shouldConfigure(liferayMavenPlugin)) { return; } final IProject project = request.getProject(); final IFile pomFile = project.getFile(IMavenConstants.POM_FILE_NAME); final IFacetedProject facetedProject = ProjectFacetsManager.create(project, false, monitor); removeLiferayMavenMarkers(project); final List<MavenProblemInfo> errors = findLiferayMavenPluginProblems(project, mavenProject); if (errors.size() > 0) { try { this.markerManager.addErrorMarkers( pomFile, ILiferayMavenConstants.LIFERAY_MAVEN_MARKER_CONFIGURATION_ERROR_ID, errors); } catch (CoreException e) { // no need to log this error its just best effort } return; } if (shouldInstallNewLiferayFacet(facetedProject)) { final MavenProblemInfo installProblem = installNewLiferayFacet(facetedProject, mavenProject, monitor); if (installProblem != null) { this.markerManager.addMarker( pomFile, ILiferayMavenConstants.LIFERAY_MAVEN_MARKER_CONFIGURATION_ERROR_ID, installProblem.getMessage(), installProblem.getLocation().getLineNumber(), IMarker.SEVERITY_WARNING); } } }