update for KT-2765 so we can specify annotationPaths for kdoc too

This commit is contained in:
James Strachan
2012-09-14 16:34:25 +01:00
parent 3d66ebd0e1
commit fdb755e2e7
2 changed files with 24 additions and 5 deletions
@@ -65,6 +65,15 @@ public class KDocMojo extends KotlinCompileMojoBase {
*/
public String output;
// 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<String> annotationPaths;
// TODO not sure why default is stopping us passing this value in via a config
// default-value="${project.compileSourceRoots}"
@@ -184,6 +193,12 @@ public class KDocMojo extends KotlinCompileMojoBase {
KDocArguments kdoc = (KDocArguments) arguments;
KDocConfig docConfig = kdoc.getDocConfig();
docConfig.setDocOutputDir(docOutputDir);
kdoc.noJdkAnnotations = true;
kdoc.annotations = getFullAnnotationsPath(getLog(), annotationPaths);
if (ignorePackages != null) {
docConfig.getIgnorePackages().addAll(ignorePackages);
}
@@ -208,6 +223,7 @@ public class KDocMojo extends KotlinCompileMojoBase {
getLog().info("sources: " + sources);
getLog().info("sourceRootHref: " + sourceRootHref);
getLog().info("projectRootDir: " + projectRootDir);
getLog().info("kotlin annotations: " + kdoc.annotations);
getLog().info("packageDescriptionFiles: " + packageDescriptionFiles);
getLog().info("packagePrefixToUrls: " + packagePrefixToUrls);
getLog().info("API docs ignore packages: " + ignorePackages);
@@ -235,15 +235,19 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
arguments.setOutputDir(output);
arguments.noJdkAnnotations = true;
arguments.annotations = getFullAnnotationsPath(log, annotationPaths);
log.info("Using kotlin annotations from " + arguments.annotations);
}
protected String getFullAnnotationsPath(Log log, List<String> annotations) {
String jdkAnnotation = getJdkAnnotations().getPath();
arguments.annotations = jdkAnnotation;
List<String> list = new ArrayList<String>();
if (jdkAnnotation != null && jdkAnnotation.length() > 0) {
list.add(jdkAnnotation);
}
if (annotationPaths != null) {
for (String annotationPath : annotationPaths) {
if (annotations != null) {
for (String annotationPath : annotations) {
if (new File(annotationPath).exists()) {
list.add(annotationPath);
} else {
@@ -251,8 +255,7 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
}
}
}
arguments.annotations = join(list, File.pathSeparator);
log.info("Using kotlin annotations from " + arguments.annotations);
return join(list, File.pathSeparator);
}