Maven: metadata mojo initial implementation
This commit is contained in:
+4
@@ -72,6 +72,9 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
||||
@Parameter
|
||||
private List<String> pluginOptions;
|
||||
|
||||
@Parameter
|
||||
private boolean multiPlatform = false;
|
||||
|
||||
private List<String> getAppliedCompilerPlugins() {
|
||||
return (compilerPlugins == null) ? Collections.<String>emptyList() : compilerPlugins;
|
||||
}
|
||||
@@ -359,6 +362,7 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
||||
arguments.suppressWarnings = nowarn;
|
||||
arguments.languageVersion = languageVersion;
|
||||
arguments.apiVersion = apiVersion;
|
||||
arguments.multiPlatform = multiPlatform;
|
||||
|
||||
getLog().info("Compiling Kotlin sources from " + sources);
|
||||
|
||||
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package org.jetbrains.kotlin.maven;
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugins.annotations.LifecyclePhase;
|
||||
import org.apache.maven.plugins.annotations.Mojo;
|
||||
import org.apache.maven.plugins.annotations.Parameter;
|
||||
import org.apache.maven.plugins.annotations.ResolutionScope;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.cli.common.CLICompiler;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2MetadataCompilerArguments;
|
||||
import org.jetbrains.kotlin.cli.metadata.K2MetadataCompiler;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import static com.intellij.openapi.util.text.StringUtil.join;
|
||||
import static org.jetbrains.kotlin.maven.Util.filterClassPath;
|
||||
|
||||
@Mojo(name = "metadata", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE)
|
||||
public class MetadataMojo extends KotlinCompileMojoBase<K2MetadataCompilerArguments> {
|
||||
@Parameter(defaultValue = "${project.compileClasspathElements}", required = true, readonly = true)
|
||||
public List<String> classpath;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected CLICompiler<K2MetadataCompilerArguments> createCompiler() {
|
||||
return new K2MetadataCompiler();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected K2MetadataCompilerArguments createCompilerArguments() {
|
||||
return new K2MetadataCompilerArguments();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configureSpecificCompilerArguments(@NotNull K2MetadataCompilerArguments arguments) throws MojoExecutionException {
|
||||
arguments.destination = output;
|
||||
if (!arguments.multiPlatform) {
|
||||
getLog().info("multiPlatform forced for metadata generation");
|
||||
arguments.multiPlatform = true;
|
||||
}
|
||||
|
||||
List<String> classpathList = filterClassPath(project.getBasedir(), classpath);
|
||||
|
||||
if (!classpathList.isEmpty()) {
|
||||
String classPathString = join(classpathList, File.pathSeparator);
|
||||
getLog().debug("Classpath: " + classPathString);
|
||||
arguments.classpath = classPathString;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user