Search in sources :

Example 1 with SourceLocation

use of org.eclipse.m2e.core.internal.markers.SourceLocation 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;
}
Also used : SourceLocation(org.eclipse.m2e.core.internal.markers.SourceLocation) Action(org.eclipse.wst.common.project.facet.core.IFacetedProject.Action) CoreException(org.eclipse.core.runtime.CoreException) MavenProblemInfo(org.eclipse.m2e.core.internal.markers.MavenProblemInfo) Plugin(org.apache.maven.model.Plugin)

Example 2 with SourceLocation

use of org.eclipse.m2e.core.internal.markers.SourceLocation 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;
}
Also used : SourceLocation(org.eclipse.m2e.core.internal.markers.SourceLocation) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Version(org.osgi.framework.Version) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) ArrayList(java.util.ArrayList) MavenProblemInfo(org.eclipse.m2e.core.internal.markers.MavenProblemInfo) Plugin(org.apache.maven.model.Plugin)

Example 3 with SourceLocation

use of org.eclipse.m2e.core.internal.markers.SourceLocation 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;
}
Also used : SourceLocation(org.eclipse.m2e.core.internal.markers.SourceLocation) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) Version(org.osgi.framework.Version) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) MavenProblemInfo(org.eclipse.m2e.core.internal.markers.MavenProblemInfo)

Example 4 with SourceLocation

use of org.eclipse.m2e.core.internal.markers.SourceLocation 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;
}
Also used : SourceLocation(org.eclipse.m2e.core.internal.markers.SourceLocation) Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) IFile(org.eclipse.core.resources.IFile) File(java.io.File) MavenProblemInfo(org.eclipse.m2e.core.internal.markers.MavenProblemInfo)

Aggregations

MavenProblemInfo (org.eclipse.m2e.core.internal.markers.MavenProblemInfo)4 SourceLocation (org.eclipse.m2e.core.internal.markers.SourceLocation)4 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)3 Plugin (org.apache.maven.model.Plugin)2 IProjectFacetVersion (org.eclipse.wst.common.project.facet.core.IProjectFacetVersion)2 Version (org.osgi.framework.Version)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 IFile (org.eclipse.core.resources.IFile)1 CoreException (org.eclipse.core.runtime.CoreException)1 Action (org.eclipse.wst.common.project.facet.core.IFacetedProject.Action)1