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