diff --git a/libraries/tools/kotlin-maven-plugin/pom.xml b/libraries/tools/kotlin-maven-plugin/pom.xml
index d02b3182d14..a1f38a64b2e 100644
--- a/libraries/tools/kotlin-maven-plugin/pom.xml
+++ b/libraries/tools/kotlin-maven-plugin/pom.xml
@@ -61,7 +61,7 @@
org.apache.maven.plugins
maven-plugin-plugin
- 2.9
+ 3.1
diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JVMCompileMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JVMCompileMojo.java
index 4818e5a7234..ee8c54b6360 100644
--- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JVMCompileMojo.java
+++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/K2JVMCompileMojo.java
@@ -22,6 +22,10 @@ import com.sampullara.cli.Args;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
+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.arguments.K2JVMCompilerArguments;
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler;
@@ -42,40 +46,29 @@ import static com.intellij.openapi.util.text.StringUtil.join;
/**
* Compiles kotlin sources
*
- * @goal compile
- * @phase compile
- * @requiresDependencyResolution compile
* @noinspection UnusedDeclaration
*/
+@Mojo(name = "compile", defaultPhase = LifecyclePhase.COMPILE, requiresDependencyResolution = ResolutionScope.COMPILE)
public class K2JVMCompileMojo extends KotlinCompileMojoBase {
/**
* The directories used to scan for annotation.xml files for Kotlin annotations
- *
- * @parameter
*/
+ @Parameter
public List annotationPaths;
- /**
- * @parameter default-value="true"
- */
+ @Parameter(defaultValue = "true")
public boolean scanForAnnotations;
/**
* Project classpath.
- *
- * @parameter default-value="${project.compileClasspathElements}"
- * @required
- * @readonly
*/
+ @Parameter(defaultValue = "${project.compileClasspathElements}", required = true, readonly = true)
public List classpath;
/**
* Project test classpath.
- *
- * @parameter default-value="${project.testClasspathElements}"
- * @required
- * @readonly
*/
+ @Parameter(defaultValue = "${project.testClasspathElements}", required = true, readonly = true)
protected List testClasspath;
@NotNull
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 7190c647fd2..be9afe38777 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
@@ -22,6 +22,7 @@ import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.cli.common.CLICompiler;
@@ -47,17 +48,14 @@ public abstract class KotlinCompileMojoBase e
/**
* The default source directories containing the sources to be compiled.
- *
- * @parameter default-value="${project.compileSourceRoots}"
- * @required
*/
+ @Parameter(defaultValue = "${project.compileSourceRoots}", required = true)
private List defaultSourceDirs;
/**
* The source directories containing the sources to be compiled.
- *
- * @parameter
*/
+ @Parameter
private List sourceDirs;
public List getSources() {
@@ -67,58 +65,41 @@ public abstract class KotlinCompileMojoBase e
/**
* Suppress all warnings.
- *
- * @parameter default-value="false"
*/
+ @Parameter(defaultValue = "false")
public boolean nowarn;
- // TODO not sure why this doesn't work :(
- // * @parameter default-value="$(project.basedir}/src/main/resources"
-
- /**
- * @parameter default-value="${project}"
- * @required
- * @readonly
- */
+ @Parameter(defaultValue = "${project}", required = true, readonly = true)
public MavenProject project;
/**
* The directory for compiled classes.
- *
- * @parameter default-value="${project.build.outputDirectory}"
- * @required
- * @readonly
*/
+ @Parameter(defaultValue = "${project.build.outputDirectory}", required = true, readonly = true)
public String output;
/**
* The directory for compiled tests classes.
- *
- * @parameter default-value="${project.build.testOutputDirectory}"
- * @required
- * @readonly
*/
+ @Parameter(defaultValue = "${project.build.testOutputDirectory}", required = true, readonly = true)
public String testOutput;
/**
* Kotlin compilation module, as alternative to source files or folders.
- *
- * @parameter
*/
+ @Parameter
public String module;
/**
* Kotlin compilation module, as alternative to source files or folders (for tests).
- *
- * @parameter
*/
+ @Parameter
public String testModule;
/**
* Additional command line arguments for Kotlin compiler.
- *
- * @parameter
*/
+ @Parameter
public List args;
protected final Log LOG = getLog();
diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestCompileMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestCompileMojo.java
index acecc74f46d..71c26b48d0d 100644
--- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestCompileMojo.java
+++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestCompileMojo.java
@@ -18,6 +18,10 @@ package org.jetbrains.kotlin.maven;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+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.arguments.K2JVMCompilerArguments;
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler;
@@ -27,18 +31,17 @@ import java.util.List;
/**
* Compiles Kotlin test sources
*
- * @goal test-compile
- * @phase test-compile
- * @requiresDependencyResolution test
* @noinspection UnusedDeclaration
*/
+@Mojo(name = "test-compile",
+ defaultPhase = LifecyclePhase.TEST_COMPILE,
+ requiresDependencyResolution = ResolutionScope.TEST
+)
public class KotlinTestCompileMojo extends K2JVMCompileMojo {
/**
* Flag to allow test compilation to be skipped.
- *
- * @parameter expression="${maven.test.skip}" default-value="false"
- * @noinspection UnusedDeclaration
*/
+ @Parameter(property = "maven.test.skip", defaultValue = "false")
private boolean skip;
// TODO it would be nice to avoid using 2 injected fields for sources
@@ -48,17 +51,14 @@ public class KotlinTestCompileMojo extends K2JVMCompileMojo {
/**
* The default source directories containing the sources to be compiled.
- *
- * @parameter default-value="${project.testCompileSourceRoots}"
- * @required
*/
+ @Parameter(defaultValue = "${project.testCompileSourceRoots}", required = true)
private List defaultSourceDirs;
/**
* The source directories containing the sources to be compiled.
- *
- * @parameter
*/
+ @Parameter
private List sourceDirs;
@Override
@@ -69,19 +69,15 @@ public class KotlinTestCompileMojo extends K2JVMCompileMojo {
/**
* The source directories containing the sources to be compiled for tests.
- *
- * @parameter default-value="${project.testCompileSourceRoots}"
- * @required
- * @readonly
*/
+ @Parameter(defaultValue = "${project.testCompileSourceRoots}", required = true, readonly = true)
private List defaultSourceDir;
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Test compilation is skipped");
- }
- else {
+ } else {
super.execute();
}
}
diff --git a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestJSCompilerMojo.java b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestJSCompilerMojo.java
index 91c9697a5e4..4a9313b4846 100644
--- a/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestJSCompilerMojo.java
+++ b/libraries/tools/kotlin-maven-plugin/src/main/java/org/jetbrains/kotlin/maven/KotlinTestJSCompilerMojo.java
@@ -97,8 +97,7 @@ public class KotlinTestJSCompilerMojo extends K2JSCompilerMojo {
public void execute() throws MojoExecutionException, MojoFailureException {
if (skip) {
getLog().info("Test compilation is skipped");
- }
- else {
+ } else {
super.execute();
}
}