// Path: nicobar-core/src/main/java/com/netflix/nicobar/core/compile/ScriptArchiveCompiler.java
// public interface ScriptArchiveCompiler {
//     /**
//      * Whether or not this compiler should be used to compile the archive
//      */
//     public boolean shouldCompile(ScriptArchive archive);
// 
//     /**
//      * Compile the archive into a ScriptModule
//      * @param archive archive to generate class files for
//      * @param moduleClassLoader class loader which can be used to find all classes and resources for modules.
//      *  The resultant classes of the compile operation should be injected into the classloader
//      *  for which the given archive has a declared dependency on
//      * @param targetDir a directory in which to store compiled classes, if any.
//      * @return The set of classes that were compiled
//      * @throws ScriptCompilationException if there was a compilation issue in the archive.
//      * @throws IOException if there was a problem reading/writing the archive
//      */
//     public Set<Class<?>> compile(ScriptArchive archive, JBossModuleClassLoader moduleClassLoader, Path targetDir) throws ScriptCompilationException, IOException;
// }
// 
// Path: nicobar-core/src/main/java/com/netflix/nicobar/core/plugin/ScriptCompilerPlugin.java
// public interface ScriptCompilerPlugin {
// 
//     public Set<? extends ScriptArchiveCompiler> getCompilers(Map<String, Object> compilerParams);
// }
// 
// Path: nicobar-groovy2/src/main/java/com/netflix/nicobar/groovy2/internal/compile/Groovy2Compiler.java
// public class Groovy2Compiler implements ScriptArchiveCompiler {
// 
//     public final static String GROOVY2_COMPILER_ID = "groovy2";
//     public final static String GROOVY2_COMPILER_PARAMS_CUSTOMIZERS = "customizerClassNames";
// 
//     private List<String> customizerClassNames = new LinkedList<String>();
// 
//     public Groovy2Compiler(Map<String, Object> compilerParams) {
//         this.processCompilerParams(compilerParams);
//     }
// 
//     private void processCompilerParams(Map<String, Object> compilerParams) {
//         
//         // filtering compilation customizers class names
//         if (compilerParams.containsKey(GROOVY2_COMPILER_PARAMS_CUSTOMIZERS)) {
//             Object customizers = compilerParams.get(GROOVY2_COMPILER_PARAMS_CUSTOMIZERS);
// 
//             if (customizers instanceof List) {
//                 for (Object customizerClassName: (List<?>) customizers) {
//                     if (customizerClassName instanceof String) {
//                         this.customizerClassNames.add((String)customizerClassName);
//                     }
//                 }
//             }
//         }
//     }
// 
//     private CompilationCustomizer getCustomizerInstanceFromString(String className, JBossModuleClassLoader moduleClassLoader) {
//         CompilationCustomizer instance = null;
// 
//         try {
//             // TODO: replace JBossModuleClassLoader with generic class loader
//             ClassLoader classLoader = moduleClassLoader != null ?
//                     moduleClassLoader : Thread.currentThread().getContextClassLoader();
// 
//             Class<?> klass = classLoader.loadClass(className);
//             instance = (CompilationCustomizer)klass.newInstance();
//         } 
//         catch (InstantiationException | IllegalAccessException | ClassNotFoundException | ClassCastException e) {
//             e.printStackTrace();
//             // TODO: add logger support for compiler (due to a separate class loader logger is not visible)
//         }
//         return instance;
//     }
// 
//     @Override
//     public boolean shouldCompile(ScriptArchive archive) {
//        return archive.getModuleSpec().getCompilerPluginIds().contains(GROOVY2_COMPILER_ID);
//     }
// 
//     @Override
//     public Set<Class<?>> compile(ScriptArchive archive, JBossModuleClassLoader moduleClassLoader, Path compilationRootDir)
//         throws ScriptCompilationException, IOException {
//         
//         List<CompilationCustomizer> customizers = new LinkedList<CompilationCustomizer>();
// 
//         for (String klassName: this.customizerClassNames) {
//             CompilationCustomizer instance = this.getCustomizerInstanceFromString(klassName, moduleClassLoader);
//             if (instance != null ) {
//                 customizers.add(instance);
//             }
//         }
// 
//         CompilerConfiguration config = new CompilerConfiguration(CompilerConfiguration.DEFAULT);
//         config.addCompilationCustomizers(customizers.toArray(new CompilationCustomizer[0]));
// 
//          new Groovy2CompilerHelper(compilationRootDir)
//             .addScriptArchive(archive)
//             .withParentClassloader(moduleClassLoader) // TODO: replace JBossModuleClassLoader with generic class loader
//             .withConfiguration(config)
//             .compile();
//         return Collections.emptySet();
//     }
// }


