Exemplo n.º 1
0
  public static IStatus compileTheme(IProject project) throws CoreException {
    final SDK sdk = SDKUtil.getSDK(project);

    if (sdk == null) {
      throw new CoreException(
          ThemeCore.createErrorStatus(
              "No SDK for project configured. Could not build theme.")); //$NON-NLS-1$
    }

    final IStatus status = sdk.compileThemePlugin(project, null);

    if (!status.isOK()) {
      throw new CoreException(status);
    }

    ensureLookAndFeelFileExists(project);

    try {
      project.refreshLocal(IResource.DEPTH_INFINITE, null);
    } catch (Exception e) {
      ThemeCore.logError(e);
    }

    return status;
  }
Exemplo n.º 2
0
  public SDK copy() {
    SDK copy = new SDK(this.getLocation());

    copy.setContributed(isContributed());
    copy.setDefault(isDefault());
    copy.setName(getName());
    copy.setVersion(getVersion());

    return copy;
  }
  @Test
  public void testNewWebAntProjectValidation() throws Exception {
    IPath liferayPluginsSdkDir = super.getLiferayPluginsSdkDir();

    final File liferayPluginsSdkDirFile = liferayPluginsSdkDir.toFile();

    if (!liferayPluginsSdkDirFile.exists()) {
      final File liferayPluginsSdkZipFile = super.getLiferayPluginsSDKZip().toFile();

      assertEquals(
          "Expected file to exist: " + liferayPluginsSdkZipFile.getAbsolutePath(),
          true,
          liferayPluginsSdkZipFile.exists());

      liferayPluginsSdkDirFile.mkdirs();

      final String liferayPluginsSdkZipFolder = super.getLiferayPluginsSdkZipFolder();

      if (CoreUtil.isNullOrEmpty(liferayPluginsSdkZipFolder)) {
        ZipUtil.unzip(liferayPluginsSdkZipFile, liferayPluginsSdkDirFile);
      } else {
        ZipUtil.unzip(
            liferayPluginsSdkZipFile,
            liferayPluginsSdkZipFolder,
            liferayPluginsSdkDirFile,
            new NullProgressMonitor());
      }
    }

    assertEquals(true, liferayPluginsSdkDirFile.exists());

    SDK sdk = null;

    final SDK existingSdk = SDKManager.getInstance().getSDK(liferayPluginsSdkDir);

    if (existingSdk == null) {
      sdk = SDKUtil.createSDKFromLocation(liferayPluginsSdkDir);
    } else {
      sdk = existingSdk;
    }

    final String projectName = "test-web-project-sdk";

    final NewLiferayPluginProjectOp op = newProjectOp(projectName);

    op.setPluginsSDKName(sdk.getName());
    op.setPluginType(PluginType.web);

    assertEquals(
        "The selected Plugins SDK does not support creating new web type plugins.  Please configure version 7.0.0 or greater.",
        op.getPluginType().validation().message());
  }
  public static boolean supportsWebTypePlugin(NewLiferayPluginProjectOp op) {
    boolean retval = false;

    if (op.getProjectProvider().content(true).getShortName().equals("maven")) {
      retval = true;
    } else {
      SDK sdk = null;

      try {
        sdk = SDKUtil.getWorkspaceSDK();
      } catch (CoreException e) {
      }

      if (sdk == null) {
        final Path sdkLocation = op.getSdkLocation().content();

        if (sdkLocation != null) {
          sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkLocation));
        }
      }

      if (sdk != null) {
        final Version version = new Version(sdk.getVersion());

        final boolean greaterThan700 =
            CoreUtil.compareVersions(version, ILiferayConstants.V700) >= 0;

        if (greaterThan700) {
          retval = true;
        }
      } else {
        retval = true;
      }
    }

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