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
This commit is contained in:
+5
-4
@@ -75,7 +75,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase<K2JSCompilerArgument
|
||||
arguments.metaInfo = metaInfo;
|
||||
|
||||
List<String> 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<K2JSCompilerArgument
|
||||
collector.add(new File(outputFile).getParent());
|
||||
}
|
||||
if (metaInfo) {
|
||||
String metaFile = KotlinPackage.substringBeforeLast(outputFile, JavaScript.DOT_EXTENSION, outputFile) + KotlinJavascriptMetadataUtils.META_JS_SUFFIX;
|
||||
String output = com.google.common.base.Objects.firstNonNull(outputFile, ""); // fqname here because of J8 compatibility issues
|
||||
String metaFile = KotlinPackage.substringBeforeLast(output, JavaScript.DOT_EXTENSION, output) + KotlinJavascriptMetadataUtils.META_JS_SUFFIX;
|
||||
collector.add(new File(metaFile).getParent());
|
||||
}
|
||||
}
|
||||
@@ -107,7 +108,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase<K2JSCompilerArgument
|
||||
libraries.add(file.getAbsolutePath());
|
||||
}
|
||||
else {
|
||||
LOG.warn("artifact " + artifact + " is not a Kotlin Javascript Library");
|
||||
getLog().warn("artifact " + artifact + " is not a Kotlin Javascript Library");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,7 +118,7 @@ public class K2JSCompilerMojo extends KotlinCompileMojoBase<K2JSCompilerArgument
|
||||
libraries.add(file);
|
||||
}
|
||||
else {
|
||||
LOG.warn("JS output directory missing: " + file);
|
||||
getLog().warn("JS output directory missing: " + file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-7
@@ -85,14 +85,14 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase<K2JVMCompilerArgumen
|
||||
|
||||
@Override
|
||||
protected void configureSpecificCompilerArguments(@NotNull K2JVMCompilerArguments arguments) throws MojoExecutionException {
|
||||
LOG.info("Classes directory is " + output);
|
||||
getLog().info("Classes directory is " + output);
|
||||
arguments.destination = output;
|
||||
|
||||
// don't include runtime, it should be in maven dependencies
|
||||
arguments.noStdlib = true;
|
||||
|
||||
if (module != null) {
|
||||
LOG.info("Compiling Kotlin module " + module);
|
||||
getLog().info("Compiling Kotlin module " + module);
|
||||
arguments.module = module;
|
||||
}
|
||||
|
||||
@@ -100,16 +100,16 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase<K2JVMCompilerArgumen
|
||||
|
||||
if (!classpathList.isEmpty()) {
|
||||
String classPathString = join(classpathList, File.pathSeparator);
|
||||
LOG.info("Classpath: " + classPathString);
|
||||
getLog().info("Classpath: " + classPathString);
|
||||
arguments.classpath = classPathString;
|
||||
}
|
||||
|
||||
LOG.info("Classes directory is " + output);
|
||||
getLog().info("Classes directory is " + output);
|
||||
arguments.destination = output;
|
||||
|
||||
arguments.noJdkAnnotations = true;
|
||||
arguments.annotations = getFullAnnotationsPath(LOG, annotationPaths);
|
||||
LOG.info("Using kotlin annotations from " + arguments.annotations);
|
||||
arguments.annotations = getFullAnnotationsPath(getLog(), annotationPaths);
|
||||
getLog().info("Using kotlin annotations from " + arguments.annotations);
|
||||
|
||||
try {
|
||||
Args.parse(arguments, ArrayUtil.toStringArray(args));
|
||||
@@ -119,7 +119,7 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase<K2JVMCompilerArgumen
|
||||
}
|
||||
|
||||
if (arguments.noOptimize) {
|
||||
LOG.info("Optimization is turned off");
|
||||
getLog().info("Optimization is turned off");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
-13
@@ -104,15 +104,13 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
||||
@Parameter
|
||||
public List<String> 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<A extends CommonCompilerArguments> 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<A extends CommonCompilerArguments> 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<A extends CommonCompilerArguments> 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<A extends CommonCompilerArguments> e
|
||||
}
|
||||
|
||||
if (arguments.noInline) {
|
||||
LOG.info("Method inlining is turned off");
|
||||
getLog().info("Method inlining is turned off");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user