update for KT-2765 so we can specify annotationPaths for kdoc too
This commit is contained in:
+16
@@ -65,6 +65,15 @@ public class KDocMojo extends KotlinCompileMojoBase {
|
|||||||
*/
|
*/
|
||||||
public String output;
|
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
|
// TODO not sure why default is stopping us passing this value in via a config
|
||||||
// default-value="${project.compileSourceRoots}"
|
// default-value="${project.compileSourceRoots}"
|
||||||
@@ -184,6 +193,12 @@ public class KDocMojo extends KotlinCompileMojoBase {
|
|||||||
KDocArguments kdoc = (KDocArguments) arguments;
|
KDocArguments kdoc = (KDocArguments) arguments;
|
||||||
KDocConfig docConfig = kdoc.getDocConfig();
|
KDocConfig docConfig = kdoc.getDocConfig();
|
||||||
docConfig.setDocOutputDir(docOutputDir);
|
docConfig.setDocOutputDir(docOutputDir);
|
||||||
|
|
||||||
|
kdoc.noJdkAnnotations = true;
|
||||||
|
kdoc.annotations = getFullAnnotationsPath(getLog(), annotationPaths);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (ignorePackages != null) {
|
if (ignorePackages != null) {
|
||||||
docConfig.getIgnorePackages().addAll(ignorePackages);
|
docConfig.getIgnorePackages().addAll(ignorePackages);
|
||||||
}
|
}
|
||||||
@@ -208,6 +223,7 @@ public class KDocMojo extends KotlinCompileMojoBase {
|
|||||||
getLog().info("sources: " + sources);
|
getLog().info("sources: " + sources);
|
||||||
getLog().info("sourceRootHref: " + sourceRootHref);
|
getLog().info("sourceRootHref: " + sourceRootHref);
|
||||||
getLog().info("projectRootDir: " + projectRootDir);
|
getLog().info("projectRootDir: " + projectRootDir);
|
||||||
|
getLog().info("kotlin annotations: " + kdoc.annotations);
|
||||||
getLog().info("packageDescriptionFiles: " + packageDescriptionFiles);
|
getLog().info("packageDescriptionFiles: " + packageDescriptionFiles);
|
||||||
getLog().info("packagePrefixToUrls: " + packagePrefixToUrls);
|
getLog().info("packagePrefixToUrls: " + packagePrefixToUrls);
|
||||||
getLog().info("API docs ignore packages: " + ignorePackages);
|
getLog().info("API docs ignore packages: " + ignorePackages);
|
||||||
|
|||||||
+8
-5
@@ -235,15 +235,19 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
|
|||||||
arguments.setOutputDir(output);
|
arguments.setOutputDir(output);
|
||||||
|
|
||||||
arguments.noJdkAnnotations = true;
|
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();
|
String jdkAnnotation = getJdkAnnotations().getPath();
|
||||||
arguments.annotations = jdkAnnotation;
|
|
||||||
|
|
||||||
List<String> list = new ArrayList<String>();
|
List<String> list = new ArrayList<String>();
|
||||||
if (jdkAnnotation != null && jdkAnnotation.length() > 0) {
|
if (jdkAnnotation != null && jdkAnnotation.length() > 0) {
|
||||||
list.add(jdkAnnotation);
|
list.add(jdkAnnotation);
|
||||||
}
|
}
|
||||||
if (annotationPaths != null) {
|
if (annotations != null) {
|
||||||
for (String annotationPath : annotationPaths) {
|
for (String annotationPath : annotations) {
|
||||||
if (new File(annotationPath).exists()) {
|
if (new File(annotationPath).exists()) {
|
||||||
list.add(annotationPath);
|
list.add(annotationPath);
|
||||||
} else {
|
} else {
|
||||||
@@ -251,8 +255,7 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
arguments.annotations = join(list, File.pathSeparator);
|
return join(list, File.pathSeparator);
|
||||||
log.info("Using kotlin annotations from " + arguments.annotations);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user