Search in sources :

Example 31 with ILiferayPortal

use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.

the class FacetedMavenProject method adapt.

@Override
public <T> T adapt(Class<T> adapterType) {
    T adapter = super.adapt(adapterType);
    if (adapter != null) {
        return adapter;
    }
    IMavenProjectFacade facade = MavenUtil.getProjectFacade(getProject(), new NullProgressMonitor());
    if (facade != null) {
        if (ILiferayPortal.class.equals(adapterType)) {
            ILiferayPortal portal = new LiferayPortalMaven(this);
            return adapterType.cast(portal);
        }
    }
    return null;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IMavenProjectFacade(org.eclipse.m2e.core.project.IMavenProjectFacade) ILiferayPortal(com.liferay.ide.core.ILiferayPortal)

Example 32 with ILiferayPortal

use of com.liferay.ide.core.ILiferayPortal 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)32 ILiferayProject (com.liferay.ide.core.ILiferayProject)29 IPath (org.eclipse.core.runtime.IPath)13 IFile (org.eclipse.core.resources.IFile)10 IProject (org.eclipse.core.resources.IProject)10 CoreException (org.eclipse.core.runtime.CoreException)8 IOException (java.io.IOException)7 Version (org.osgi.framework.Version)7 ArrayList (java.util.ArrayList)4 IWebProject (com.liferay.ide.core.IWebProject)3 Hook (com.liferay.ide.hook.core.model.Hook)3 File (java.io.File)3 Properties (java.util.Properties)3 JarFile (java.util.jar.JarFile)3 Path (org.eclipse.core.runtime.Path)3 InputStream (java.io.InputStream)2 HashSet (java.util.HashSet)2 ZipEntry (java.util.zip.ZipEntry)2 ConfigurationException (org.apache.commons.configuration.ConfigurationException)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2