Search in sources :

Example 6 with SDK

use of com.liferay.ide.sdk.core.SDK in project liferay-ide by liferay.

the class SDKBuildPropertiesResourceListener method visit.

@Override
public boolean visit(IResourceDelta delta) throws CoreException {
    switch(delta.getResource().getType()) {
        case IResource.ROOT:
        case IResource.PROJECT:
        case IResource.FOLDER:
            return true;
        case IResource.FILE:
            IFile deltaFile = (IFile) delta.getResource();
            Job job = new WorkspaceJob("Processing SDK build properties file") {

                @Override
                public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                    try {
                        boolean hasMultipleSDK = _checkMultipleSDK(monitor);
                        if (hasMultipleSDK) {
                            return Status.OK_STATUS;
                        }
                        IPath deltaLocation = deltaFile.getLocation();
                        if (deltaLocation != null) {
                            SDK sdk = SDKUtil.getWorkspaceSDK();
                            if (sdk.getLocation().isPrefixOf(deltaLocation)) {
                                processPropertiesFileChanged(deltaFile);
                            }
                        }
                    } catch (CoreException ce) {
                        ProjectCore.logError(ce);
                    }
                    return Status.OK_STATUS;
                }
            };
            job.schedule();
    }
    return false;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) SDK(com.liferay.ide.sdk.core.SDK) Job(org.eclipse.core.runtime.jobs.Job) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob)

Example 7 with SDK

use of com.liferay.ide.sdk.core.SDK in project liferay-ide by liferay.

the class SDKClasspathContainerInitializer method _getSDKDependencies.

private IPath[] _getSDKDependencies(IJavaProject project) {
    IPath path = project.getProject().getLocation();
    SDK sdk = SDKUtil.getSDKFromProjectDir(path.toFile());
    if (sdk == null) {
        return null;
    }
    return sdk.getDependencyJarPaths();
}
Also used : IPath(org.eclipse.core.runtime.IPath) SDK(com.liferay.ide.sdk.core.SDK)

Example 8 with SDK

use of com.liferay.ide.sdk.core.SDK in project liferay-ide by liferay.

the class PluginClasspathContainer method createContextClasspathEntry.

protected IClasspathEntry createContextClasspathEntry(String context) {
    IClasspathEntry entry = null;
    IFile serviceJar = ComponentUtil.findServiceJarForContext(context);
    if (serviceJar.exists()) {
        IWebProject webproject = LiferayCore.create(IWebProject.class, serviceJar.getProject());
        if ((webproject != null) && (webproject.getDefaultDocrootFolder() != null)) {
            IFolder defaultDocroot = webproject.getDefaultDocrootFolder();
            IFolder serviceFolder = defaultDocroot.getFolder(new Path("WEB-INF/service"));
            if (serviceFolder.exists()) {
                entry = createClasspathEntry(serviceJar.getLocation(), serviceFolder.getLocation());
            }
        }
        if (entry == null) {
            entry = createClasspathEntry(serviceJar.getLocation(), null);
        }
    }
    if (entry == null) {
        IProject project = this.javaProject.getProject();
        SDK sdk = SDKUtil.getSDK(project);
        IPath sdkLocation = sdk.getLocation();
        String type = StringPool.EMPTY;
        if (ProjectUtil.isPortletProject(project)) {
            type = "portlets";
        } else if (ProjectUtil.isHookProject(project)) {
            type = "hooks";
        } else if (ProjectUtil.isExtProject(project)) {
            type = "ext";
        }
        IPath contextPath = sdkLocation.append(type).append(context);
        String libFolder = ISDKConstants.DEFAULT_DOCROOT_FOLDER + "/WEB-INF/lib";
        IPath serviceJarPath = contextPath.append(libFolder).append(context + "-service.jar");
        if (serviceJarPath.toFile().exists()) {
            IPath servicePath = serviceJarPath.removeLastSegments(2).append("service");
            entry = createClasspathEntry(serviceJarPath, servicePath.toFile().exists() ? servicePath : null);
        }
    }
    return entry;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) IWebProject(com.liferay.ide.core.IWebProject) SDK(com.liferay.ide.sdk.core.SDK) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Example 9 with SDK

use of com.liferay.ide.sdk.core.SDK in project liferay-ide by liferay.

the class PluginsSDKBundleProject method getSDK.

public SDK getSDK() {
    SDK retval = null;
    // try to determine SDK based on project location
    IPath rawLocation = getProject().getRawLocation();
    IPath sdkLocation = rawLocation.removeLastSegments(2);
    retval = SDKManager.getInstance().getSDK(sdkLocation);
    if (retval == null) {
        retval = SDKUtil.createSDKFromLocation(sdkLocation);
        SDKManager.getInstance().addSDK(retval);
    }
    return retval;
}
Also used : IPath(org.eclipse.core.runtime.IPath) SDK(com.liferay.ide.sdk.core.SDK)

Example 10 with SDK

use of com.liferay.ide.sdk.core.SDK in project liferay-ide by liferay.

the class PluginsSDKBundleProject method getOutputBundlePath.

@Override
public IPath getOutputBundlePath() {
    IPath retval = null;
    SDK sdk = getSDK();
    IStatus status = sdk.validate();
    if (!status.isOK()) {
        return retval;
    }
    IPath distPath = sdk.getLocation().append("dist");
    File[] distFiles = distPath.toFile().listFiles(new FilenameFilter() {

        @Override
        public boolean accept(File dir, String name) {
            IPath location = getProject().getLocation();
            return name.contains(location.lastSegment());
        }
    });
    try {
        retval = new Path(distFiles[0].getCanonicalPath());
    } catch (IOException ioe) {
        ProjectCore.createErrorStatus(ioe);
    }
    return retval;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) FilenameFilter(java.io.FilenameFilter) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) SDK(com.liferay.ide.sdk.core.SDK) IOException(java.io.IOException) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Aggregations

SDK (com.liferay.ide.sdk.core.SDK)75 IPath (org.eclipse.core.runtime.IPath)41 CoreException (org.eclipse.core.runtime.CoreException)29 IStatus (org.eclipse.core.runtime.IStatus)26 IProject (org.eclipse.core.resources.IProject)24 Path (org.eclipse.sapphire.modeling.Path)16 File (java.io.File)15 IFile (org.eclipse.core.resources.IFile)14 Path (org.eclipse.core.runtime.Path)14 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)12 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11 Version (org.osgi.framework.Version)11 IOException (java.io.IOException)9 Status (org.eclipse.sapphire.modeling.Status)9 IFolder (org.eclipse.core.resources.IFolder)7 Test (org.junit.Test)7 ArrayList (java.util.ArrayList)6 IWebProject (com.liferay.ide.core.IWebProject)4 IPortletFramework (com.liferay.ide.project.core.IPortletFramework)4 PluginType (com.liferay.ide.project.core.model.PluginType)4