Exemplo n.º 1
0
  public void testTagLibsFromPlugin() throws Exception {

    IProject proj = ensureProject(TEST_PROJECT_NAME);
    ensureDefaultGrailsVersion(GrailsVersion.getGrailsVersion(proj));

    if (GrailsVersion.V_2_3_.compareTo(GrailsVersion.MOST_RECENT) > 0) {
      // below 2.3 install-plugin command works
      GrailsCommand cmd =
          GrailsCommand.forTest(proj, "install-plugin").addArgument("feeds").addArgument("1.6");
      cmd.synchExec();
    } else {
      // after 2.3, must edit build config
      IFile buildConfig = proj.getFile("grails-app/conf/BuildConfig.groovy");
      String origContents = GrailsTest.getContents(buildConfig);

      // Modify the props file add two plugins
      // A bit of a hack, but this is a simple way to add plugins to the build
      String newContents =
          origContents.replace("plugins {\n", "plugins {\n\t\tcompile \":feeds:1.6\"\n");
      GrailsTest.setContents(buildConfig, newContents);
    }
    refreshDependencies(proj);

    assertPluginSourceFolder(proj, "feeds-1.6", "src", "groovy");

    // now also check to see that the tag is available
    PerProjectTagProvider provider = GrailsCore.get().connect(proj, PerProjectTagProvider.class);
    assertNotNull("feeds:meta tag not installed", provider.getDocumentForTagName("feed:meta"));
  }
Exemplo n.º 2
0
 /**
  * The Grails work Directory as (for example) set on commandLine by -Dgrails.work.dir. Typically
  * this is a folder in the user's .grails folder.
  *
  * <p>This information is extracted from our dependency data file. So to ensure this info is
  * up-to-date the file must be up-to-date. The file gets generated by refreshDependencies (or by
  * any GrailsCommand executed with "enableRefreshDependencyFile" turned on.
  *
  * <p>Callers of this method are responsible for ensuring that the file is up-to-date.
  */
 public static String getGrailsWorkDir(IProject project) {
   PerProjectDependencyDataCache info =
       GrailsCore.get().connect(project, PerProjectDependencyDataCache.class);
   if (info != null) {
     DependencyData data = info.getData();
     if (data != null) {
       return data.getWorkDir();
     }
   }
   return null;
 }
 public String[] findNamedQueries(DomainClass domainClass) {
   if (domainClass.getGroovyClass() == null) {
     return NO_QUERIES;
   }
   String name = domainClass.getGroovyClass().getName();
   String[] queries = domainClassToQueries.get(name);
   if (queries == null) {
     queries = ensureInitialized(domainClass.getGroovyClass());
     synchronized (GrailsCore.get().getLockForProject(project)) {
       domainClassToQueries.put(name, queries);
     }
   }
   return queries;
 }
  public void projectChanged(GrailsElementKind[] changeKinds, IResourceDelta change) {
    synchronized (GrailsCore.get().getLockForProject(project)) {
      boolean foundRelevantChange = false;
      for (GrailsElementKind changeKind : changeKinds) {
        if (changeKind == GrailsElementKind.PROJECT
            || changeKind == GrailsElementKind.CLASSPATH
            || changeKind == GrailsElementKind.DOMAIN_CLASS) {
          foundRelevantChange = true;
          break;
        }
      }

      if (foundRelevantChange) {
        domainClassToQueries.clear();
      }
    }
  }