@SuppressWarnings("restriction") @Override public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException { markerManager.deleteMarkers(request.getProject(), MISSING_ENDORSED_DIRS_MARKER); IMavenProjectFacade mavenProjectFacade = request.getMavenProjectFacade(); File[] endorsedDirs = getEndorsedDirs(mavenProjectFacade, monitor); if (endorsedDirs == null || endorsedDirs.length == 0) { return; } Set<File> missingEndorsedDir = checkMissingDirs(endorsedDirs); if (!missingEndorsedDir.isEmpty()) { MojoExecutionKey key = new MojoExecutionKey( "org.apache.maven.plugins", "maven-compiler-plugin", null, null, null, null); SourceLocation sourceLocation = SourceLocationHelper.findLocation(mavenProjectFacade.getMavenProject(), key); for (File dir : missingEndorsedDir) { addMissingDirWarning(request.getProject(), sourceLocation, dir); } } }
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; }
private MavenProblemInfo checkValidLiferayVersion(Plugin liferayMavenPlugin, Xpp3Dom config) { MavenProblemInfo retval = null; Version liferayVersion = null; String liferayVersionValue = null; if (config != null) { // check for liferayVersion final Xpp3Dom liferayVersionNode = config.getChild(ILiferayMavenConstants.PLUGIN_CONFIG_LIFERAY_VERSION); if (liferayVersionNode != null) { liferayVersionValue = liferayVersionNode.getValue(); // handle the case where user specifies SNAPSHOT version liferayVersionValue = liferayVersionValue.replaceAll("-SNAPSHOT$", ""); // $NON-NLS-1$ //$NON-NLS-2$ try { liferayVersion = new Version(liferayVersionValue); } catch (IllegalArgumentException e) { // bad version } } } if (liferayVersion == null) { // could not get valid liferayVersion final SourceLocation location = SourceLocationHelper.findLocation(liferayMavenPlugin, null); final String problemMsg = NLS.bind( Msgs.invalidConfigValue, ILiferayMavenConstants.PLUGIN_CONFIG_LIFERAY_VERSION, liferayVersionValue); retval = new MavenProblemInfo(problemMsg, IMarker.SEVERITY_ERROR, location); } return retval; }
private MavenProblemInfo checkValidConfigDir( Plugin liferayMavenPlugin, Xpp3Dom config, String configParam) { MavenProblemInfo retval = null; if (configParam != null && config != null) { final Xpp3Dom configNode = config.getChild(configParam); if (configNode != null) { final String value = configNode.getValue(); if (!new File(value).exists()) { SourceLocation location = SourceLocationHelper.findLocation(liferayMavenPlugin, configParam); retval = new MavenProblemInfo( NLS.bind(Msgs.invalidConfigValue, configParam, value), IMarker.SEVERITY_ERROR, location); } } } return retval; }