From 3a9ed81915d5e0d38fef68a692e1b462490c684c Mon Sep 17 00:00:00 2001 From: Philippe Marschall Date: Wed, 5 Dec 2012 15:17:46 +0100 Subject: [PATCH] Skip Plugin Exceution for POM Projects It's quite common to have a multi module project with a parent project that has POM packaging. It would be quite convenient if the kotlin-maven-plugin could be configured there instead of in each module. Currently this is not possible because the plugin tries to execute on POM projects with fails. - skip execution on POM projects --- libraries/tools/kotlin-maven-plugin/pom.xml | 5 +++++ .../kotlin/maven/KotlinCompileMojoBase.java | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/libraries/tools/kotlin-maven-plugin/pom.xml b/libraries/tools/kotlin-maven-plugin/pom.xml index 990e2ec5f08..663d47a1980 100644 --- a/libraries/tools/kotlin-maven-plugin/pom.xml +++ b/libraries/tools/kotlin-maven-plugin/pom.xml @@ -25,6 +25,11 @@ maven-plugin-api ${maven.version} + + org.apache.maven + maven-core + ${maven.version} + org.jetbrains.kotlin kotlin-compiler 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 7e43239e6ab..2623d11f565 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 @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.maven; import com.google.common.base.Joiner; import com.google.common.io.Files; import com.google.common.io.Resources; +import org.apache.maven.project.MavenProject; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -128,8 +129,21 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { */ public String testModule; + /** + * The maven project. + * + * @parameter default-value="${project}" + * @required + * @readonly + */ + public MavenProject project; + @Override public void execute() throws MojoExecutionException, MojoFailureException { + if (project.getPackaging().equals("pom")) { + getLog().info( "Skipping Kotlin execution for POM projects" ); + } + // Check sources List sources = getSources(); if (sources != null && sources.size() > 0) {