use of com.liferay.ide.sdk.core.SDK in project liferay-ide by liferay.
the class PortalDeployExcludesSection method createJarsArray.
protected void createJarsArray() {
_fJars = new Vector<>();
PluginPackageModel model = (PluginPackageModel) getPage().getModel();
String[] excludeJars = model.getPortalDeloyExcludesJars();
IProject project = getProject();
IFolder docroot = CoreUtil.getDefaultDocrootFolder(project);
if ((docroot == null) || ProjectUtil.isMavenProject(project) || ProjectUtil.isExtProject(project)) {
TablePart tablePart = getTablePart();
tablePart.setButtonEnabled(_ADD_INDEX, false);
return;
}
SDK sdk = SDKUtil.getSDK(project);
IPath sdkLocation = sdk.getLocation();
String type;
if (ProjectUtil.isPortletProject(project)) {
type = "portlets";
} else if (ProjectUtil.isHookProject(project)) {
type = "hooks";
} else if (ProjectUtil.isWebProject(project)) {
type = "webs";
} else {
type = StringPool.EMPTY;
}
IPath excludeJarPath = sdkLocation.append(type).append(docroot.getFullPath());
if (excludeJarPath != null) {
for (String excludeJar : excludeJars) {
if (excludeJar.startsWith("**/WEB-INF/lib/")) {
excludeJar = excludeJar.substring(excludeJar.lastIndexOf("/"));
}
File jarFile = new File(excludeJarPath.append("WEB-INF/lib").toFile(), excludeJar.trim());
if (jarFile.isFile() && jarFile.exists()) {
_fJars.add(jarFile);
}
}
}
}
use of com.liferay.ide.sdk.core.SDK in project liferay-ide by liferay.
the class PluginsSDKProjectProvider method createNewProject.
@Override
public IStatus createNewProject(NewLiferayPluginProjectOp op, IProgressMonitor monitor) throws CoreException {
ElementList<ProjectName> projectNames = op.getProjectNames();
PluginType pluginType = op.getPluginType().content(true);
String originalProjectName = op.getProjectName().content();
String pluginTypeSuffix = NewLiferayPluginProjectOpMethods.getPluginTypeSuffix(pluginType);
String fixedProjectName = originalProjectName;
if (originalProjectName.endsWith(pluginTypeSuffix)) {
fixedProjectName = originalProjectName.substring(0, originalProjectName.length() - pluginTypeSuffix.length());
}
String projectName = fixedProjectName;
String displayName = op.getDisplayName().content(true);
boolean separateJRE = true;
SDK sdk = _getSDK(op);
if (sdk == null) {
return ProjectCore.createErrorStatus("Can not get correct SDK for " + fixedProjectName + ", Please check SDK configuration setting.");
}
// workingDir should always be the directory of the type of plugin /sdk/portlets/ for a portlet, etc
String workingDir = null;
ArrayList<String> arguments = new ArrayList<>();
arguments.add(projectName);
arguments.add(displayName);
boolean hasGradleTools = SDKUtil.hasGradleTools(sdk.getLocation());
IPath newSDKProjectPath = null;
IPath path = null;
switch(pluginType) {
case servicebuilder:
op.setPortletFramework("mvc");
case portlet:
path = sdk.getLocation().append(ISDKConstants.PORTLET_PLUGIN_PROJECT_FOLDER);
String frameworkName = NewLiferayPluginProjectOpMethods.getFrameworkName(op);
workingDir = path.toOSString();
if (hasGradleTools) {
arguments.add(frameworkName);
sdk.createNewProject(projectName, arguments, "portlet", workingDir, monitor);
} else {
newSDKProjectPath = sdk.createNewPortletProject(projectName, displayName, frameworkName, separateJRE, workingDir, null, monitor);
}
break;
case hook:
path = sdk.getLocation().append(ISDKConstants.HOOK_PLUGIN_PROJECT_FOLDER);
workingDir = path.toOSString();
if (hasGradleTools) {
sdk.createNewProject(projectName, arguments, "hook", workingDir, monitor);
} else {
newSDKProjectPath = sdk.createNewHookProject(projectName, displayName, separateJRE, workingDir, null, monitor);
}
break;
case ext:
path = sdk.getLocation().append(ISDKConstants.EXT_PLUGIN_PROJECT_FOLDER);
workingDir = path.toOSString();
if (hasGradleTools) {
sdk.createNewProject(projectName, arguments, "ext", workingDir, monitor);
} else {
newSDKProjectPath = sdk.createNewExtProject(projectName, displayName, separateJRE, workingDir, null, monitor);
}
break;
case layouttpl:
path = sdk.getLocation().append(ISDKConstants.LAYOUTTPL_PLUGIN_PROJECT_FOLDER);
workingDir = path.toOSString();
if (hasGradleTools) {
sdk.createNewProject(projectName, arguments, "layouttpl", workingDir, monitor);
} else {
newSDKProjectPath = sdk.createNewLayoutTplProject(projectName, displayName, separateJRE, workingDir, null, monitor);
}
IProject layoutProject = ProjectUtil.getProject(projectName);
if (!LiferayDescriptorHelper.getDescriptorVersion(layoutProject).equals("6.2.0")) {
IPath projectPath = newSDKProjectPath.append(projectName + pluginTypeSuffix);
IPath fileWap = projectPath.append("docroot").append("blank_columns.wap.tpl");
if (FileUtil.exists(fileWap)) {
fileWap.toFile().delete();
}
}
break;
case theme:
path = sdk.getLocation().append(ISDKConstants.THEME_PLUGIN_PROJECT_FOLDER);
workingDir = path.toOSString();
if (hasGradleTools) {
sdk.createNewProject(projectName, arguments, "theme", workingDir, monitor);
} else {
newSDKProjectPath = sdk.createNewThemeProject(projectName, displayName, separateJRE, workingDir, null, monitor);
}
break;
case web:
path = sdk.getLocation().append(ISDKConstants.WEB_PLUGIN_PROJECT_FOLDER);
workingDir = path.toOSString();
if (hasGradleTools) {
sdk.createNewProject(projectName, arguments, "web", workingDir, monitor);
} else {
newSDKProjectPath = sdk.createNewWebProject(projectName, displayName, separateJRE, workingDir, null, monitor);
}
break;
}
NewLiferayPluginProjectOpMethods.updateLocation(op);
Path projectLocation = op.getLocation().content();
if (!hasGradleTools) {
File projectDir = projectLocation.toFile();
File projectParent = projectDir.getParentFile();
projectParent.mkdirs();
if (FileUtil.notExists(newSDKProjectPath)) {
return ProjectCore.createErrorStatus("Error create project due to '" + newSDKProjectPath + "' does not exist.");
}
File newSDKProjectDir = newSDKProjectPath.toFile();
try {
FileUtils.copyDirectory(newSDKProjectDir, projectParent);
FileUtils.deleteDirectory(newSDKProjectDir);
} catch (IOException ioe) {
throw new CoreException(ProjectCore.createErrorStatus(ioe));
}
}
ProjectRecord projectRecord = ProjectUtil.getProjectRecordForDir(projectLocation.toOSString());
IProject newProject = ProjectImportUtil.importProject(projectRecord.getProjectLocation(), monitor, op);
newProject.open(monitor);
// need to update project name incase the suffix was not correct
op.setFinalProjectName(newProject.getName());
projectNames.insert().setName(op.getFinalProjectName().content());
_projectCreated(newProject);
switch(op.getPluginType().content()) {
case portlet:
_portletProjectCreated(op, newProject, monitor);
break;
case servicebuilder:
PortalBundle bundle = ServerUtil.getPortalBundle(newProject);
_serviceBuilderProjectCreated(bundle.getVersion(), newProject, monitor);
break;
case theme:
_themeProjectCreated(newProject);
break;
default:
break;
}
return Status.OK_STATUS;
}
use of com.liferay.ide.sdk.core.SDK in project liferay-ide by liferay.
the class PluginsSDKRuntimeProject method getSDK.
protected SDK getSDK() {
SDK retval = null;
// try to determine SDK based on project location
IPath path = getProject().getRawLocation();
IPath sdkLocation = path.removeLastSegments(2);
retval = SDKManager.getInstance().getSDK(sdkLocation);
if (retval == null) {
retval = SDKUtil.createSDKFromLocation(sdkLocation);
SDKManager.getInstance().addSDK(retval);
}
return retval;
}
use of com.liferay.ide.sdk.core.SDK in project liferay-ide by liferay.
the class PluginsSDKRuntimeProject method getOutputs.
public Collection<IFile> getOutputs(boolean build, IProgressMonitor monitor) throws CoreException {
Collection<IFile> outputs = new HashSet<>();
if (build) {
getProject().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
SDK sdk = SDKUtil.getSDK(getProject());
IStatus warStatus = sdk.war(getProject(), null, true, monitor);
if (warStatus.isOK()) {
}
}
return outputs;
}
use of com.liferay.ide.sdk.core.SDK in project liferay-ide by liferay.
the class SDKBuildPropertiesResourceListener method processPropertiesFileChanged.
protected void processPropertiesFileChanged(IFile deltaFile) throws CoreException {
IProject deltaProject = deltaFile.getProject();
SDK sdk = SDKUtil.createSDKFromLocation(deltaProject.getLocation());
if (sdk == null) {
return;
}
IMarker[] problemMarkers = MarkerUtil.findMarkers(deltaFile.getProject(), IMarker.PROBLEM, _MARKER_ID_SDK_PROPERTIES_INVALID);
IStatus sdkStatus = sdk.validate(true);
if (sdkStatus.isOK()) {
if (ListUtil.isNotEmpty(problemMarkers)) {
MarkerUtil.clearMarkers(deltaFile.getProject(), IMarker.PROBLEM, _MARKER_ID_SDK_PROPERTIES_INVALID);
}
for (IProject project : CoreUtil.getAllProjects()) {
if (SDKUtil.isSDKProject(project) && sdk.getLocation().isPrefixOf(project.getLocation())) {
Job job = new WorkspaceJob("Updating dependencies " + project.getName()) {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
ClasspathUtil.updateRequestContainer(project);
return Status.OK_STATUS;
}
};
job.schedule();
}
}
} else {
IStatus[] statuses = sdkStatus.getChildren();
for (IMarker marker : problemMarkers) {
boolean canDelete = true;
String message = (String) marker.getAttribute(IMarker.MESSAGE);
for (IStatus status : statuses) {
if (status.getMessage().equals(message)) {
canDelete = false;
break;
}
}
if (canDelete) {
marker.delete();
}
}
for (IStatus status : statuses) {
boolean canAdd = true;
for (IMarker marker : problemMarkers) {
if (marker.exists()) {
String message = (String) marker.getAttribute(IMarker.MESSAGE);
if (status.getMessage().equals(message)) {
canAdd = false;
break;
}
}
}
if (canAdd) {
MarkerUtil.setMarker(deltaFile, IMarker.PROBLEM, IMarker.SEVERITY_ERROR, status.getMessage(), deltaFile.getFullPath().toPortableString(), _MARKER_ID_SDK_PROPERTIES_INVALID);
}
}
}
}
Aggregations