mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix groovyc classpath for test sources
This commit is contained in:
@@ -56,8 +56,9 @@ public class GroovyCompiler extends GroovyCompilerBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void compileFiles(CompileContext compileContext, Module module, List<VirtualFile> toCompile, VirtualFile outputDir, OutputSink sink) {
|
||||
runGroovycCompiler(compileContext, module, toCompile, false, outputDir, sink);
|
||||
protected void compileFiles(CompileContext compileContext, Module module, List<VirtualFile> toCompile, VirtualFile outputDir, OutputSink sink,
|
||||
boolean tests) {
|
||||
runGroovycCompiler(compileContext, module, toCompile, false, outputDir, sink, tests);
|
||||
}
|
||||
|
||||
public boolean validateConfiguration(CompileScope compileScope) {
|
||||
|
||||
@@ -87,7 +87,7 @@ public abstract class GroovyCompilerBase implements TranslatingCompiler {
|
||||
final List<VirtualFile> toCompile,
|
||||
boolean forStubs,
|
||||
VirtualFile outputDir,
|
||||
OutputSink sink) {
|
||||
OutputSink sink, boolean tests) {
|
||||
GeneralCommandLine commandLine = new GeneralCommandLine();
|
||||
final Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
|
||||
assert sdk != null; //verified before
|
||||
@@ -133,7 +133,7 @@ public abstract class GroovyCompilerBase implements TranslatingCompiler {
|
||||
|
||||
try {
|
||||
File fileWithParameters = File.createTempFile("toCompile", "");
|
||||
fillFileWithGroovycParameters(module, toCompile, fileWithParameters, compileContext, outputDir, patchers);
|
||||
fillFileWithGroovycParameters(module, toCompile, fileWithParameters, compileContext, outputDir, patchers, tests);
|
||||
|
||||
commandLine.addParameter(forStubs ? "stubs" : "groovyc");
|
||||
commandLine.addParameter(fileWithParameters.getPath());
|
||||
@@ -225,7 +225,7 @@ public abstract class GroovyCompilerBase implements TranslatingCompiler {
|
||||
}
|
||||
|
||||
private void fillFileWithGroovycParameters(Module module, List<VirtualFile> virtualFiles, File f, CompileContext context,
|
||||
VirtualFile outputDir, final List<String> patchers) {
|
||||
VirtualFile outputDir, final List<String> patchers, boolean tests) {
|
||||
if (LOG.isDebugEnabled()) {
|
||||
LOG.debug("Running groovyc on: " + virtualFiles.toString());
|
||||
}
|
||||
@@ -259,7 +259,12 @@ public abstract class GroovyCompilerBase implements TranslatingCompiler {
|
||||
|
||||
printer.println(GroovycRunner.CLASSPATH);
|
||||
final ModuleChunk chunk = createChunk(module, context);
|
||||
printer.println(chunk.getCompilationClasspath() + File.pathSeparator + CompilerPaths.getModuleOutputPath(module, false) + File.pathSeparator + CompilerPaths.getModuleOutputPath(module, true));
|
||||
StringBuilder compileClasspath = new StringBuilder(chunk.getCompilationClasspath());
|
||||
appendOutputPath(module, compileClasspath, false);
|
||||
if (tests) {
|
||||
appendOutputPath(module, compileClasspath, true);
|
||||
}
|
||||
printer.println(compileClasspath.toString());
|
||||
|
||||
if (!patchers.isEmpty()) {
|
||||
printer.println(GroovycRunner.PATCHERS);
|
||||
@@ -281,6 +286,14 @@ public abstract class GroovyCompilerBase implements TranslatingCompiler {
|
||||
printer.close();
|
||||
}
|
||||
|
||||
private static void appendOutputPath(Module module, StringBuilder compileClasspath, final boolean forTestClasses) {
|
||||
String output = CompilerPaths.getModuleOutputPath(module, forTestClasses);
|
||||
if (output != null) {
|
||||
compileClasspath.append(File.pathSeparator);
|
||||
compileClasspath.append(FileUtil.toSystemDependentName(output));
|
||||
}
|
||||
}
|
||||
|
||||
private static ModuleChunk createChunk(Module module, CompileContext context) {
|
||||
return new ModuleChunk((CompileContextEx)context, new Chunk<Module>(module), Collections.<Module, List<VirtualFile>>emptyMap());
|
||||
}
|
||||
@@ -313,10 +326,10 @@ public abstract class GroovyCompilerBase implements TranslatingCompiler {
|
||||
}
|
||||
|
||||
if (!toCompile.isEmpty()) {
|
||||
compileFiles(compileContext, module, toCompile, compileContext.getModuleOutputDirectory(module), sink);
|
||||
compileFiles(compileContext, module, toCompile, compileContext.getModuleOutputDirectory(module), sink, false);
|
||||
}
|
||||
if (!toCompileTests.isEmpty()) {
|
||||
compileFiles(compileContext, module, toCompileTests, compileContext.getModuleOutputDirectoryForTests(module), sink);
|
||||
compileFiles(compileContext, module, toCompileTests, compileContext.getModuleOutputDirectoryForTests(module), sink, true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -326,7 +339,7 @@ public abstract class GroovyCompilerBase implements TranslatingCompiler {
|
||||
protected abstract void compileFiles(CompileContext compileContext, Module module,
|
||||
List<VirtualFile> toCompile,
|
||||
VirtualFile outputDir,
|
||||
OutputSink sink);
|
||||
OutputSink sink, boolean tests);
|
||||
|
||||
public boolean isCompilableFile(VirtualFile file, CompileContext context) {
|
||||
final boolean result = GroovyFileType.GROOVY_FILE_TYPE.equals(file.getFileType());
|
||||
|
||||
+3
-3
@@ -80,7 +80,7 @@ public class GroovycStubGenerator extends GroovyCompilerBase {
|
||||
|
||||
@Override
|
||||
protected void compileFiles(CompileContext compileContext, Module module,
|
||||
final List<VirtualFile> toCompile, VirtualFile outputDir, OutputSink sink) {
|
||||
final List<VirtualFile> toCompile, VirtualFile outputDir, OutputSink sink, boolean tests) {
|
||||
boolean hasGroovy = false;
|
||||
boolean hasJava = false;
|
||||
for (final VirtualFile file : toCompile) {
|
||||
@@ -109,9 +109,9 @@ public class GroovycStubGenerator extends GroovyCompilerBase {
|
||||
assert tempOutput != null;
|
||||
cleanDirectory(tempOutput);
|
||||
|
||||
((CompileContextEx)compileContext).assignModule(tempOutput, module, false);
|
||||
((CompileContextEx)compileContext).assignModule(tempOutput, module, tests);
|
||||
|
||||
runGroovycCompiler(compileContext, module, toCompile, true, tempOutput, sink);
|
||||
runGroovycCompiler(compileContext, module, toCompile, true, tempOutput, sink, tests);
|
||||
}
|
||||
|
||||
private VirtualFile createMockJavaFile(final String rootPath) {
|
||||
|
||||
Reference in New Issue
Block a user