From 015ac0cd5bd25ec074e8b8350f554fa79b001b21 Mon Sep 17 00:00:00 2001 From: Sergey Mashkov Date: Mon, 27 Jul 2015 21:44:30 +0300 Subject: [PATCH] Maven: take logger every time The root cause of problem is that we take logger at too early stage so there is initial bootstrap maven logger that is replaced by plexus container via injector at later initialization stage. We have to use injected logger rather than initial bootstrap logger. At the same time there is no actual performance advantage to have LOG field because of JIT inliner will inline getLog() body anyway. #KT-8630 Fixed --- .../kotlin/maven/K2JSCompilerMojo.java | 9 +++---- .../kotlin/maven/K2JVMCompileMojo.java | 14 +++++------ .../kotlin/maven/KotlinCompileMojoBase.java | 24 +++++++++---------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java index 99b2f53e791..4f0da1a9036 100644 --- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java +++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JSCompilerMojo.java @@ -75,7 +75,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase libraries = getKotlinJavascriptLibraryFiles(); - LOG.debug("libraryFiles: " + libraries); + getLog().debug("libraryFiles: " + libraries); arguments.libraryFiles = ArrayUtil.toStringArray(libraries); arguments.sourceMap = sourceMap; @@ -86,7 +86,8 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase e @Parameter public List args; - protected final Log LOG = getLog(); - @Override public void execute() throws MojoExecutionException, MojoFailureException { - LOG.info("Kotlin Compiler version " + KotlinVersion.VERSION); + getLog().info("Kotlin Compiler version " + KotlinVersion.VERSION); if (!hasKotlinFilesInSources()) { - LOG.warn("No sources found skipping Kotlin compile"); + getLog().warn("No sources found skipping Kotlin compile"); return; } @@ -131,13 +129,13 @@ public abstract class KotlinCompileMojoBase e String text = position + message; if (CompilerMessageSeverity.VERBOSE.contains(severity)) { - LOG.debug(text); + getLog().debug(text); } else if (CompilerMessageSeverity.ERRORS.contains(severity)) { - LOG.error(text); + getLog().error(text); } else if (severity == CompilerMessageSeverity.INFO) { - LOG.info(text); + getLog().info(text); } else { - LOG.warn(text); + getLog().warn(text); } } }; @@ -227,7 +225,7 @@ public abstract class KotlinCompileMojoBase e protected abstract void configureSpecificCompilerArguments(@NotNull A arguments) throws MojoExecutionException; private void configureCompilerArguments(@NotNull A arguments) throws MojoExecutionException { - if (LOG.isDebugEnabled()) { + if (getLog().isDebugEnabled()) { arguments.verbose = true; } @@ -237,18 +235,18 @@ public abstract class KotlinCompileMojoBase e sources.add(source); } else { - LOG.warn("Source root doesn't exist: " + source); + getLog().warn("Source root doesn't exist: " + source); } } - if (sources == null || sources.isEmpty()) { + if (sources.isEmpty()) { throw new MojoExecutionException("No source roots to compile"); } arguments.suppressWarnings = nowarn; arguments.freeArgs.addAll(sources); - LOG.info("Compiling Kotlin sources from " + sources); + getLog().info("Compiling Kotlin sources from " + sources); configureSpecificCompilerArguments(arguments); @@ -260,7 +258,7 @@ public abstract class KotlinCompileMojoBase e } if (arguments.noInline) { - LOG.info("Method inlining is turned off"); + getLog().info("Method inlining is turned off"); } } }