use of org.eclipse.m2e.core.internal.markers.MavenProblemInfo in project liferay-ide by liferay.
the class LiferayMavenProjectConfigurator method _installNewLiferayFacet.
// Copied from
// org.eclipse.m2e.wtp.AbstractProjectConfiguratorDelegate#configureDeployedName()
private MavenProblemInfo _installNewLiferayFacet(IFacetedProject facetedProject, ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException {
MavenProblemInfo retval = null;
String pluginType = MavenUtil.getLiferayMavenPluginType(request.getMavenProject());
if (pluginType == null) {
pluginType = ILiferayMavenConstants.DEFAULT_PLUGIN_TYPE;
}
Plugin liferayMavenPlugin = MavenUtil.getPlugin(request.getMavenProjectFacade(), ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_KEY, monitor);
Action action = _getNewLiferayFacetInstallAction(pluginType);
if (action != null) {
try {
facetedProject.modify(Collections.singleton(action), monitor);
} catch (Exception e) {
try {
SourceLocation location = SourceLocationHelper.findLocation(liferayMavenPlugin, SourceLocationHelper.CONFIGURATION);
String problemMsg = NLS.bind(Msgs.facetInstallError, pluginType, e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
retval = new MavenProblemInfo(location, e);
retval.setMessage(problemMsg);
} catch (Exception e1) {
}
LiferayMavenCore.logError("Unable to install liferay facet " + action.getProjectFacetVersion(), e.getCause());
}
}
return retval;
}
use of org.eclipse.m2e.core.internal.markers.MavenProblemInfo in project liferay-ide by liferay.
the class LiferayMavenProjectConfigurator method configure.
@Override
public void configure(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException {
if (monitor == null) {
monitor = new NullProgressMonitor();
}
monitor.beginTask(NLS.bind(Msgs.configuringLiferayProject, request.getProject()), 100);
Plugin liferayMavenPlugin = MavenUtil.getPlugin(request.getMavenProjectFacade(), ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_KEY, monitor);
if (!_shouldConfigure(liferayMavenPlugin, request)) {
monitor.done();
return;
}
IProject project = request.getProject();
IFile pomFile = project.getFile(IMavenConstants.POM_FILE_NAME);
IFacetedProject facetedProject = ProjectFacetsManager.create(project, false, monitor);
_removeLiferayMavenMarkers(project);
monitor.worked(25);
MavenProject mavenProject = request.getMavenProject();
List<MavenProblemInfo> errors = _findLiferayMavenPluginProblems(request, monitor);
if (ListUtil.isNotEmpty(errors)) {
try {
markerManager.addErrorMarkers(pomFile, ILiferayMavenConstants.LIFERAY_MAVEN_MARKER_CONFIGURATION_WARNING_ID, errors);
} catch (CoreException ce) {
// no need to log this error its just best effort
}
}
monitor.worked(25);
MavenProblemInfo installProblem = null;
if (_shouldInstallNewLiferayFacet(facetedProject)) {
installProblem = _installNewLiferayFacet(facetedProject, request, monitor);
}
if (_shouldAddLiferayNature(mavenProject, facetedProject)) {
LiferayNature.addLiferayNature(project, monitor);
}
monitor.worked(25);
if (installProblem != null) {
this.markerManager.addMarker(pomFile, ILiferayMavenConstants.LIFERAY_MAVEN_MARKER_CONFIGURATION_WARNING_ID, installProblem.getMessage(), installProblem.getLocation().getLineNumber(), IMarker.SEVERITY_WARNING);
} else {
String pluginType = MavenUtil.getLiferayMavenPluginType(mavenProject);
// IDE-817 we need to mak sure that on deployment it will have the correct
// suffix for project name
IVirtualComponent projectComponent = ComponentCore.createComponent(project);
try {
if (projectComponent != null) {
String deployedName = projectComponent.getDeployedName();
Matcher m = _versionPattern.matcher(deployedName);
if (m.matches()) {
deployedName = m.group(1);
configureDeployedName(project, deployedName);
}
if (pluginType != null) {
String pluginTypeSuffix = "-" + pluginType;
String deployedFileName = project.getName() + pluginTypeSuffix;
if ((deployedName == null) || ((deployedName != null) && !deployedName.endsWith(pluginTypeSuffix))) {
configureDeployedName(project, deployedFileName);
}
String oldContextRoot = ComponentUtilities.getServerContextRoot(project);
if ((oldContextRoot == null) || ((oldContextRoot != null) && !oldContextRoot.endsWith(pluginTypeSuffix))) {
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(LiferayMavenCore.PLUGIN_ID);
boolean setMavenPluginSuffix = prefs.getBoolean(LiferayMavenCore.PREF_ADD_MAVEN_PLUGIN_SUFFIX, false);
if (setMavenPluginSuffix) {
ComponentUtilities.setServerContextRoot(project, deployedFileName);
}
}
}
}
} catch (Exception e) {
LiferayMavenCore.logError("Unable to configure deployed name for project " + project.getName(), e);
}
if (ILiferayMavenConstants.THEME_PLUGIN_TYPE.equals(pluginType)) {
IVirtualComponent component = ComponentCore.createComponent(project, true);
if (component != null) {
// make sure to update the main deployment folder
WarPluginConfiguration config = new WarPluginConfiguration(mavenProject, project);
String warSourceDirectory = config.getWarSourceDirectory();
IFolder contentFolder = project.getFolder(warSourceDirectory);
IPath warPath = _rootPath.append(contentFolder.getProjectRelativePath());
IPath themeFolder = _rootPath.append(getThemeTargetFolder(mavenProject, project));
// add a link to our m2e-liferay/theme-resources folder into deployment assembly
WTPProjectsUtil.insertLinkBefore(project, themeFolder, warPath, _rootPath, monitor);
}
}
}
if ((project != null) && ProjectUtil.isHookProject(project)) {
HookDescriptorHelper hookDescriptor = new HookDescriptorHelper(project);
String customJSPFolder = hookDescriptor.getCustomJSPFolder(null);
if (customJSPFolder != null) {
IWebProject webproject = LiferayCore.create(IWebProject.class, project);
if ((webproject != null) && (webproject.getDefaultDocrootFolder() != null)) {
IFolder docFolder = webproject.getDefaultDocrootFolder();
IPath newPath = Path.fromOSString(customJSPFolder);
IPath pathValue = docFolder.getFullPath().append(newPath);
boolean disableCustomJspValidation = LiferayMavenCore.getPreferenceBoolean(LiferayMavenCore.PREF_DISABLE_CUSTOM_JSP_VALIDATION);
if (disableCustomJspValidation) {
HookUtil.configureJSPSyntaxValidationExclude(project, project.getFolder(pathValue.makeRelativeTo(project.getFullPath())), true);
}
}
}
}
monitor.worked(25);
monitor.done();
}
use of org.eclipse.m2e.core.internal.markers.MavenProblemInfo in project liferay-ide by liferay.
the class LiferayMavenProjectConfigurator method _findLiferayMavenPluginProblems.
private List<MavenProblemInfo> _findLiferayMavenPluginProblems(ProjectConfigurationRequest request, IProgressMonitor monitor) throws CoreException {
List<MavenProblemInfo> warnings = new ArrayList<>();
// first check to make sure that the AppServer* properties are available and
// pointed to valid location
Plugin liferayMavenPlugin = MavenUtil.getPlugin(request.getMavenProjectFacade(), ILiferayMavenConstants.LIFERAY_MAVEN_PLUGIN_KEY, monitor);
if (liferayMavenPlugin != null) {
Xpp3Dom config = (Xpp3Dom) liferayMavenPlugin.getConfiguration();
MavenProblemInfo validLiferayProblemInfo = _checkValidVersion(liferayMavenPlugin, config, ILiferayMavenConstants.PLUGIN_CONFIG_LIFERAY_VERSION);
if (validLiferayProblemInfo != null) {
warnings.add(validLiferayProblemInfo);
}
Version mavenPluginVersion = new Version(MavenUtil.getVersion(liferayMavenPlugin.getVersion()));
if ((mavenPluginVersion == null) || mavenPluginVersion.equals(ILiferayConstants.EMPTY_VERSION)) {
// could not get valid version for liferaymavenPlugin
SourceLocation location = SourceLocationHelper.findLocation(liferayMavenPlugin, "version");
String problemMsg = NLS.bind(Msgs.invalidVersion, "liferay-maven-plugin", liferayMavenPlugin.getVersion());
MavenProblemInfo versionProblem = new MavenProblemInfo(problemMsg, IMarker.SEVERITY_WARNING, location);
warnings.add(versionProblem);
}
String[] configDirParams = { ILiferayMavenConstants.PLUGIN_CONFIG_APP_SERVER_PORTAL_DIR };
for (String configParam : configDirParams) {
MavenProblemInfo configProblemInfo = _checkValidConfigDir(liferayMavenPlugin, config, configParam);
if (configProblemInfo != null) {
warnings.add(configProblemInfo);
}
}
}
return warnings;
}
use of org.eclipse.m2e.core.internal.markers.MavenProblemInfo in project liferay-ide by liferay.
the class LiferayMavenProjectConfigurator method _checkValidVersion.
private MavenProblemInfo _checkValidVersion(Plugin plugin, Xpp3Dom config, String versionNodeName) {
MavenProblemInfo retval = null;
Version liferayVersion = null;
String version = null;
if (config != null) {
// check for version config node
Xpp3Dom versionNode = config.getChild(versionNodeName);
if (versionNode != null) {
version = versionNode.getValue();
try {
liferayVersion = new Version(MavenUtil.getVersion(version));
} catch (IllegalArgumentException iae) {
// bad version
}
}
}
if ((liferayVersion == null) || liferayVersion.equals(ILiferayConstants.EMPTY_VERSION)) {
// could not get valid liferayVersion
SourceLocation location = SourceLocationHelper.findLocation(plugin, SourceLocationHelper.CONFIGURATION);
String problemMsg = NLS.bind(Msgs.unusableConfigValue, versionNodeName, version);
retval = new MavenProblemInfo(problemMsg, IMarker.SEVERITY_WARNING, location);
}
return retval;
}
use of org.eclipse.m2e.core.internal.markers.MavenProblemInfo in project liferay-ide by liferay.
the class LiferayMavenProjectConfigurator method _checkValidConfigDir.
private MavenProblemInfo _checkValidConfigDir(Plugin liferayMavenPlugin, Xpp3Dom config, String configParam) {
MavenProblemInfo retval = null;
String message = null;
String value = null;
if (configParam != null) {
if (config == null) {
message = NLS.bind(Msgs.missingConfigValue, configParam);
} else {
Xpp3Dom dirNode = config.getChild(configParam);
if (dirNode == null) {
message = NLS.bind(Msgs.missingConfigValue, configParam);
} else {
value = dirNode.getValue();
if (CoreUtil.isNullOrEmpty(value)) {
message = NLS.bind(Msgs.emptyConfigValue, configParam);
} else {
File configDir = new File(value);
if (FileUtil.notExists(configDir) || !configDir.isDirectory()) {
message = NLS.bind(Msgs.unusableConfigValue, configParam, value);
}
}
}
}
}
if (message != null) {
SourceLocation location = SourceLocationHelper.findLocation(liferayMavenPlugin, SourceLocationHelper.CONFIGURATION);
retval = new MavenProblemInfo(message, IMarker.SEVERITY_WARNING, location);
}
return retval;
}
Aggregations