diff --git a/compiler/cli/src/org/jetbrains/jet/compiler/CompileEnvironment.java b/compiler/cli/src/org/jetbrains/jet/compiler/CompileEnvironment.java index 187e6649fbc..d0caf14f664 100644 --- a/compiler/cli/src/org/jetbrains/jet/compiler/CompileEnvironment.java +++ b/compiler/cli/src/org/jetbrains/jet/compiler/CompileEnvironment.java @@ -181,6 +181,8 @@ public class CompileEnvironment { final String directory = new File(moduleScriptFile).getParent(); for (Module moduleBuilder : modules) { CompileEnvironment compileEnvironment = new CompileEnvironment(myFileNameTransformer, myMessageRenderer); + // copy across any compiler plugins + compileEnvironment.getMyEnvironment().getCompilerPlugins().addAll(myEnvironment.getCompilerPlugins()); ClassFileFactory moduleFactory = compileEnvironment.compileModule(moduleBuilder, directory); if (moduleFactory == null) { return false; @@ -208,7 +210,7 @@ public class CompileEnvironment { if (!scriptCompileSession.analyze(myErrorStream, myMessageRenderer)) { return null; } - final ClassFileFactory factory = scriptCompileSession.generate(); + final ClassFileFactory factory = scriptCompileSession.generate(true); return runDefineModules(moduleFile, factory); } @@ -267,7 +269,7 @@ public class CompileEnvironment { if (!moduleCompileSession.analyze(myErrorStream, myMessageRenderer) && !ignoreErrors) { return null; } - return moduleCompileSession.generate(); + return moduleCompileSession.generate(false); } public static void writeToJar(ClassFileFactory factory, final OutputStream fos, @Nullable String mainClass, boolean includeRuntime) { @@ -355,7 +357,7 @@ public class CompileEnvironment { return null; } - ClassFileFactory factory = session.generate(); + ClassFileFactory factory = session.generate(false); return new GeneratedClassLoader(factory); } @@ -380,7 +382,7 @@ public class CompileEnvironment { return false; } - ClassFileFactory factory = session.generate(); + ClassFileFactory factory = session.generate(false); if (jar != null) { try { writeToJar(factory, new FileOutputStream(jar), mainClass, includeRuntime); diff --git a/compiler/cli/src/org/jetbrains/jet/compiler/CompileSession.java b/compiler/cli/src/org/jetbrains/jet/compiler/CompileSession.java index f67e87e4617..ec53cd8a23b 100644 --- a/compiler/cli/src/org/jetbrains/jet/compiler/CompileSession.java +++ b/compiler/cli/src/org/jetbrains/jet/compiler/CompileSession.java @@ -209,16 +209,18 @@ public class CompileSession { } @NotNull - public ClassFileFactory generate() { + public ClassFileFactory generate(boolean module) { Project project = myEnvironment.getProject(); GenerationState generationState = new GenerationState(project, ClassBuilderFactories.binaries(stubs), myFileNameTransformer); generationState.compileCorrectFiles(myBindingContext, mySourceFiles, CompilationErrorHandler.THROW_EXCEPTION, true); ClassFileFactory answer = generationState.getFactory(); - List fileProcessors = myEnvironment.getCompilerPlugins(); - if (fileProcessors != null) { - for (CompilerPlugin processor : fileProcessors) { - processor.processFiles(myBindingContext, getSourceFileNamespaces()); + List plugins = myEnvironment.getCompilerPlugins(); + if (!module) { + if (plugins != null) { + for (CompilerPlugin plugin : plugins) { + plugin.processFiles(myBindingContext, getSourceFileNamespaces()); + } } } return answer; diff --git a/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java b/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java index 2336c3e013d..2f999a3d9e1 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java @@ -89,7 +89,7 @@ public class TestlibTest extends CodegenTestCase { throw new RuntimeException("There were compilation errors"); } - ClassFileFactory classFileFactory = session.generate(); + ClassFileFactory classFileFactory = session.generate(false); final GeneratedClassLoader loader = new GeneratedClassLoader( classFileFactory,