make it more clear in while loading which class from which module did NCDFE occur inside groovyc

This commit is contained in:
peter
2016-06-30 11:16:52 +02:00
parent e4e98fe046
commit 964a06d8a9
4 changed files with 22 additions and 3 deletions
@@ -158,6 +158,11 @@ public class GroovycOutputParser {
? BuildMessage.Kind.WARNING
: BuildMessage.Kind.INFO;
if (StringUtil.isEmpty(url) || "null".equals(url)) {
url = null;
message = "While compiling " + myChunk.getPresentableShortName() + ": " + message;
}
CompilerMessage compilerMessage = new CompilerMessage("Groovyc", kind, message, url, -1, -1, -1, lineInt, columnInt);
if (LOG.isDebugEnabled()) {
LOG.debug("Message: " + compilerMessage);
@@ -227,7 +232,7 @@ public class GroovycOutputParser {
if (msg.contains(GroovyRtConstants.NO_GROOVY)) {
messages.add(reportNoGroovy());
} else {
messages.add(new CompilerMessage("Groovyc", BuildMessage.Kind.INFO, msg));
messages.add(new CompilerMessage("Groovyc", BuildMessage.Kind.INFO, "While compiling " + myChunk.getPresentableShortName() + ":" + msg));
}
}
@@ -32,6 +32,18 @@ class JointCompilationClassLoader extends UrlClassLoader {
myClassPath = super.getClassPath();
}
@Override
protected Class _defineClass(String name, byte[] b) {
try {
return super._defineClass(name, b);
}
catch (NoClassDefFoundError e) {
NoClassDefFoundError wrap = new NoClassDefFoundError(e.getMessage() + " needed for " + name);
wrap.initCause(e);
throw wrap;
}
}
@NotNull
@Override
protected ClassPath getClassPath() {
@@ -73,7 +73,7 @@ public class GroovyCompilerWrapper {
}
catch (NoClassDefFoundError e) {
final String className = e.getMessage();
if (className.startsWith("org/apache/ivy/")) {
if (className.contains("org/apache/ivy/")) {
addMessageWithoutLocation("Cannot @Grab without Ivy, please add it to your module dependencies (NoClassDefFoundError: " + className + ")", true);
} else {
throw e;
@@ -23,6 +23,7 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.*;
@@ -135,7 +136,8 @@ public class GroovycRunner {
method.invoke(null, forStubs, argPath, configScript, mailbox);
}
catch (Throwable e) {
while (e.getCause() != null) {
//noinspection InstanceofCatchParameter
while (e instanceof InvocationTargetException) {
e = e.getCause();
}
e.printStackTrace();