title: About Adding import package in Groovy by customizing compilation process
body: <p>I am writing a java file in which i am parsing the given groovy file using GroovyClassLoader to find the class in it. To do this, i have to import some class (like org.junit.Test) and add  package and add static import also. Since i am using old groovy version 1.6, i can not use compilation customizers as these classes not available in this version. So to import custom classes, i had to write custom groovy class loader by extending groovy class loader class like below,</p>
  
  <p>...</p>
  
  <pre><code>public static class DefaultImportClassLoader extends GroovyClassLoader {
  public DefaultImportClassLoader(ClassLoader cl){
      super(cl);
  }
  
  public CompilationUnit createCompilationUnit(CompilerConfiguration config, CodeSource codeSource) {
           CompilationUnit cu = super.createCompilationUnit(config, codeSource);
           cu.addPhaseOperation(new SourceUnitOperation() {
           public void call(SourceUnit source) throws CompilationFailedException {
               //source.getAST().addImport("Test",ClassHelper.make("org.junit.Test")); //working
          source.getAST().addImportPackage("org.junit.");
          }}, Phases.CONVERSION);
  
          return cu;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>here add import package is not working. Would any one give right suggestion way of using addImportPackage().</p>