// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/ClassSource.java
// @SuppressWarnings("JavadocReference")
// public interface ClassSource
// {
//   URL getUrl();
// 
//   File getFile();
// 
//   interface Inline
//   {
//     String getName();
// 
//     String getCodeBase();
// 
//     Reader getInput();
//   }
// 
//   Inline getInline();
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/ClassSource.java
// interface Inline
// {
//   String getName();
// 
//   String getCodeBase();
// 
//   Reader getInput();
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/ClosureTarget.java
// @SuppressWarnings("JavadocReference")
// public interface ClosureTarget
// {
//   @Nullable
//   Object call(Object[] args) throws Exception;
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/ConsoleWindow.java
// @SuppressWarnings("JavadocReference")
// public interface ConsoleWindow
// {
//   interface WindowHandle
//   {
//     void close();
// 
//     void await() throws InterruptedException;
//   }
// 
//   WindowHandle open(ClassLoader classLoader,
//                     ResourceLoader resourceLoader,
//                     Map<String, Object> context,
//                     @Nullable Map<String, Object> options)
//       throws Exception;
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/GroovyRuntime.java
// public interface GroovyRuntime
// {
//   ScriptExecutor createScriptExecutor();
// 
//   ConsoleWindow createConsoleWindow();
// 
//   ShellRunner createShellRunner();
// 
//   void cleanup();
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/MagicContext.java
// public enum MagicContext
// {
//   /**
//    * Context value will be replaced by a {@link groovy.util.AntBuilder} instance.
//    */
//   @SuppressWarnings("JavadocReference")
//   ANT_BUILDER
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/ResourceLoader.java
// @SuppressWarnings("JavadocReference")
// public interface ResourceLoader
// {
//   @Nullable
//   URL loadResource(String name) throws MalformedURLException;
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/ScriptExecutor.java
// @SuppressWarnings("JavadocReference")
// public interface ScriptExecutor
// {
//   @Nullable
//   Object execute(ClassSource classSource,
//                  ClassLoader classLoader,
//                  ResourceLoader resourceLoader,
//                  Map<String, Object> context,
//                  @Nullable Map<String, Object> options)
//       throws Exception;
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/ShellRunner.java
// @SuppressWarnings("JavadocReference")
// public interface ShellRunner
// {
//   void run(ClassLoader classLoader,
//            ResourceLoader resourceLoader,
//            Map<String, Object> context,
//            @Nullable Map<String, Object> options)
//       throws Exception;
// }


