// Path: gmaven-feature/gmaven-feature-support/src/main/java/org/codehaus/gmaven/feature/support/ComponentSupport.java
// public class ComponentSupport
//     implements Component
// {
//     protected final Logger log = LoggerFactory.getLogger(getClass());
// 
//     protected final Feature feature;
// 
//     protected final Configuration config;
// 
//     protected ComponentSupport(final Feature feature, final Configuration config) {
//         assert feature != null;
//         assert config != null;
// 
//         this.feature = feature;
//         this.config = config;
//     }
// 
//     protected ComponentSupport(final Feature feature) {
//         this(feature, new Configuration());
//     }
// 
//     public Feature feature() {
//         return feature;
//     }
// 
//     public Configuration config() {
//         return config;
//     }
// }
// 
// Path: gmaven-runtime/gmaven-runtime-api/src/main/java/org/codehaus/gmaven/runtime/util/ClassSource.java
// public class ClassSource
// {
//     public final URL url;
// 
//     public final File file;
// 
//     public final Body body;
// 
//     private ClassSource(final URL url, final File file, final Body body) {
//         this.url = url;
//         this.file = file;
//         this.body = body;
//     }
// 
//     public ClassSource(final URL url) {
//         this(url, null, null);
//     }
// 
//     public ClassSource(final File file) {
//         this(null, file, null);
//     }
// 
//     public ClassSource(final Body body) {
//         this(null, null, body);
//     }
// 
//     public String toString() {
//         return "ClassSource" +
//                 "[ url=" + url +
//                 ", file=" + file +
//                 ", body=" + body +
//                 " ]";
//     }
// 
//     //
//     // Body
//     //
// 
//     public static class Body
//     {
//         public final String name;
// 
//         public final String codeBase;
// 
//         public final InputStream input;
// 
//         public Body(final String name, final String codeBase, final InputStream input) {
//             assert name != null;
//             assert codeBase != null;
//             assert input != null;
// 
//             this.name = name;
//             this.codeBase = codeBase;
//             this.input = input;
//         }
// 
//         public Body(final String source) {
//             this("script" + System.currentTimeMillis() + ".groovy",
//                  "/groovy/script",
//                  new ByteArrayInputStream(source.getBytes()));
//         }
// 
//         public String toString() {
//             return "Body" +
//                     "[ name=" + name +
//                     ", codeBase=" + codeBase +
//                     ", input=" + input +
//                     " ]";
//         }
//     }
// 
//     //
//     // Helpers
//     //
// 
//     public static ClassSource forValue(final String source) {
//         assert source != null;
// 
//         // First try and parse the source as a URL
//         try {
//             return new ClassSource(new URL(source));
//         }
//         catch (MalformedURLException ignore) {}
// 
//         // Then as a File
//         File file = new File(source);
//         if (file.exists()) {
//             return new ClassSource(file);
//         }
// 
//         // Else its a body
//         return new ClassSource(new ClassSource.Body(source));
//     }
// }
// 
// Path: gmaven-runtime/gmaven-runtime-api/src/main/java/org/codehaus/gmaven/runtime/util/ResourceLoader.java
// public interface ResourceLoader
// {
//     URL loadResource(final String name) throws MalformedURLException;
// }


