protected void createInfoGroup(Composite parent) {
    new Label(parent, SWT.LEFT).setText(Msgs.liferayPluginTypeLabel);

    final Text pluginTypeLabel = new Text(parent, SWT.READ_ONLY | SWT.BORDER);
    pluginTypeLabel.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));

    final IProjectFacet liferayFacet = ProjectUtil.getLiferayFacet(getFacetedProject());

    if (liferayFacet != null) {
      pluginTypeLabel.setText(liferayFacet.getLabel());
    }

    new Label(parent, SWT.LEFT).setText(Msgs.liferayRuntimeLabel);

    this.runtimeCombo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    this.runtimeCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));

    String currentRuntimeName = null;

    try {
      ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(getProject());

      currentRuntimeName = liferayRuntime.getRuntime().getName();
    } catch (Exception e) {
      ProjectUIPlugin.logError("Could not determine liferay runtime", e); // $NON-NLS-1$
    }

    final List<String> runtimeNames = new ArrayList<String>();
    int selectionIndex = -1;

    for (IRuntime runtime : ServerCore.getRuntimes()) {
      if (ServerUtil.isLiferayRuntime(runtime)) {
        runtimeNames.add(runtime.getName());

        if (runtime.getName().equals(currentRuntimeName)) {
          selectionIndex = runtimeNames.size() - 1;
        }
      }
    }

    if (runtimeNames.size() == 0) {
      runtimeNames.add("No Liferay runtimes available."); // $NON-NLS-1$
    }

    this.runtimeCombo.setItems(runtimeNames.toArray(new String[0]));

    if (selectionIndex > -1) {
      this.runtimeCombo.select(selectionIndex);
    }
  }
Пример #2
0
  public ILiferayProject provide(Object type) {
    final IProject project = (IProject) type;

    ILiferayRuntime liferayRuntime = null;

    try {
      liferayRuntime = ServerUtil.getLiferayRuntime(project);
    } catch (CoreException e) {
    }

    if (liferayRuntime != null) {
      return new LiferayRuntimeProject(project, liferayRuntime);
    }

    return null;
  }
  public IPath publishModuleFull(IProgressMonitor monitor) throws CoreException {
    final IPath deployPath =
        LiferayServerCore.getTempLocation("direct-deploy", StringPool.EMPTY); // $NON-NLS-1$
    File warFile = deployPath.append(getProject().getName() + ".war").toFile(); // $NON-NLS-1$
    warFile.getParentFile().mkdirs();

    final Map<String, String> properties = new HashMap<String, String>();
    properties.put(ISDKConstants.PROPERTY_AUTO_DEPLOY_UNPACK_WAR, "false"); // $NON-NLS-1$

    final ILiferayRuntime runtime = ServerUtil.getLiferayRuntime(getProject());

    final String appServerDeployDirProp =
        ServerUtil.getAppServerPropertyKey(ISDKConstants.PROPERTY_APP_SERVER_DEPLOY_DIR, runtime);

    properties.put(appServerDeployDirProp, deployPath.toOSString());

    // IDE-1073 LPS-37923
    properties.put(ISDKConstants.PROPERTY_PLUGIN_FILE_DEFAULT, warFile.getAbsolutePath());

    properties.put(ISDKConstants.PROPERTY_PLUGIN_FILE, warFile.getAbsolutePath());

    final String fileTimeStamp = System.currentTimeMillis() + "";

    // IDE-1491
    properties.put(ISDKConstants.PROPERTY_LP_VERSION, fileTimeStamp);

    properties.put(ISDKConstants.PROPERTY_LP_VERSION_SUFFIX, ".0");

    final Map<String, String> appServerProperties =
        ServerUtil.configureAppServerProperties(getProject());

    final IStatus directDeployStatus =
        sdk.war(
            getProject(),
            properties,
            true,
            appServerProperties,
            new String[] {"-Duser.timezone=GMT"},
            monitor);

    if (!directDeployStatus.isOK() || (!warFile.exists())) {
      String pluginVersion = "1";

      final IPath pluginPropertiesPath = new Path("WEB-INF/liferay-plugin-package.properties");
      final IFile propertiesFile =
          CoreUtil.getDocrootFile(getProject(), pluginPropertiesPath.toOSString());

      if (propertiesFile != null) {
        try {
          if (propertiesFile.exists()) {
            final PropertiesConfiguration pluginPackageProperties = new PropertiesConfiguration();
            final InputStream is = propertiesFile.getContents();
            pluginPackageProperties.load(is);
            pluginVersion = pluginPackageProperties.getString("module-incremental-version");
            is.close();
          }
        } catch (Exception e) {
          LiferayCore.logError("error reading module-incremtnal-version. ", e);
        }
      }

      warFile =
          sdk.getLocation()
              .append("dist")
              .append(
                  getProject().getName()
                      + "-"
                      + fileTimeStamp
                      + "."
                      + pluginVersion
                      + ".0"
                      + ".war")
              .toFile();

      if (!warFile.exists()) {
        throw new CoreException(directDeployStatus);
      }
    }

    return new Path(warFile.getAbsolutePath());
  }