Пример #1
0
 @SuppressWarnings("rawtypes")
 private void cleanup(GantResult result, GantBinding binding) {
   if (result != null) {
     Class cls = GantMetaClass.class;
     try {
       Field methodsInvoked = cls.getDeclaredField("methodsInvoked");
       methodsInvoked.setAccessible(true);
       Set methodsInvokedSet = (Set) methodsInvoked.get(cls);
       if (methodsInvokedSet != null) {
         methodsInvokedSet.clear();
       }
     } catch (NoSuchFieldException e) {
       // ignore
     } catch (IllegalAccessException e) {
       // ignore
     }
   }
   System.setIn(originalIn);
   System.setOut(originalOut);
   GrailsPluginUtils.clearCaches();
   Map variables = binding.getVariables();
   Object pluginsSettingsObject = variables.get("pluginsSettings");
   if (pluginsSettingsObject instanceof PluginBuildSettings) {
     ((PluginBuildSettings) pluginsSettingsObject).clearCache();
   }
   GroovySystem.getMetaClassRegistry().removeMetaClass(GantBinding.class);
   GroovySystem.getMetaClassRegistry().removeMetaClass(Gant.class);
 }
Пример #2
0
  public BaseSettingsApi(
      BuildSettings settings, GrailsBuildEventListener buildEventListener, boolean interactive) {
    buildSettings = settings;
    buildProps = buildSettings.getConfig().toProperties();
    grailsHome = buildSettings.getGrailsHome();

    metadataFile = new File(buildSettings.getBaseDir(), "application.properties");

    metadata = metadataFile.exists() ? Metadata.getInstance(metadataFile) : Metadata.getCurrent();

    metadataFile = metadata.getMetadataFile();
    enableProfile = Boolean.valueOf(getPropertyValue("grails.script.profile", false).toString());
    pluginsHome = buildSettings.getProjectPluginsDir().getPath();
    pluginSettings = GrailsPluginUtils.getPluginBuildSettings(settings);
    grailsAppName = metadata.getApplicationName();
    isInteractive = interactive;

    // If no app name property (upgraded/new/edited project) default to basedir.
    if (grailsAppName == null) {
      grailsAppName = buildSettings.getBaseDir().getName();
    }

    if (grailsAppName.indexOf('/') > -1) {
      appClassName =
          grailsAppName.substring(grailsAppName.lastIndexOf('/'), grailsAppName.length());
    } else {
      appClassName = GrailsNameUtils.getClassNameRepresentation(grailsAppName);
    }
    configSlurper = buildSettings.createConfigSlurper();
    configSlurper.setEnvironment(buildSettings.getGrailsEnv());
    this.buildEventListener = buildEventListener;
  }
 protected File getPluginDir() throws IOException {
   GrailsPluginInfo info =
       GrailsPluginUtils.getPluginBuildSettings().getPluginInfoForName("scaffolding");
   return info.getDescriptor().getFile().getParentFile();
 }