예제 #1
0
  public static void addUserLibToClassPath(IProject project, IProgressMonitor monitor) {

    monitor = Util.getNonNullMonitor(monitor);
    try {

      IJavaProject javaProject = JavaCore.create(project);
      IClasspathEntry[] oldClasspath = javaProject.getRawClasspath();
      IClasspathEntry[] newClasspath = new IClasspathEntry[oldClasspath.length + 1];
      System.arraycopy(oldClasspath, 0, newClasspath, 0, oldClasspath.length);
      IClasspathEntry gwtuserJarEntry =
          JavaCore.newVariableEntry(Util.getGwtUserLibPath(), null, null);
      gwtuserJarEntry =
          JavaCore.newVariableEntry(
              gwtuserJarEntry.getPath(),
              null,
              null,
              new IAccessRule[0],
              new IClasspathAttribute[0],
              false);
      newClasspath[oldClasspath.length] = gwtuserJarEntry;
      javaProject.setRawClasspath(newClasspath, monitor);

    } catch (CoreException e) {
      // the jar is already in the classpath.
      Activator.logException(e);
    } finally {
      monitor.done();
    }
  }
예제 #2
0
  public static void addServletLibToWebInf(IProject project, IProgressMonitor monitor) {

    monitor = Util.getNonNullMonitor(monitor);

    try {
      monitor.beginTask("", 1);

      IJavaProject javaProject = JavaCore.create(project);
      IClasspathEntry[] oldClasspath = javaProject.getRawClasspath();
      IClasspathEntry[] newClasspath = new IClasspathEntry[oldClasspath.length + 1];
      System.arraycopy(oldClasspath, 0, newClasspath, 0, oldClasspath.length);
      IClasspathEntry gwtServletJarEntry =
          JavaCore.newVariableEntry(Util.getGwtServletLibPath(), null, null);
      IClasspathAttribute attr =
          JavaCore.newClasspathAttribute("org.eclipse.jst.component.dependency", "/WEB-INF/lib");
      gwtServletJarEntry =
          JavaCore.newVariableEntry(
              gwtServletJarEntry.getPath(),
              null,
              null,
              new IAccessRule[0],
              new IClasspathAttribute[] {attr},
              false);
      newClasspath[oldClasspath.length] = gwtServletJarEntry;
      javaProject.setRawClasspath(newClasspath, monitor);

    } catch (JavaModelException e) {
      // the jar is already in the classpath.
      Activator.logException(e);
    } finally {
      monitor.done();
    }
  }
예제 #3
0
  public void execute(
      IProject project, IProjectFacetVersion facetVersion, Object config, IProgressMonitor monitor)
      throws CoreException {

    monitor = Util.getNonNullMonitor(monitor);

    try {

      monitor.beginTask("", 3);

      addNature(project, new SubProgressMonitor(monitor, 1));
      addUserLibToClassPath(project, new SubProgressMonitor(monitor, 1));
      addServletLibToWebInf(project, new SubProgressMonitor(monitor, 1));

    } catch (CoreException e) {
      monitor.setCanceled(true);
      Activator.logException(e);
    } finally {
      monitor.done();
    }
  }