Maven: Make compiler plugin option reporting more user-friendly
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
[INFO] Kotlin Compiler version @snapshot@
|
||||
[INFO] Compiling Kotlin sources from [/test-extension/src/main/kotlin]
|
||||
[INFO] Module name is test-extension
|
||||
[WARNING] Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version @snapshot@ the Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath or use '-Xskip-runtime-version-check' to suppress this warning
|
||||
[WARNING] /local-repo/org/jetbrains/kotlin/kotlin-compiler/1.1-SNAPSHOT/kotlin-compiler-1.1-SNAPSHOT.jar: (-1, -1) Library has Kotlin runtime bundled into it
|
||||
[INFO] Kotlin Compiler version @snapshot@
|
||||
[WARNING] No sources found skipping Kotlin compile
|
||||
[INFO] Kotlin Compiler version @snapshot@
|
||||
[INFO] Compiling Kotlin sources from [/use-test-extension/src/main/kotlin]
|
||||
[INFO] Module name is use-test-extension
|
||||
[INFO] Applicability test for project use-test-extension
|
||||
[INFO] Applied plugin: 'test-me'
|
||||
[INFO] Configuring test plugin with arguments
|
||||
[INFO] Options for plugin test-me: [plugin:org.jetbrains.kotlin.test.test-plugin:test-option=my-special-value]
|
||||
[INFO] Plugin applied
|
||||
[INFO] Option value: my-special-value
|
||||
[INFO] Kotlin Compiler version @snapshot@
|
||||
[WARNING] No sources found skipping Kotlin compile
|
||||
[WARNING] No sources found skipping Kotlin compile
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-compiler-extensions-test</artifactId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<modules>
|
||||
<module>test-extension</module>
|
||||
<module>use-test-extension</module>
|
||||
|
||||
@@ -5,16 +5,12 @@
|
||||
<parent>
|
||||
<artifactId>kotlin-compiler-extensions-test</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>test-extension</artifactId>
|
||||
|
||||
<properties>
|
||||
<kotlin.version>1.1-SNAPSHOT</kotlin.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
|
||||
+1
@@ -23,6 +23,7 @@ class MavenPluginComponent : KotlinMavenPluginExtension {
|
||||
logger.info("Configuring test plugin with arguments")
|
||||
|
||||
return listOf(PluginOption(
|
||||
"test-me",
|
||||
TestCommandLineProcessor.TestPluginId,
|
||||
TestCommandLineProcessor.MyTestOption.name,
|
||||
"my-special-value"))
|
||||
|
||||
+1
-6
@@ -5,17 +5,12 @@
|
||||
<parent>
|
||||
<artifactId>kotlin-compiler-extensions-test</artifactId>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<version>1.1-SNAPSHOT</version>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>use-test-extension</artifactId>
|
||||
|
||||
|
||||
<properties>
|
||||
<kotlin.version>1.1-SNAPSHOT</kotlin.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
|
||||
+34
-3
@@ -328,10 +328,13 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
||||
String pluginName = pluginEntry.getKey();
|
||||
KotlinMavenPluginExtension plugin = pluginEntry.getValue();
|
||||
|
||||
// applied plugin (...) to info()
|
||||
if (plugin.isApplicable(project, mojoExecution)) {
|
||||
getLog().info("Applied plugin: '" + pluginName + "'");
|
||||
List<PluginOption> optionsForPlugin = plugin.getPluginOptions(project, mojoExecution);
|
||||
getLog().info("Options for plugin " + pluginName + ": " + optionsForPlugin);
|
||||
pluginOptions.addAll(optionsForPlugin);
|
||||
if (!optionsForPlugin.isEmpty()) {
|
||||
pluginOptions.addAll(optionsForPlugin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,6 +342,34 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
||||
pluginOptions.addAll(parseUserProvidedPluginOptions(this.pluginOptions, plugins));
|
||||
}
|
||||
|
||||
Map<String, List<PluginOption>> optionsByPluginName = new LinkedHashMap<String, List<PluginOption>>();
|
||||
for (PluginOption option : pluginOptions) {
|
||||
List<PluginOption> optionsForPlugin = optionsByPluginName.get(option.pluginName);
|
||||
if (optionsForPlugin == null) {
|
||||
optionsForPlugin = new ArrayList<PluginOption>();
|
||||
optionsByPluginName.put(option.pluginName, optionsForPlugin);
|
||||
}
|
||||
|
||||
optionsForPlugin.add(option);
|
||||
}
|
||||
|
||||
for (Map.Entry<String, List<PluginOption>> entry : optionsByPluginName.entrySet()) {
|
||||
assert !entry.getValue().isEmpty();
|
||||
|
||||
String pluginName = entry.getValue().get(0).pluginName;
|
||||
|
||||
StringBuilder renderedOptions = new StringBuilder("[");
|
||||
for (PluginOption option : entry.getValue()) {
|
||||
if (renderedOptions.length() > 1) {
|
||||
renderedOptions.append(", ");
|
||||
}
|
||||
renderedOptions.append(option.key).append(": ").append(option.value);
|
||||
}
|
||||
renderedOptions.append("]");
|
||||
|
||||
getLog().debug("Options for plugin " + pluginName + ": " + renderedOptions);
|
||||
}
|
||||
|
||||
return pluginOptions;
|
||||
}
|
||||
|
||||
@@ -363,7 +394,7 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
||||
throw new PluginNotFoundException(pluginName);
|
||||
}
|
||||
|
||||
pluginOptions.add(new PluginOption(plugin.getCompilerPluginId(), key, value));
|
||||
pluginOptions.add(new PluginOption(pluginName, plugin.getCompilerPluginId(), key, value));
|
||||
}
|
||||
|
||||
return pluginOptions;
|
||||
|
||||
+7
-1
@@ -1,11 +1,17 @@
|
||||
package org.jetbrains.kotlin.maven;
|
||||
|
||||
public class PluginOption {
|
||||
/** The plugin name in Maven, e.g. "all-open" */
|
||||
public final String pluginName;
|
||||
|
||||
/** The compiler plugin identifier, e.g. "org.jetbrains.kotlin.allopen" */
|
||||
public final String pluginId;
|
||||
|
||||
public final String key;
|
||||
public final String value;
|
||||
|
||||
public PluginOption(String pluginId, String key, String value) {
|
||||
public PluginOption(String pluginName, String pluginId, String key, String value) {
|
||||
this.pluginName = pluginName;
|
||||
this.pluginId = pluginId;
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
|
||||
Reference in New Issue
Block a user