Search in sources :

Example 46 with SDK

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

the class PluginsSDKBundleProject method getOutputs.

public Collection<IFile> getOutputs(boolean build, IProgressMonitor monitor) throws CoreException {
    Collection<IFile> outputs = new HashSet<>();
    if (!build) {
        return outputs;
    }
    getProject().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, monitor);
    SDK sdk = SDKUtil.getSDK(getProject());
    IStatus warStatus = sdk.war(getProject(), null, true, monitor);
    if (warStatus.isOK()) {
    }
    return outputs;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) SDK(com.liferay.ide.sdk.core.SDK) HashSet(java.util.HashSet)

Example 47 with SDK

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

the class PluginsSDKBundleProject method getOutputBundle.

@Override
public IPath getOutputBundle(boolean cleanBuild, IProgressMonitor monitor) throws CoreException {
    IPath retval = null;
    SDK sdk = getSDK();
    IStatus status = sdk.validate();
    if (!status.isOK()) {
        throw new CoreException(status);
    }
    IStatus warStatus = sdk.war(getProject(), null, true, new String[] { "-Duser.timezone=GMT" }, monitor);
    IPath distPath = sdk.getLocation().append("dist");
    // TODO need to find a better way to determine the actual output file.
    File[] distFiles = distPath.toFile().listFiles(new FilenameFilter() {

        @Override
        public boolean accept(File dir, String name) {
            IPath location = getProject().getLocation();
            return name.contains(location.lastSegment());
        }
    });
    if (warStatus.isOK()) {
        try {
            retval = new Path(distFiles[0].getCanonicalPath());
        } catch (IOException ioe) {
            throw new CoreException(ProjectCore.createErrorStatus(ioe));
        }
    }
    return retval;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) FilenameFilter(java.io.FilenameFilter) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) SDK(com.liferay.ide.sdk.core.SDK) IOException(java.io.IOException) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 48 with SDK

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

the class PluginsSDKProjectProvider method _getSDK.

private static SDK _getSDK(NewLiferayPluginProjectOp op) {
    SDK sdk = null;
    try {
        boolean sdkValid = false;
        sdk = SDKUtil.getWorkspaceSDK();
        if (sdk != null) {
            IStatus sdkStatus = sdk.validate();
            if (sdkStatus.isOK()) {
                sdkValid = true;
            }
        }
        if (sdkValid == false) {
            Path sdkLocation = op.getSdkLocation().content(true);
            if (sdkLocation != null) {
                sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkLocation));
                if (sdk != null) {
                    IStatus sdkStatus = sdk.validate();
                    if (sdkStatus.isOK()) {
                        sdkValid = true;
                    }
                }
            }
        }
        if (!sdkValid) {
            return null;
        }
    } catch (CoreException ce) {
        return null;
    }
    return sdk;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) SDK(com.liferay.ide.sdk.core.SDK)

Example 49 with SDK

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

the class BinaryProjectImportOperation method execute.

@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
    Object selectedProjects = getDataModel().getProperty(ISDKProjectsImportDataModelProperties.SELECTED_PROJECTS);
    BridgedRuntime bridgedRuntime = (BridgedRuntime) model.getProperty(IFacetProjectCreationDataModelProperties.FACET_RUNTIME);
    String sdkLocation = model.getStringProperty(ISDKProjectsImportDataModelProperties.SDK_LOCATION);
    if (selectedProjects == null) {
        return super.execute(monitor, info);
    }
    SDKManager sdkManager = SDKManager.getInstance();
    SDK liferaySDK = sdkManager.getSDK(new Path(sdkLocation));
    Object[] seleBinaryRecords = (Object[]) selectedProjects;
    ProjectRecord[] projectRecords = new ProjectRecord[1];
    BinaryProjectRecord pluginBinaryRecord = (BinaryProjectRecord) seleBinaryRecords[0];
    try {
        projectRecords[0] = ProjectImportUtil.createSDKPluginProject(bridgedRuntime, pluginBinaryRecord, liferaySDK);
    } catch (Exception e) {
        throw new ExecutionException("Error while importing Binary:" + pluginBinaryRecord.getBinaryName(), e);
    }
    getDataModel().setProperty(SELECTED_PROJECTS, projectRecords);
    return super.execute(monitor, info);
}
Also used : Path(org.eclipse.core.runtime.Path) SDKManager(com.liferay.ide.sdk.core.SDKManager) BridgedRuntime(org.eclipse.wst.common.project.facet.core.runtime.internal.BridgedRuntime) SDK(com.liferay.ide.sdk.core.SDK) ExecutionException(org.eclipse.core.commands.ExecutionException) ExecutionException(org.eclipse.core.commands.ExecutionException)

Example 50 with SDK

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

the class SDKProjectConvertOperation method getSDKName.

protected String getSDKName() {
    String sdkLocation = getDataModel().getStringProperty(SDK_LOCATION);
    IPath sdkLocationPath = new Path(sdkLocation);
    SDK sdk = SDKManager.getInstance().getSDK(sdkLocationPath);
    String sdkName = null;
    if (sdk != null) {
        sdkName = sdk.getName();
    } else {
        sdk = SDKUtil.createSDKFromLocation(sdkLocationPath);
        SDKManager.getInstance().addSDK(sdk);
        sdkName = sdk.getName();
    }
    return sdkName;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) SDK(com.liferay.ide.sdk.core.SDK)

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