@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());
  }
Exemplo n.º 2
0
  private static void initializeLautRunner() {
    String lautRunnerPath = System.getProperty(LAUT_PATH);

    if (lautRunnerPath != null) {
      File lautRunnerFile = new File(lautRunnerPath);

      if (!lautRunnerFile.exists()) {
        lautRunnerPath = null;
      }
    }

    if (lautRunnerPath == null) {
      try {
        final Bundle lautRunnerBundle = AlloyCore.getDefault().getBundle();
        URL lautUrl = null;

        if (lautRunnerBundle == null) {
          AlloyCore.logError("Unable to find laut bundle.");
        } else {
          final Enumeration<URL> lautEntries =
              lautRunnerBundle.findEntries("/" + LAUT_ENTRY, "/", false);

          if (lautEntries == null || !lautEntries.hasMoreElements()) {
            final Enumeration<URL> lautZipEntries =
                lautRunnerBundle.findEntries("/", LAUT_ZIP, false);

            if (lautZipEntries != null && lautZipEntries.hasMoreElements()) {
              final File lautZipFile =
                  new File(FileLocator.toFileURL(lautZipEntries.nextElement()).getFile());

              final File lautBundleDir = lautZipFile.getParentFile();

              File lautDir = new File(lautBundleDir, LAUT_ENTRY);

              if (!lautBundleDir.canWrite()) {
                lautDir = AlloyCore.getDefault().getStateLocation().append(LAUT_ENTRY).toFile();

                FileUtil.deleteDir(lautDir, true);
              }

              ZipUtil.unzip(lautZipFile, lautDir.getParentFile());

              new File(lautBundleDir, "laut").renameTo(lautDir);

              final Enumeration<URL> lautPathEntries =
                  lautRunnerBundle.findEntries("/" + LAUT_ENTRY, "/", false);
              lautUrl = lautPathEntries.nextElement();
            }
          } else {
            lautUrl = lautEntries.nextElement();
          }

          if (lautUrl != null) {
            final File lautRunnerDir = new File(FileLocator.toFileURL(lautUrl).getFile());
            final String lautRunnerDirPath = lautRunnerDir.getAbsolutePath();

            System.setProperty(LAUT_PATH, lautRunnerDirPath);
            setSDKExecutableFlags(new Path(lautRunnerDirPath));
          }
        }
      } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }