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();
}
}
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;
}
Aggregations