Search in sources :

Example 1 with IMavenProject

use of com.liferay.ide.maven.core.IMavenProject in project liferay-ide by liferay.

the class MavenProjectAdapter method adapt.

public <T> T adapt(ILiferayProject liferayProject, Class<T> adapterType) {
    if (liferayProject instanceof IMavenProject && IProjectBuilder.class.equals(adapterType)) {
        // only use this builder for versions of Liferay less than 6.2
        ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
        if (portal != null) {
            String version = portal.getVersion();
            if (!CoreUtil.isNullOrEmpty(version)) {
                // we only need to match the first 2 characters
                Matcher matcher = _majorMinor.matcher(version);
                String matchedVersion = null;
                if (matcher.find() && (matcher.groupCount() == 2)) {
                    matchedVersion = matcher.group(1) + "." + matcher.group(2) + ".0";
                }
                Version portalVersion = new Version(matchedVersion != null ? matchedVersion : version);
                if (CoreUtil.compareVersions(portalVersion, ILiferayConstants.V620) < 0) {
                    MavenUIProjectBuilder builder = new MavenUIProjectBuilder((FacetedMavenProject) liferayProject);
                    return adapterType.cast(builder);
                }
            }
        }
    }
    return null;
}
Also used : IMavenProject(com.liferay.ide.maven.core.IMavenProject) Matcher(java.util.regex.Matcher) Version(org.osgi.framework.Version) IProjectBuilder(com.liferay.ide.project.core.IProjectBuilder) ILiferayPortal(com.liferay.ide.core.ILiferayPortal)

Aggregations

ILiferayPortal (com.liferay.ide.core.ILiferayPortal)1 IMavenProject (com.liferay.ide.maven.core.IMavenProject)1 IProjectBuilder (com.liferay.ide.project.core.IProjectBuilder)1 Matcher (java.util.regex.Matcher)1 Version (org.osgi.framework.Version)1