Search in sources :

Example 26 with SDK

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

the class PluginsSDKNameDefaultValueService method compute.

@Override
protected String compute() {
    String value = null;
    SDK defaultSDK = SDKManager.getInstance().getDefaultSDK();
    if (defaultSDK != null) {
        value = defaultSDK.getName();
    } else {
        value = NONE;
    }
    return value;
}
Also used : SDK(com.liferay.ide.sdk.core.SDK)

Example 27 with SDK

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

the class NewLiferayPluginProjectMavenTests method testProjectProviderListener.

@Test
public void testProjectProviderListener() throws Exception {
    if (shouldSkipBundleTests())
        return;
    final NewLiferayPluginProjectOp op = newProjectOp("test-project-provider-listener");
    final String projectName = op.getProjectName().content();
    op.setPluginType("portlet");
    op.setUseDefaultLocation(true);
    final SDK sdk = SDKUtil.createSDKFromLocation(getLiferayPluginsSdkDir());
    IPath exceptedLocation = null;
    op.setProjectProvider("ant");
    exceptedLocation = sdk.getLocation().append("portlets").append(projectName + "-portlet");
    assertEquals(exceptedLocation, PathBridge.create(op.getLocation().content()));
    op.setProjectProvider("maven");
    exceptedLocation = CoreUtil.getWorkspaceRoot().getLocation().append(projectName);
    assertEquals(exceptedLocation, PathBridge.create(op.getLocation().content()));
}
Also used : IPath(org.eclipse.core.runtime.IPath) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) SDK(com.liferay.ide.sdk.core.SDK) Test(org.junit.Test)

Example 28 with SDK

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

the class NewLiferayPluginProjectMavenTests method testUseDefaultLocationListener.

protected void testUseDefaultLocationListener(boolean versionRestriction) throws Exception {
    final NewLiferayPluginProjectOp op = newProjectOp("test-use-default-location-listener");
    final String projectName = op.getProjectName().content();
    op.setProjectProvider("maven");
    IPath exceptedLocation = null;
    op.setUseDefaultLocation(true);
    exceptedLocation = CoreUtil.getWorkspaceRoot().getLocation().append(projectName);
    assertEquals(exceptedLocation, PathBridge.create(op.getLocation().content()));
    op.setUseDefaultLocation(false);
    assertEquals(null, op.getLocation().content());
    if (versionRestriction) {
        op.setProjectProvider("ant");
        op.setPluginType("portlet");
        op.setUseDefaultLocation(true);
        final SDK sdk = SDKUtil.createSDKFromLocation(getLiferayPluginsSdkDir());
        exceptedLocation = sdk.getLocation().append("portlets").append(projectName + "-portlet");
        assertEquals(exceptedLocation, PathBridge.create(op.getLocation().content()));
        op.setUseDefaultLocation(false);
        assertEquals(null, op.getLocation().content());
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) SDK(com.liferay.ide.sdk.core.SDK)

Example 29 with SDK

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

the class SdkLocationValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    int countPossibleWorkspaceSDKProjects = SDKUtil.countPossibleWorkspaceSDKProjects();
    if (countPossibleWorkspaceSDKProjects > 1) {
        return StatusBridge.create(ProjectCore.createErrorStatus("This workspace has more than one SDK. "));
    }
    Value<Path> sdkLocationValue = _op().getSdkLocation();
    Path sdkLocation = sdkLocationValue.content(true);
    if ((sdkLocation == null) || sdkLocation.isEmpty()) {
        return StatusBridge.create(ProjectCore.createErrorStatus("This sdk location is empty "));
    }
    SDK sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkLocation));
    if (sdk != null) {
        IStatus status = sdk.validate(true);
        if (!status.isOK()) {
            return StatusBridge.create(status);
        }
    } else {
        return StatusBridge.create(ProjectCore.createErrorStatus("This sdk location is not correct"));
    }
    return retval;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.sapphire.modeling.Status) Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus) SDK(com.liferay.ide.sdk.core.SDK)

Example 30 with SDK

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

the class ProjectImportUtil method createWorkspaceProjects.

/**
 * This will create the Eclipse Workspace projects
 *
 * @param monitor
 * @throws CoreException
 */
public static void createWorkspaceProjects(Object[] projects, IRuntime runtime, String sdkLocation, IProgressMonitor monitor) throws CoreException {
    List<IProject> createdProjects = new ArrayList<>();
    monitor.beginTask(Msgs.creatingSDKWorkspaceProjects, projects.length);
    if (ListUtil.isNotEmpty(projects)) {
        SDK sdk = SDKManager.getInstance().getSDK(new Path(sdkLocation));
        if (sdk == null) {
            sdk = SDKUtil.createSDKFromLocation(new Path(sdkLocation));
        }
        if ((sdk != null) && sdk.isValid() && !(SDKManager.getInstance().containsSDK(sdk))) {
            SDKManager.getInstance().addSDK(sdk);
        }
    }
    for (int i = 0; i < projects.length; i++) {
        if (projects[i] instanceof ProjectRecord) {
            IProject project = importProject((ProjectRecord) projects[i], runtime, sdkLocation, monitor);
            if (project != null) {
                createdProjects.add(project);
                monitor.worked(createdProjects.size());
            }
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ArrayList(java.util.ArrayList) ProjectRecord(com.liferay.ide.project.core.ProjectRecord) BinaryProjectRecord(com.liferay.ide.project.core.BinaryProjectRecord) SDK(com.liferay.ide.sdk.core.SDK) IProject(org.eclipse.core.resources.IProject)

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