示例#1
0
 private void refreshDependencies(IProject proj) throws CoreException {
   try {
     GrailsCommandUtils.refreshDependencies(JavaCore.create(proj), true);
   } catch (Exception e) {
     // as of Grails 2.3, we really should only need to run refresh dependencies once
     // but below that, we need to do it twice
     if (GrailsVersion.V_2_3_.compareTo(GrailsVersion.MOST_RECENT) > 0) {
       try {
         GrailsCommandUtils.refreshDependencies(JavaCore.create(proj), true);
       } catch (Exception e2) {
         throw new RuntimeException(e2);
       }
     } else {
       throw new RuntimeException(e);
     }
   }
 }
示例#2
0
  public void testInPlacePluginDependency() throws Exception {
    IProject plugin = ensureProject(this.getClass().getSimpleName() + "-" + "plug-in", true);
    IProject nonPlugin = ensureProject(this.getClass().getSimpleName() + "-" + "NonPlugin");
    IJavaProject jNonPlugin = JavaCore.create(nonPlugin);

    // at first, should not have a dependency and should not be on classpath
    assertFalse(
        "Dependency should not exist", GrailsPluginUtil.dependencyExists(nonPlugin, plugin));
    assertFalse("Should not be on classpath", isOnClasspath(nonPlugin, plugin));

    GrailsPluginUtil.addPluginDependency(nonPlugin, plugin);

    // dependency should exist, but not on classpath until refresh
    // dependencies is run
    assertTrue("Dependency should exist", GrailsPluginUtil.dependencyExists(nonPlugin, plugin));
    assertFalse("Should not be on classpath", isOnClasspath(nonPlugin, plugin));

    GrailsCommandUtils.refreshDependencies(jNonPlugin, false);
    assertTrue("Should be on classpath", isOnClasspath(nonPlugin, plugin));
    assertTrue("Dependency should exist", GrailsPluginUtil.dependencyExists(nonPlugin, plugin));

    // now remove dependency
    GrailsPluginUtil.removePluginDependency(nonPlugin, plugin);

    // dependency should not exist, but still on classpath until refresh
    // dependencies is run
    assertFalse(
        "Dependency should not exist", GrailsPluginUtil.dependencyExists(nonPlugin, plugin));
    assertTrue("Should be on classpath", isOnClasspath(nonPlugin, plugin));

    GrailsCommandUtils.refreshDependencies(jNonPlugin, false);
    assertFalse("Should not be on classpath", isOnClasspath(nonPlugin, plugin));
    assertFalse(
        "Dependency should not exist", GrailsPluginUtil.dependencyExists(nonPlugin, plugin));

    // try one more time for good show
    GrailsPluginUtil.addPluginDependency(nonPlugin, plugin);

    // dependency should exist, but not on classpath until refresh
    // dependencies is run
    assertTrue("Dependency should exist", GrailsPluginUtil.dependencyExists(nonPlugin, plugin));
    assertFalse("Should not be on classpath", isOnClasspath(nonPlugin, plugin));

    GrailsCommandUtils.refreshDependencies(jNonPlugin, false);
    assertTrue("Should be on classpath", isOnClasspath(nonPlugin, plugin));
  }