From 564b6de80e6d8322284d6c9db81ecef1e5619bcd Mon Sep 17 00:00:00 2001 From: peter Date: Wed, 19 Dec 2012 17:07:40 +0100 Subject: [PATCH] add some groovyc logging and trim its output (IDEA-94812) --- .../jps/incremental/groovy/GroovyBuilder.java | 6 ++++- .../groovy/GroovycOSProcessHandler.java | 26 ++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java index 0ac63d6ee5b7..41089856a4c3 100644 --- a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java +++ b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovyBuilder.java @@ -156,10 +156,14 @@ public class GroovyBuilder extends ModuleLevelBuilder { private GroovycOSProcessHandler runGroovyc(final CompileContext context, ModuleChunk chunk, File tempFile) throws IOException { //todo xmx + ArrayList classpath = new ArrayList(generateClasspath(context, chunk)); + if (LOG.isDebugEnabled()) { + LOG.debug("Groovyc classpath: " + classpath); + } final List cmd = ExternalProcessUtil.buildJavaCommandLine( getJavaExecutable(chunk), "org.jetbrains.groovy.compiler.rt.GroovycRunner", - Collections.emptyList(), new ArrayList(generateClasspath(context, chunk)), + Collections.emptyList(), classpath, Arrays.asList("-Xmx384m", "-Dfile.encoding=" + System.getProperty("file.encoding")/*, "-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5239"*/), diff --git a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOSProcessHandler.java b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOSProcessHandler.java index 0d29c31035cf..f99d1ade7a82 100644 --- a/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOSProcessHandler.java +++ b/plugins/groovy/jps-plugin/src/org/jetbrains/jps/incremental/groovy/GroovycOSProcessHandler.java @@ -23,6 +23,7 @@ import com.intellij.openapi.util.Key; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.Consumer; +import com.intellij.util.Function; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.Nullable; import org.jetbrains.groovy.compiler.rt.GroovyCompilerMessageCategories; @@ -102,11 +103,15 @@ public class GroovycOSProcessHandler extends BaseOSProcessHandler { } final String compiled = handleOutputBuffer(GroovyRtConstants.COMPILED_START, GroovyRtConstants.COMPILED_END); - final List list = StringUtil.split(compiled, GroovyRtConstants.SEPARATOR); + final List list = splitAndTrim(compiled); String outputPath = list.get(0); String sourceFile = list.get(1); - ContainerUtil.addIfNotNull(getOutputItem(outputPath, sourceFile), myCompiledItems); + OutputItem item = new OutputItem(outputPath, sourceFile); + if (LOG.isDebugEnabled()) { + LOG.debug("Output: " + item); + } + myCompiledItems.add(item); } else if (outputBuffer.indexOf(GroovyRtConstants.TO_RECOMPILE_START) != -1) { @@ -122,7 +127,7 @@ public class GroovycOSProcessHandler extends BaseOSProcessHandler { text = handleOutputBuffer(GroovyRtConstants.MESSAGES_START, GroovyRtConstants.MESSAGES_END); - List tokens = StringUtil.split(text, GroovyRtConstants.SEPARATOR); + List tokens = splitAndTrim(text); LOG.assertTrue(tokens.size() > 4, "Wrong number of output params"); String category = tokens.get(0); @@ -150,7 +155,11 @@ public class GroovycOSProcessHandler extends BaseOSProcessHandler { ? BuildMessage.Kind.WARNING : BuildMessage.Kind.INFO; - compilerMessages.add(new CompilerMessage("Groovyc", kind, message, url, -1, -1, -1, lineInt, columnInt)); + CompilerMessage compilerMessage = new CompilerMessage("Groovyc", kind, message, url, -1, -1, -1, lineInt, columnInt); + if (LOG.isDebugEnabled()) { + LOG.debug("Message: " + compilerMessage); + } + compilerMessages.add(compilerMessage); } } } @@ -169,9 +178,12 @@ public class GroovycOSProcessHandler extends BaseOSProcessHandler { return text.trim(); } - @Nullable - private static OutputItem getOutputItem(final String outputPath, final String sourceFile) { - return new OutputItem(outputPath, sourceFile); + private static List splitAndTrim(String compiled) { + return ContainerUtil.map(StringUtil.split(compiled, GroovyRtConstants.SEPARATOR), new Function() { + public String fun(String s) { + return s.trim(); + } + }); } public List getSuccessfullyCompiled() {