示例#1
0
  public static SDK getSDK(IProject project) {
    SDK retval = null;

    // try to determine SDK based on project location
    IPath projectLocation = project.getRawLocation();

    if (projectLocation == null) {
      projectLocation = project.getLocation();
    }

    if (projectLocation != null) {
      IPath sdkLocation = projectLocation.removeLastSegments(2);

      retval = SDKManager.getInstance().getSDK(sdkLocation);

      if (retval == null) {
        retval = SDKUtil.createSDKFromLocation(sdkLocation);

        if (retval != null) {
          SDKManager.getInstance().addSDK(retval);
        }
      }
    }

    return retval;
  }
示例#2
0
  public static IStatus cssBuild(IProject project) throws CoreException {

    SDK sdk = SDKUtil.getSDK(project);

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

    ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(project);

    if (liferayRuntime == null) {
      throw new CoreException(
          ThemeCore.createErrorStatus(
              "Could not get portal runtime for project.  Could not build theme."));
    }

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

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

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

    IFolder docroot = CoreUtil.getDocroot(project);

    IFile lookAndFeelFile =
        docroot.getFile("WEB-INF/" + ILiferayConstants.LIFERAY_LOOK_AND_FEEL_XML_FILE);

    if (!lookAndFeelFile.exists()) {
      String id = project.getName().replaceAll(ISDKConstants.THEME_PLUGIN_PROJECT_SUFFIX, "");
      IFile propsFile =
          docroot.getFile("WEB-INF/" + ILiferayConstants.LIFERAY_PLUGIN_PACKAGE_PROPERTIES_FILE);
      String name = id;
      if (propsFile.exists()) {
        Properties props = new Properties();
        try {
          props.load(propsFile.getContents());
          String nameValue = props.getProperty("name");
          if (!CoreUtil.isNullOrEmpty(nameValue)) {
            name = nameValue;
          }
        } catch (IOException e) {
          ThemeCore.logError("Unable to load plugin package properties.", e);
        }
      }

      if (liferayRuntime != null) {
        ThemeDescriptorHelper.createDefaultFile(
            lookAndFeelFile, liferayRuntime.getPortalVersion() + "+", id, name);
      }
    }

    if (docroot != null && docroot.exists()) {
      docroot.refreshLocal(IResource.DEPTH_INFINITE, null);
    }

    return status;
  }
示例#3
0
  public static boolean isSDKSupported(String location) {
    boolean retval = false;

    try {
      String version = SDKUtil.readSDKVersion(location);

      retval = new Version(version).compareTo(ISDKConstants.LEAST_SUPPORTED_SDK_VERSION) >= 0;
    } catch (Exception e) {
      // best effort we didn't find a valid location
    }

    return retval;
  }
  protected IClasspathEntry createContextClasspathEntry(String context) {
    IClasspathEntry entry = null;

    IFile serviceJar = ProjectUtil.findServiceJarForContext(context);

    if (serviceJar.exists()) {
      IFolder docroot = CoreUtil.getDocroot(serviceJar.getProject());
      IFolder serviceFolder = docroot.getFolder("WEB-INF/service");

      entry =
          createClasspathEntry(
              serviceJar.getLocation(),
              serviceFolder.exists() ? serviceFolder.getLocation() : null);
    }

    if (entry == null) {
      IProject project = this.javaProject.getProject();

      SDK sdk = SDKUtil.getSDK(project);

      IPath sdkLocation = sdk.getLocation();

      String type =
          ProjectUtil.isPortletProject(project)
              ? "portlets"
              : ProjectUtil.isHookProject(project)
                  ? "hooks"
                  : ProjectUtil.isExtProject(project) ? "ext" : "";

      IPath serviceJarPath =
          sdkLocation
              .append(type)
              .append(context)
              .append("docroot/WEB-INF/lib")
              .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;
  }
示例#5
0
  public static SDK getSDKFromProjectDir(File projectDir) {
    File sdkDir = projectDir.getParentFile().getParentFile();

    if (sdkDir.exists() && SDKUtil.isValidSDKLocation(sdkDir.getPath())) {
      Path sdkLocation = new Path(sdkDir.getPath());

      SDK existingSDK = SDKManager.getInstance().getSDK(sdkLocation);

      if (existingSDK != null) {
        return existingSDK;
      } else {
        return createSDKFromLocation(sdkLocation);
      }
    }

    return null;
  }
示例#6
0
  public static boolean isValidSDKLocation(String loc) {
    boolean retval = false;

    // try to look for build.properties file with property lp.version

    try {
      String version = SDKUtil.readSDKVersion(loc);

      new Version(version);

      File sdkDir = new File(loc);

      File portletsBuildXml = new File(sdkDir, ISDKConstants.PORTLET_PLUGIN_ANT_BUILD);
      File hooksBuildXml = new File(sdkDir, ISDKConstants.HOOK_PLUGIN_ANT_BUILD);
      File extBuildXml = new File(sdkDir, ISDKConstants.EXT_PLUGIN_ANT_BUILD);

      retval = portletsBuildXml.exists() && hooksBuildXml.exists() && extBuildXml.exists();
    } catch (Exception e) {
      // best effort we didn't find a valid location
    }

    return retval;
  }