import java.util.Collections;
import java.util.Map;
import java.util.Set;
import com.netflix.nicobar.core.compile.ScriptArchiveCompiler;
import com.netflix.nicobar.core.plugin.ScriptCompilerPlugin;
import com.netflix.nicobar.groovy2.internal.compile.Groovy2Compiler;
/*
 *
 *  Copyright 2013 Netflix, Inc.
 *
 *     Licensed under the Apache License, Version 2.0 (the "License");
 *     you may not use this file except in compliance with the License.
 *     You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *     Unless required by applicable law or agreed to in writing, software
 *     distributed under the License is distributed on an "AS IS" BASIS,
 *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *     See the License for the specific language governing permissions and
 *     limitations under the License.
 *
 */
package com.netflix.nicobar.groovy2.plugin;



/**
 * Factory class for the Groovy 2 language plug-in
 *
 * @author James Kojo
 * @author Vasanth Asokan
 */
public class Groovy2CompilerPlugin implements ScriptCompilerPlugin {

    public static final String PLUGIN_ID = "groovy2";

    public Groovy2CompilerPlugin() {
    }

    @Override
// Path: nicobar-core/src/main/java/com/netflix/nicobar/core/compile/ScriptArchiveCompiler.java
// public interface ScriptArchiveCompiler {
//     /**
//      * Whether or not this compiler should be used to compile the archive
//      */
//     public boolean shouldCompile(ScriptArchive archive);
// 
//     /**
//      * Compile the archive into a ScriptModule
//      * @param archive archive to generate class files for
//      * @param moduleClassLoader class loader which can be used to find all classes and resources for modules.
//      *  The resultant classes of the compile operation should be injected into the classloader
//      *  for which the given archive has a declared dependency on
//      * @param targetDir a directory in which to store compiled classes, if any.
//      * @return The set of classes that were compiled
//      * @throws ScriptCompilationException if there was a compilation issue in the archive.
//      * @throws IOException if there was a problem reading/writing the archive
//      */
//     public Set<Class<?>> compile(ScriptArchive archive, JBossModuleClassLoader moduleClassLoader, Path targetDir) throws ScriptCompilationException, IOException;
// }
// 
// Path: nicobar-core/src/main/java/com/netflix/nicobar/core/plugin/ScriptCompilerPlugin.java
// public interface ScriptCompilerPlugin {
// 
//     public Set<? extends ScriptArchiveCompiler> getCompilers(Map<String, Object> compilerParams);
// }
// 
// Path: nicobar-groovy2/src/main/java/com/netflix/nicobar/groovy2/internal/compile/Groovy2Compiler.java
// public class Groovy2Compiler implements ScriptArchiveCompiler {
// 
//     public final static String GROOVY2_COMPILER_ID = "groovy2";
//     public final static String GROOVY2_COMPILER_PARAMS_CUSTOMIZERS = "customizerClassNames";
// 
//     private List<String> customizerClassNames = new LinkedList<String>();
// 
//     public Groovy2Compiler(Map<String, Object> compilerParams) {
//         this.processCompilerParams(compilerParams);
//     }
// 
//     private void processCompilerParams(Map<String, Object> compilerParams) {
//         
//         // filtering compilation customizers class names
//         if (compilerParams.containsKey(GROOVY2_COMPILER_PARAMS_CUSTOMIZERS)) {
//             Object customizers = compilerParams.get(GROOVY2_COMPILER_PARAMS_CUSTOMIZERS);
// 
//             if (customizers instanceof List) {
//                 for (Object customizerClassName: (List<?>) customizers) {
//                     if (customizerClassName instanceof String) {
//                         this.customizerClassNames.add((String)customizerClassName);
//                     }
//                 }
//             }
//         }
//     }
// 
//     private CompilationCustomizer getCustomizerInstanceFromString(String className, JBossModuleClassLoader moduleClassLoader) {
//         CompilationCustomizer instance = null;
// 
//         try {
//             // TODO: replace JBossModuleClassLoader with generic class loader
//             ClassLoader classLoader = moduleClassLoader != null ?
//                     moduleClassLoader : Thread.currentThread().getContextClassLoader();
// 
//             Class<?> klass = classLoader.loadClass(className);
//             instance = (CompilationCustomizer)klass.newInstance();
//         } 
//         catch (InstantiationException | IllegalAccessException | ClassNotFoundException | ClassCastException e) {
//             e.printStackTrace();
//             // TODO: add logger support for compiler (due to a separate class loader logger is not visible)
//         }
//         return instance;
//     }
// 
//     @Override
//     public boolean shouldCompile(ScriptArchive archive) {
//        return archive.getModuleSpec().getCompilerPluginIds().contains(GROOVY2_COMPILER_ID);
//     }
// 
//     @Override
//     public Set<Class<?>> compile(ScriptArchive archive, JBossModuleClassLoader moduleClassLoader, Path compilationRootDir)
//         throws ScriptCompilationException, IOException {
//         
//         List<CompilationCustomizer> customizers = new LinkedList<CompilationCustomizer>();
// 
//         for (String klassName: this.customizerClassNames) {
//             CompilationCustomizer instance = this.getCustomizerInstanceFromString(klassName, moduleClassLoader);
//             if (instance != null ) {
//                 customizers.add(instance);
//             }
//         }
// 
//         CompilerConfiguration config = new CompilerConfiguration(CompilerConfiguration.DEFAULT);
//         config.addCompilationCustomizers(customizers.toArray(new CompilationCustomizer[0]));
// 
//          new Groovy2CompilerHelper(compilationRootDir)
//             .addScriptArchive(archive)
//             .withParentClassloader(moduleClassLoader) // TODO: replace JBossModuleClassLoader with generic class loader
//             .withConfiguration(config)
//             .compile();
//         return Collections.emptySet();
//     }
// }


// Path: nicobar-groovy2/src/main/java/com/netflix/nicobar/groovy2/plugin/Groovy2CompilerPlugin.java
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import com.netflix.nicobar.core.compile.ScriptArchiveCompiler;
import com.netflix.nicobar.core.plugin.ScriptCompilerPlugin;
import com.netflix.nicobar.groovy2.internal.compile.Groovy2Compiler;

/*
 *
 *  Copyright 2013 Netflix, Inc.
 *
 *     Licensed under the Apache License, Version 2.0 (the "License");
 *     you may not use this file except in compliance with the License.
 *     You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *     Unless required by applicable law or agreed to in writing, software
 *     distributed under the License is distributed on an "AS IS" BASIS,
 *     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *     See the License for the specific language governing permissions and
 *     limitations under the License.
 *
 */
package com.netflix.nicobar.groovy2.plugin;



/**
 * Factory class for the Groovy 2 language plug-in
 *
 * @author James Kojo
 * @author Vasanth Asokan
 */
public class Groovy2CompilerPlugin implements ScriptCompilerPlugin {

    public static final String PLUGIN_ID = "groovy2";

    public Groovy2CompilerPlugin() {
    }

    @Override
    public Set<? extends ScriptArchiveCompiler> getCompilers(Map<String, Object> compilerParams) {