import java.net.URL;
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyCodeSource;
import groovy.lang.GroovyResourceLoader;
import org.codehaus.gmaven.feature.Component;
import org.codehaus.gmaven.feature.ComponentException;
import org.codehaus.gmaven.feature.support.ComponentSupport;
import org.codehaus.gmaven.feature.support.FeatureSupport;
import org.codehaus.gmaven.runtime.ClassFactory;
import org.codehaus.gmaven.runtime.support.util.ResourceLoaderImpl;
import org.codehaus.gmaven.runtime.util.ClassSource;
import org.codehaus.gmaven.runtime.util.ResourceLoader;
import java.io.IOException;
import java.net.MalformedURLException;
    {
        private ClassFactoryImpl() {
            super(ClassFactoryFeature.this);
        }

        public Class create(final ClassSource classSource, final ClassLoader classLoader, final ResourceLoader resourceLoader) throws Exception {
            assert classSource != null;
            assert classLoader != null;
            // resourceLoader can be null

            GroovyClassLoader groovyClassLoader = createGroovyClassLoader(classLoader, resourceLoader);

            GroovyCodeSource codeSource = createGroovyCodeSource(classSource);

            return groovyClassLoader.parseClass(codeSource);
        }

        public Class create(final ClassSource classSource, final ClassLoader classLoader) throws Exception {
            return create(classSource, classLoader, null);
        }

        public Class create(final String className, final ClassLoader classLoader, ResourceLoader resourceLoader) throws Exception {
            assert className != null;
            assert classLoader != null;
            // resourceLoader can be null

            if (resourceLoader == null) {
                resourceLoader = new ResourceLoaderImpl(classLoader);
            }

// Path: gmaven-feature/gmaven-feature-support/src/main/java/org/codehaus/gmaven/feature/support/ComponentSupport.java
// public class ComponentSupport
//     implements Component
// {
//     protected final Logger log = LoggerFactory.getLogger(getClass());
// 
//     protected final Feature feature;
// 
//     protected final Configuration config;
// 
//     protected ComponentSupport(final Feature feature, final Configuration config) {
//         assert feature != null;
//         assert config != null;
// 
//         this.feature = feature;
//         this.config = config;
//     }
// 
//     protected ComponentSupport(final Feature feature) {
//         this(feature, new Configuration());
//     }
// 
//     public Feature feature() {
//         return feature;
//     }
// 
//     public Configuration config() {
//         return config;
//     }
// }
// 
// Path: gmaven-runtime/gmaven-runtime-api/src/main/java/org/codehaus/gmaven/runtime/util/ClassSource.java
// public class ClassSource
// {
//     public final URL url;
// 
//     public final File file;
// 
//     public final Body body;
// 
//     private ClassSource(final URL url, final File file, final Body body) {
//         this.url = url;
//         this.file = file;
//         this.body = body;
//     }
// 
//     public ClassSource(final URL url) {
//         this(url, null, null);
//     }
// 
//     public ClassSource(final File file) {
//         this(null, file, null);
//     }
// 
//     public ClassSource(final Body body) {
//         this(null, null, body);
//     }
// 
//     public String toString() {
//         return "ClassSource" +
//                 "[ url=" + url +
//                 ", file=" + file +
//                 ", body=" + body +
//                 " ]";
//     }
// 
//     //
//     // Body
//     //
// 
//     public static class Body
//     {
//         public final String name;
// 
//         public final String codeBase;
// 
//         public final InputStream input;
// 
//         public Body(final String name, final String codeBase, final InputStream input) {
//             assert name != null;
//             assert codeBase != null;
//             assert input != null;
// 
//             this.name = name;
//             this.codeBase = codeBase;
//             this.input = input;
//         }
// 
//         public Body(final String source) {
//             this("script" + System.currentTimeMillis() + ".groovy",
//                  "/groovy/script",
//                  new ByteArrayInputStream(source.getBytes()));
//         }
// 
//         public String toString() {
//             return "Body" +
//                     "[ name=" + name +
//                     ", codeBase=" + codeBase +
//                     ", input=" + input +
//                     " ]";
//         }
//     }
// 
//     //
//     // Helpers
//     //
// 
//     public static ClassSource forValue(final String source) {
//         assert source != null;
// 
//         // First try and parse the source as a URL
//         try {
//             return new ClassSource(new URL(source));
//         }
//         catch (MalformedURLException ignore) {}
// 
//         // Then as a File
//         File file = new File(source);
//         if (file.exists()) {
//             return new ClassSource(file);
//         }
// 
//         // Else its a body
//         return new ClassSource(new ClassSource.Body(source));
//     }
// }
// 
// Path: gmaven-runtime/gmaven-runtime-api/src/main/java/org/codehaus/gmaven/runtime/util/ResourceLoader.java
// public interface ResourceLoader
// {
//     URL loadResource(final String name) throws MalformedURLException;
// }


// Path: gmaven-runtime/gmaven-runtime-1.6/src/main/java/org/codehaus/gmaven/runtime/v1_6/ClassFactoryFeature.java
import java.net.URL;
import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyCodeSource;
import groovy.lang.GroovyResourceLoader;
import org.codehaus.gmaven.feature.Component;
import org.codehaus.gmaven.feature.ComponentException;
import org.codehaus.gmaven.feature.support.ComponentSupport;
import org.codehaus.gmaven.feature.support.FeatureSupport;
import org.codehaus.gmaven.runtime.ClassFactory;
import org.codehaus.gmaven.runtime.support.util.ResourceLoaderImpl;
import org.codehaus.gmaven.runtime.util.ClassSource;
import org.codehaus.gmaven.runtime.util.ResourceLoader;
import java.io.IOException;
import java.net.MalformedURLException;

    {
        private ClassFactoryImpl() {
            super(ClassFactoryFeature.this);
        }

        public Class create(final ClassSource classSource, final ClassLoader classLoader, final ResourceLoader resourceLoader) throws Exception {
            assert classSource != null;
            assert classLoader != null;
            // resourceLoader can be null

            GroovyClassLoader groovyClassLoader = createGroovyClassLoader(classLoader, resourceLoader);

            GroovyCodeSource codeSource = createGroovyCodeSource(classSource);

            return groovyClassLoader.parseClass(codeSource);
        }

        public Class create(final ClassSource classSource, final ClassLoader classLoader) throws Exception {
            return create(classSource, classLoader, null);
        }

        public Class create(final String className, final ClassLoader classLoader, ResourceLoader resourceLoader) throws Exception {
            assert className != null;
            assert classLoader != null;
            // resourceLoader can be null

            if (resourceLoader == null) {
                resourceLoader = new ResourceLoaderImpl(classLoader);
            }

            URL source = resourceLoader.loadResource(className);