diff --git a/src/main/java/rife/bld/extension/dokka/DokkaOperation.java b/src/main/java/rife/bld/extension/dokka/DokkaOperation.java index 5d68a3f..c73ed84 100644 --- a/src/main/java/rife/bld/extension/dokka/DokkaOperation.java +++ b/src/main/java/rife/bld/extension/dokka/DokkaOperation.java @@ -50,8 +50,8 @@ public class DokkaOperation extends AbstractProcessOperation { private final Collection globalPackageOptions_ = new ArrayList<>(); private final Collection globalSrcLinks_ = new ArrayList<>(); private final Collection includes_ = new ArrayList<>(); - private final Map pluginsConfiguration_ = new ConcurrentHashMap<>(); private final Collection pluginsClasspath_ = new ArrayList<>(); + private final Map pluginsConfiguration_ = new ConcurrentHashMap<>(); private boolean delayTemplateSubstitution_; private boolean failOnWarning_; private LoggingLevel loggingLevel_; @@ -226,15 +226,18 @@ public class DokkaOperation extends AbstractProcessOperation { /** * Configures the operation from a {@link BaseProject}. *

- * Sets the {@link #sourceSet sourceSet}, {@link SourceSet#jdkVersion jdkVersion} and {@link #moduleName moduleName} - * from the project. + * Sets the {@link #sourceSet sourceSet}, {@link SourceSet#jdkVersion jdkVersion}, {@link #moduleName moduleName} + * and {@link SourceSet#classpath(String...) classpath} from the project. * * @param project the project to configure the operation from */ @Override public DokkaOperation fromProject(BaseProject project) { project_ = project; - sourceSet_ = new SourceSet().src(new File(project.srcMainDirectory(), "kotlin").getAbsolutePath()); + sourceSet_ = new SourceSet() + .src(new File(project.srcMainDirectory(), "kotlin").getAbsolutePath()) + .classpath(project.compileClasspathJars()) + .classpath(project.providedClasspathJars()); if (project.javaRelease() != null) { sourceSet_ = sourceSet_.jdkVersion(project.javaRelease()); } diff --git a/src/main/java/rife/bld/extension/dokka/SourceSet.java b/src/main/java/rife/bld/extension/dokka/SourceSet.java index 2c83ef6..28aedd8 100644 --- a/src/main/java/rife/bld/extension/dokka/SourceSet.java +++ b/src/main/java/rife/bld/extension/dokka/SourceSet.java @@ -16,6 +16,7 @@ package rife.bld.extension.dokka; +import java.io.File; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -236,11 +237,11 @@ public class SourceSet { *

* This option accepts both {@code .jar} and {@code .klib} files. * - * @param classpath one or more classpath + * @param files one or more file * @return this operation instance */ - public SourceSet classpath(String... classpath) { - classpath_.addAll(Arrays.asList(classpath)); + public SourceSet classpath(String... files) { + classpath_.addAll(Arrays.asList(files)); return this; } @@ -251,11 +252,26 @@ public class SourceSet { *

* This option accepts both {@code .jar} and {@code .klib} files. * - * @param classpath the list of classpath + * @param files the list of files * @return this operation instance */ - public SourceSet classpath(Collection classpath) { - classpath_.addAll(classpath); + public SourceSet classpath(Collection files) { + classpath_.addAll(files); + return this; + } + + /** + * Sets classpath for analysis and interactive samples. + *

+ * This is useful if some types that come from dependencies are not resolved/picked up automatically. + *

+ * This option accepts both {@code .jar} and {@code .klib} files. + * + * @param files the list of files + * @return this operation instance + */ + public SourceSet classpath(List files) { + files.forEach(it -> classpath_.add(it.getAbsolutePath())); return this; } diff --git a/src/test/java/rife/bld/extension/dokka/DokkaOperationTest.java b/src/test/java/rife/bld/extension/dokka/DokkaOperationTest.java index 110c909..b4f30a9 100644 --- a/src/test/java/rife/bld/extension/dokka/DokkaOperationTest.java +++ b/src/test/java/rife/bld/extension/dokka/DokkaOperationTest.java @@ -55,6 +55,11 @@ class DokkaOperationTest { .outputDir(new File(examples, "build")) .outputFormat(OutputFormat.JAVADOC) .suppressInheritedMembers(true) + .sourceSet(new SourceSet().classpath( + List.of( + new File("examples/foo.jar"), + new File("examples/bar.jar") + ))) .executeConstructProcessCommandList(); var path = examples.getAbsolutePath(); @@ -66,7 +71,7 @@ class DokkaOperationTest { path + "/lib/bld/javadoc-plugin-" + dokkaJar + ';' + path + "/lib/bld/korte-jvm-4.0.10.jar;" + path + "/lib/bld/kotlin-as-java-plugin-" + dokkaJar + ";path1;path2;path3;path4", - "-sourceSet", "-src " + path + "/src/main/kotlin", + "-sourceSet", "-src " + path + "/src/main/kotlin" + " -classpath " + path + "/foo.jar;" + path + "/bar.jar", "-outputDir", path + "/build", "-delayTemplateSubstitution", "-failOnWarning", @@ -87,9 +92,9 @@ class DokkaOperationTest { IntStream.range(0, args.size()).forEach(i -> { if (args.get(i).contains(".jar;")) { var jars = args.get(i).split(";"); - Arrays.stream(jars).forEach(jar -> assertThat(matches.get(i)).contains(jar)); + Arrays.stream(jars).forEach(jar -> assertThat(matches.get(i)).as(matches.get(i)).contains(jar)); } else { - assertThat(args.get(i)).isEqualTo(matches.get(i)); + assertThat(args.get(i)).as(args.get(i)).isEqualTo(matches.get(i)); } }); } diff --git a/src/test/java/rife/bld/extension/dokka/SourceSetTest.java b/src/test/java/rife/bld/extension/dokka/SourceSetTest.java index 4edefe0..f48c26e 100644 --- a/src/test/java/rife/bld/extension/dokka/SourceSetTest.java +++ b/src/test/java/rife/bld/extension/dokka/SourceSetTest.java @@ -53,7 +53,7 @@ class SourceSetTest { @Test @SuppressWarnings("PMD.AvoidDuplicateLiterals") void sourceSetTest() { - var args = new SourceSet() + var sourceSet = new SourceSet() .classpath("classpath1", "classpath2") .dependentSourceSets("moduleName", "sourceSetName") .documentedVisibilities(DocumentedVisibility.PACKAGE, DocumentedVisibility.PRIVATE) @@ -76,8 +76,9 @@ class SourceSetTest { .noStdlibLink(true) .reportUndocumented(true) .skipDeprecated(true) - .sourceSetName("setName") - .args(); + .sourceSetName("setName"); + + var args = sourceSet.args(); var matches = List.of( "-analysisPlatform", "jvm", @@ -105,5 +106,9 @@ class SourceSetTest { assertThat(args).hasSize(matches.size()); IntStream.range(0, args.size()).forEach(i -> assertThat(args.get(i)).isEqualTo(matches.get(i))); + + sourceSet.classpath(List.of("classpath1", "classpath2")); + + IntStream.range(0, args.size()).forEach(i -> assertThat(args.get(i)).isEqualTo(matches.get(i))); } }