From 3d66ebd0e1694f40c3f634b99a05a02ea35bfbb9 Mon Sep 17 00:00:00 2001 From: James Strachan Date: Fri, 14 Sep 2012 15:04:09 +0100 Subject: [PATCH] added partial fix for KT-2765 so we can specify the paths to where annotations.xml files can be found --- .../kotlin/maven/KotlinCompileMojoBase.java | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) 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 3c081e6e68d..a246e2da991 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 @@ -36,6 +36,8 @@ import java.net.URL; import java.util.ArrayList; import java.util.List; +import static org.jetbrains.jet.internal.com.intellij.openapi.util.text.StringUtil.join; + public abstract class KotlinCompileMojoBase extends AbstractMojo { /** * The source directories containing the sources to be compiled. @@ -46,6 +48,16 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { */ public List sources; + // TODO not sure why this doesn't work :( + // * @parameter default-value="$(project.basedir}/src/main/resources" + + /** + * The directories used to scan for annotation.xml files for Kotlin annotations + * + * @parameter + */ + public List annotationPaths; + /** * The source directories containing the sources to be compiled for tests. * @@ -223,10 +235,27 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo { arguments.setOutputDir(output); arguments.noJdkAnnotations = true; - arguments.annotations = getJdkAnnotations().getPath(); - log.debug("Using jdk annotations from " + arguments.annotations); + String jdkAnnotation = getJdkAnnotations().getPath(); + arguments.annotations = jdkAnnotation; + + List list = new ArrayList(); + if (jdkAnnotation != null && jdkAnnotation.length() > 0) { + list.add(jdkAnnotation); + } + if (annotationPaths != null) { + for (String annotationPath : annotationPaths) { + if (new File(annotationPath).exists()) { + list.add(annotationPath); + } else { + log.info("annotation path " + annotationPath + " does not exist"); + } + } + } + arguments.annotations = join(list, File.pathSeparator); + log.info("Using kotlin annotations from " + arguments.annotations); } + // TODO: Make a better runtime detection or get rid of it entirely private String getRuntimeFromClassPath(List classpath) { for (String item : classpath) {