diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java index 81208b0f249..93442bec1f9 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinCompileMojoBase.java @@ -28,6 +28,8 @@ import org.jetbrains.jet.cli.KotlinCompiler; import java.io.File; import java.io.IOException; +import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.net.URL; import java.util.ArrayList; import java.util.List; @@ -109,6 +111,8 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { final KotlinCompiler compiler = createCompiler(); + printCompilerArgumentsIfDebugEnabled(arguments, compiler); + final KotlinCompiler.ExitCode exitCode = compiler.exec(System.err, arguments); switch (exitCode) { @@ -120,6 +124,25 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { } } + private void printCompilerArgumentsIfDebugEnabled(CompilerArguments arguments, KotlinCompiler compiler) { + if (getLog().isDebugEnabled()) { + getLog().debug("Invoking compiler " + compiler + " with arguments:"); + try { + Field[] fields = arguments.getClass().getFields(); + for (Field f : fields) { + Object value = f.get(arguments); + if (value != null) { + getLog().debug(f.getName() + "=" + value); + } + } + getLog().debug("End of arguments"); + } + catch (Exception e) { + getLog().warn("Failed to print compiler arguments: " + e, e); + } + } + } + protected KotlinCompiler createCompiler() { return new KotlinCompiler(); }