Maven: KT-15050 setup logger so IDEA's core could log error

Introduce system property kotlin.compiler.X.enable.idea.logger=true
The reason is that I suspect that the error is somewhere at com.intellij.ide.plugins.PluginManagerCore#loadDescriptorFromJar but unfortunately default logger doesn't log messages at "info" log level so we can't see why exactly does it fail.
Users can enable IDEA's logger to see more details.
This commit is contained in:
Sergey Mashkov
2017-04-14 21:45:02 +03:00
parent 7e6df03421
commit 96160606ba
2 changed files with 95 additions and 0 deletions
@@ -0,0 +1,88 @@
package org.jetbrains.kotlin.maven;
import com.intellij.openapi.diagnostic.Logger;
import org.apache.log4j.Level;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.logging.SystemStreamLog;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.StringJoiner;
public class IdeaCoreLoggerFactory implements Logger.Factory {
@NotNull
private final Log parent;
public IdeaCoreLoggerFactory(@NotNull Log parent) {
this.parent = parent;
}
public IdeaCoreLoggerFactory() {
this(new SystemStreamLog());
}
@NotNull
@Override
public Logger getLoggerInstance(@NotNull String s) {
return new Logger() {
@Override
public boolean isDebugEnabled() {
return parent.isDebugEnabled();
}
@Override
public void debug(String s) {
parent.debug(s);
}
@Override
public void debug(@Nullable Throwable throwable) {
parent.debug(s);
}
@Override
public void debug(String s, @Nullable Throwable throwable) {
parent.debug(s, throwable);
}
@Override
public void info(String s) {
parent.info(s);
}
@Override
public void info(String s, @Nullable Throwable throwable) {
parent.info(s, throwable);
}
@Override
public void warn(String s, @Nullable Throwable throwable) {
parent.warn(s, throwable);
}
@Override
public void error(String s, @Nullable Throwable throwable, @NotNull String... strings) {
String message = s;
if (strings.length > 0) {
StringJoiner j = new StringJoiner("\n");
j.add(s);
j.add("details:");
for (String details : strings) {
j.add(details);
}
message = j.toString();
}
parent.error(message, throwable);
}
@Override
public void setLevel(Level level) {
}
};
}
}
@@ -17,6 +17,7 @@
package org.jetbrains.kotlin.maven;
import com.google.common.base.Joiner;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Processor;
@@ -189,6 +190,12 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
private final static Pattern OPTION_PATTERN = Pattern.compile("([^:]+):([^=]+)=(.*)");
static {
if (System.getProperty("kotlin.compiler.X.enable.idea.logger") != null) {
Logger.setFactory(IdeaCoreLoggerFactory.class);
}
}
@Override
public void execute() throws MojoExecutionException, MojoFailureException {