Пример #1
0
  protected boolean shouldFullBuild(Map args) throws CoreException {
    if (args != null && args.get("force") != null && args.get("force").equals("true")) {
      return true;
    }

    // check to see if there is any files in the _diffs folder
    // IDE-110 IDE-648
    final IWebProject lrproject = LiferayCore.create(IWebProject.class, getProject());

    if (lrproject != null && lrproject.getDefaultDocrootFolder() != null) {
      final IFolder webappRoot = lrproject.getDefaultDocrootFolder();

      if (webappRoot != null) {
        IFolder diffs = webappRoot.getFolder(new Path("_diffs"));

        if (diffs != null && diffs.exists()) {
          IResource[] diffMembers = diffs.members();

          if (!CoreUtil.isNullOrEmpty(diffMembers)) {
            return true;
          }
        }
      }
    }

    return false;
  }
Пример #2
0
  public static IFolder getDefaultDocrootFolder(IProject project) {
    IFolder retval = null;

    final IWebProject webproject = LiferayCore.create(IWebProject.class, project);

    if (webproject != null) {
      retval = webproject.getDefaultDocrootFolder();
    }

    return retval;
  }
  private static IStatus removeSampleCodeAndFiles(NewLiferayPluginProjectOp op) {
    IStatus status = org.eclipse.core.runtime.Status.OK_STATUS;

    final boolean includeSampleCode = op.getIncludeSampleCode().content();

    if (!includeSampleCode) {
      final IProject project = CoreUtil.getLiferayProject(op.getFinalProjectName().content());

      if (project != null && project.exists()) {
        ProjectCore.operate(project, RemoveSampleElementsOperation.class);

        // delete sample files: view.jsp, main.css, main.js
        try {
          final IWebProject webproject = LiferayCore.create(IWebProject.class, project);

          if (webproject != null) {
            final IFolder docroot = webproject.getDefaultDocrootFolder();

            final IFile[] sampleFiles = {
              docroot.getFile("view.jsp"),
              docroot.getFile("css/main.css"),
              docroot.getFile("js/main.js")
            };

            for (IFile file : sampleFiles) {
              if (file != null && file.exists()) {
                file.delete(true, new NullProgressMonitor());

                if (file.getParent().members().length == 0) {
                  CoreUtil.deleteResource(file.getParent());
                }
              }
            }
          }
        } catch (CoreException e) {
          ProjectCore.logError("Error deleting sample files.", e);
        }
      }
    }

    return status;
  }
Пример #4
0
  public static void ensureLookAndFeelFileExists(IProject project) throws CoreException {
    // IDE-110 IDE-648
    final IWebProject lrProject = LiferayCore.create(IWebProject.class, project);

    if (lrProject == null) {
      return;
    }

    IFile lookAndFeelFile = null;

    final IResource res =
        lrProject.findDocrootResource(
            new Path("WEB-INF/" + ILiferayConstants.LIFERAY_LOOK_AND_FEEL_XML_FILE));

    if (res instanceof IFile && res.exists()) {
      lookAndFeelFile = (IFile) res;
    }

    if (lookAndFeelFile == null) {
      // need to generate a new lnf file in deafult docroot
      String id =
          project.getName().replaceAll(ISDKConstants.THEME_PLUGIN_PROJECT_SUFFIX, StringPool.EMPTY);

      final IResource propertiesFileRes =
          lrProject.findDocrootResource(
              new Path("WEB-INF/" + ILiferayConstants.LIFERAY_PLUGIN_PACKAGE_PROPERTIES_FILE));
      String name = id;

      if (propertiesFileRes instanceof IFile && propertiesFileRes.exists()) {
        Properties props = new Properties();

        try {
          final IFile propsFile = (IFile) propertiesFileRes;
          final InputStream contents = propsFile.getContents();

          props.load(contents);
          contents.close();

          final String nameValue = props.getProperty("name"); // $NON-NLS-1$

          if (!CoreUtil.isNullOrEmpty(nameValue)) {
            name = nameValue;
          }

          final ThemeDescriptorHelper themeDescriptorHelper = new ThemeDescriptorHelper(project);

          final ILiferayProject lProject = lrProject;
          final ILiferayPortal portal = lProject.adapt(ILiferayPortal.class);
          String version = "6.2.0";

          if (portal != null) {
            version = portal.getVersion();
          }

          final String themeType = lProject.getProperty("theme.type", "vm");

          themeDescriptorHelper.createDefaultFile(
              lrProject.getDefaultDocrootFolder().getFolder("WEB-INF"),
              version,
              id,
              name,
              themeType);
        } catch (IOException e) {
          ThemeCore.logError("Unable to load plugin package properties.", e); // $NON-NLS-1$
        }
      }
    }
  }