import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Map;
import java.util.Map.Entry;
import com.google.common.base.Throwables;
import groovy.lang.Binding;
import groovy.lang.Closure;
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyCodeSource;
import groovy.lang.GroovyResourceLoader;
import groovy.util.AntBuilder;
import org.apache.tools.ant.BuildLogger;
import org.codehaus.gmaven.adapter.ClassSource;
import org.codehaus.gmaven.adapter.ClassSource.Inline;
import org.codehaus.gmaven.adapter.ClosureTarget;
import org.codehaus.gmaven.adapter.ConsoleWindow;
import org.codehaus.gmaven.adapter.GroovyRuntime;
import org.codehaus.gmaven.adapter.MagicContext;
import org.codehaus.gmaven.adapter.ResourceLoader;
import org.codehaus.gmaven.adapter.ScriptExecutor;
import org.codehaus.gmaven.adapter.ShellRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.checkNotNull;
    });
  }

  /**
   * Creates a {@link GroovyResourceLoader} from a {@link ResourceLoader}.
   */
  public GroovyResourceLoader createGroovyResourceLoader(final ResourceLoader resourceLoader) {
    checkNotNull(resourceLoader);

    return new GroovyResourceLoader()
    {
      @Override
      public URL loadGroovySource(final String name) throws MalformedURLException {
        return resourceLoader.loadResource(name);
      }
    };
  }

  /**
   * Creates a {@link GroovyCodeSource} from a {@link ClassSource}.
   */
  public GroovyCodeSource createGroovyCodeSource(final ClassSource source) throws IOException {
    checkNotNull(source);

    if (source.getUrl() != null) {
      return new GroovyCodeSource(source.getUrl());
    }
    if (source.getFile() != null) {
      return new GroovyCodeSource(source.getFile());
    }
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/ClassSource.java
// @SuppressWarnings("JavadocReference")
// public interface ClassSource
// {
//   URL getUrl();
// 
//   File getFile();
// 
//   interface Inline
//   {
//     String getName();
// 
//     String getCodeBase();
// 
//     Reader getInput();
//   }
// 
//   Inline getInline();
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/ClassSource.java
// interface Inline
// {
//   String getName();
// 
//   String getCodeBase();
// 
//   Reader getInput();
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/ClosureTarget.java
// @SuppressWarnings("JavadocReference")
// public interface ClosureTarget
// {
//   @Nullable
//   Object call(Object[] args) throws Exception;
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/ConsoleWindow.java
// @SuppressWarnings("JavadocReference")
// public interface ConsoleWindow
// {
//   interface WindowHandle
//   {
//     void close();
// 
//     void await() throws InterruptedException;
//   }
// 
//   WindowHandle open(ClassLoader classLoader,
//                     ResourceLoader resourceLoader,
//                     Map<String, Object> context,
//                     @Nullable Map<String, Object> options)
//       throws Exception;
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/GroovyRuntime.java
// public interface GroovyRuntime
// {
//   ScriptExecutor createScriptExecutor();
// 
//   ConsoleWindow createConsoleWindow();
// 
//   ShellRunner createShellRunner();
// 
//   void cleanup();
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/MagicContext.java
// public enum MagicContext
// {
//   /**
//    * Context value will be replaced by a {@link groovy.util.AntBuilder} instance.
//    */
//   @SuppressWarnings("JavadocReference")
//   ANT_BUILDER
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/ResourceLoader.java
// @SuppressWarnings("JavadocReference")
// public interface ResourceLoader
// {
//   @Nullable
//   URL loadResource(String name) throws MalformedURLException;
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/ScriptExecutor.java
// @SuppressWarnings("JavadocReference")
// public interface ScriptExecutor
// {
//   @Nullable
//   Object execute(ClassSource classSource,
//                  ClassLoader classLoader,
//                  ResourceLoader resourceLoader,
//                  Map<String, Object> context,
//                  @Nullable Map<String, Object> options)
//       throws Exception;
// }
// 
// Path: gmaven-adapter-api/src/main/java/org/codehaus/gmaven/adapter/ShellRunner.java
// @SuppressWarnings("JavadocReference")
// public interface ShellRunner
// {
//   void run(ClassLoader classLoader,
//            ResourceLoader resourceLoader,
//            Map<String, Object> context,
//            @Nullable Map<String, Object> options)
//       throws Exception;
// }


// Path: gmaven-adapter-impl/src/main/java/org/codehaus/gmaven/adapter/impl/GroovyRuntimeImpl.java
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Map;
import java.util.Map.Entry;
import com.google.common.base.Throwables;
import groovy.lang.Binding;
import groovy.lang.Closure;
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyCodeSource;
import groovy.lang.GroovyResourceLoader;
import groovy.util.AntBuilder;
import org.apache.tools.ant.BuildLogger;
import org.codehaus.gmaven.adapter.ClassSource;
import org.codehaus.gmaven.adapter.ClassSource.Inline;
import org.codehaus.gmaven.adapter.ClosureTarget;
import org.codehaus.gmaven.adapter.ConsoleWindow;
import org.codehaus.gmaven.adapter.GroovyRuntime;
import org.codehaus.gmaven.adapter.MagicContext;
import org.codehaus.gmaven.adapter.ResourceLoader;
import org.codehaus.gmaven.adapter.ScriptExecutor;
import org.codehaus.gmaven.adapter.ShellRunner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.checkNotNull;

    });
  }

  /**
   * Creates a {@link GroovyResourceLoader} from a {@link ResourceLoader}.
   */
  public GroovyResourceLoader createGroovyResourceLoader(final ResourceLoader resourceLoader) {
    checkNotNull(resourceLoader);

    return new GroovyResourceLoader()
    {
      @Override
      public URL loadGroovySource(final String name) throws MalformedURLException {
        return resourceLoader.loadResource(name);
      }
    };
  }

  /**
   * Creates a {@link GroovyCodeSource} from a {@link ClassSource}.
   */
  public GroovyCodeSource createGroovyCodeSource(final ClassSource source) throws IOException {
    checkNotNull(source);

    if (source.getUrl() != null) {
      return new GroovyCodeSource(source.getUrl());
    }
    if (source.getFile() != null) {
      return new GroovyCodeSource(source.getFile());
    }
    if (source.getInline() != null) {