Search in sources :

Example 1 with IWorkspaceProjectBuilder

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

the class InitConfigureProjectPage method _createInitBundle.

private void _createInitBundle(IProgressMonitor monitor) throws CoreException {
    SubMonitor progress = SubMonitor.convert(monitor, 100);
    try {
        progress.beginTask("Execute Liferay Worksapce Bundle Init Command...", 100);
        String layout = dataModel.getLayout().content();
        if (layout.equals(_layoutNames[0])) {
            IPath sdkLocation = PathBridge.create(dataModel.getSdkLocation().content());
            IProject project = CoreUtil.getProject(sdkLocation.lastSegment());
            final String bundleUrl = dataModel.getBundleUrl().content();
            final String bundleName = dataModel.getBundleName().content();
            IWorkspaceProjectBuilder projectBuilder = _getWorkspaceProjectBuilder(project);
            progress.worked(30);
            if (bundleUrl != null && projectBuilder != null) {
                projectBuilder.initBundle(project, bundleUrl, monitor);
            }
            IPath bundleLocationDir = sdkLocation.append("bundles");
            if (bundleLocationDir.toFile().exists()) {
                progress.worked(60);
                final IPath runtimeLocation = sdkLocation.append(LiferayWorkspaceUtil.getHomeDir(sdkLocation.toOSString()));
                ServerUtil.addPortalRuntimeAndServer(bundleName, runtimeLocation, monitor);
                IServer bundleServer = ServerCore.findServer(dataModel.getBundleName().content());
                if (bundleServer != null) {
                    org.eclipse.sapphire.modeling.Path newPath = dataModel.getSdkLocation().content();
                    SDK sdk = SDKUtil.createSDKFromLocation(PathBridge.create(newPath).append("plugins-sdk"));
                    IPath bundleLocation = bundleServer.getRuntime().getLocation();
                    sdk.addOrUpdateServerProperties(bundleLocation);
                }
                project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
            }
        }
        progress.worked(100);
    } catch (Exception e) {
        ProjectUI.logError(e);
        throw new CoreException(StatusBridge.create(Status.createErrorStatus("Failed to execute Liferay Workspace Bundle Init Command...", e)));
    } finally {
        progress.done();
    }
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) SubMonitor(org.eclipse.core.runtime.SubMonitor) IWorkspaceProjectBuilder(com.liferay.ide.project.core.IWorkspaceProjectBuilder) SDK(com.liferay.ide.sdk.core.SDK) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) BladeCLIException(com.liferay.ide.project.core.modules.BladeCLIException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) JDOMException(org.jdom.JDOMException)

Example 2 with IWorkspaceProjectBuilder

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

the class InitConfigureProjectPage method _getWorkspaceProjectBuilder.

private IWorkspaceProjectBuilder _getWorkspaceProjectBuilder(IProject project) throws CoreException {
    final ILiferayProject liferayProject = LiferayCore.create(project);
    if (liferayProject == null) {
        throw new CoreException(ProjectUI.createErrorStatus("Can't find Liferay workspace project."));
    }
    final IWorkspaceProjectBuilder builder = liferayProject.adapt(IWorkspaceProjectBuilder.class);
    if (builder == null) {
        throw new CoreException(ProjectUI.createErrorStatus("Can't find Liferay Gradle project builder."));
    }
    return builder;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ILiferayProject(com.liferay.ide.core.ILiferayProject) IWorkspaceProjectBuilder(com.liferay.ide.project.core.IWorkspaceProjectBuilder)

Aggregations

IWorkspaceProjectBuilder (com.liferay.ide.project.core.IWorkspaceProjectBuilder)2 CoreException (org.eclipse.core.runtime.CoreException)2 ILiferayProject (com.liferay.ide.core.ILiferayProject)1 BladeCLIException (com.liferay.ide.project.core.modules.BladeCLIException)1 SDK (com.liferay.ide.sdk.core.SDK)1 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 IServer (org.eclipse.wst.server.core.IServer)1 JDOMException (org.jdom.JDOMException)1