Added the compile and provided classpaths to the sourceSet when DokkaOperation().fromProject() is called. Closes #3
This commit is contained in:
parent
deb66a2d20
commit
d2560125d7
4 changed files with 45 additions and 16 deletions
|
@ -50,8 +50,8 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
|
||||||
private final Collection<String> globalPackageOptions_ = new ArrayList<>();
|
private final Collection<String> globalPackageOptions_ = new ArrayList<>();
|
||||||
private final Collection<String> globalSrcLinks_ = new ArrayList<>();
|
private final Collection<String> globalSrcLinks_ = new ArrayList<>();
|
||||||
private final Collection<String> includes_ = new ArrayList<>();
|
private final Collection<String> includes_ = new ArrayList<>();
|
||||||
private final Map<String, String> pluginsConfiguration_ = new ConcurrentHashMap<>();
|
|
||||||
private final Collection<String> pluginsClasspath_ = new ArrayList<>();
|
private final Collection<String> pluginsClasspath_ = new ArrayList<>();
|
||||||
|
private final Map<String, String> pluginsConfiguration_ = new ConcurrentHashMap<>();
|
||||||
private boolean delayTemplateSubstitution_;
|
private boolean delayTemplateSubstitution_;
|
||||||
private boolean failOnWarning_;
|
private boolean failOnWarning_;
|
||||||
private LoggingLevel loggingLevel_;
|
private LoggingLevel loggingLevel_;
|
||||||
|
@ -226,15 +226,18 @@ public class DokkaOperation extends AbstractProcessOperation<DokkaOperation> {
|
||||||
/**
|
/**
|
||||||
* Configures the operation from a {@link BaseProject}.
|
* Configures the operation from a {@link BaseProject}.
|
||||||
* <p>
|
* <p>
|
||||||
* Sets the {@link #sourceSet sourceSet}, {@link SourceSet#jdkVersion jdkVersion} and {@link #moduleName moduleName}
|
* Sets the {@link #sourceSet sourceSet}, {@link SourceSet#jdkVersion jdkVersion}, {@link #moduleName moduleName}
|
||||||
* from the project.
|
* and {@link SourceSet#classpath(String...) classpath} from the project.
|
||||||
*
|
*
|
||||||
* @param project the project to configure the operation from
|
* @param project the project to configure the operation from
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public DokkaOperation fromProject(BaseProject project) {
|
public DokkaOperation fromProject(BaseProject project) {
|
||||||
project_ = 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) {
|
if (project.javaRelease() != null) {
|
||||||
sourceSet_ = sourceSet_.jdkVersion(project.javaRelease());
|
sourceSet_ = sourceSet_.jdkVersion(project.javaRelease());
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package rife.bld.extension.dokka;
|
package rife.bld.extension.dokka;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
@ -236,11 +237,11 @@ public class SourceSet {
|
||||||
* <p>
|
* <p>
|
||||||
* This option accepts both {@code .jar} and {@code .klib} files.
|
* 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
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public SourceSet classpath(String... classpath) {
|
public SourceSet classpath(String... files) {
|
||||||
classpath_.addAll(Arrays.asList(classpath));
|
classpath_.addAll(Arrays.asList(files));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,11 +252,26 @@ public class SourceSet {
|
||||||
* <p>
|
* <p>
|
||||||
* This option accepts both {@code .jar} and {@code .klib} files.
|
* 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
|
* @return this operation instance
|
||||||
*/
|
*/
|
||||||
public SourceSet classpath(Collection<String> classpath) {
|
public SourceSet classpath(Collection<String> files) {
|
||||||
classpath_.addAll(classpath);
|
classpath_.addAll(files);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets classpath for analysis and interactive samples.
|
||||||
|
* <p>
|
||||||
|
* This is useful if some types that come from dependencies are not resolved/picked up automatically.
|
||||||
|
* <p>
|
||||||
|
* This option accepts both {@code .jar} and {@code .klib} files.
|
||||||
|
*
|
||||||
|
* @param files the list of files
|
||||||
|
* @return this operation instance
|
||||||
|
*/
|
||||||
|
public SourceSet classpath(List<File> files) {
|
||||||
|
files.forEach(it -> classpath_.add(it.getAbsolutePath()));
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,11 @@ class DokkaOperationTest {
|
||||||
.outputDir(new File(examples, "build"))
|
.outputDir(new File(examples, "build"))
|
||||||
.outputFormat(OutputFormat.JAVADOC)
|
.outputFormat(OutputFormat.JAVADOC)
|
||||||
.suppressInheritedMembers(true)
|
.suppressInheritedMembers(true)
|
||||||
|
.sourceSet(new SourceSet().classpath(
|
||||||
|
List.of(
|
||||||
|
new File("examples/foo.jar"),
|
||||||
|
new File("examples/bar.jar")
|
||||||
|
)))
|
||||||
.executeConstructProcessCommandList();
|
.executeConstructProcessCommandList();
|
||||||
|
|
||||||
var path = examples.getAbsolutePath();
|
var path = examples.getAbsolutePath();
|
||||||
|
@ -66,7 +71,7 @@ class DokkaOperationTest {
|
||||||
path + "/lib/bld/javadoc-plugin-" + dokkaJar + ';' +
|
path + "/lib/bld/javadoc-plugin-" + dokkaJar + ';' +
|
||||||
path + "/lib/bld/korte-jvm-4.0.10.jar;" +
|
path + "/lib/bld/korte-jvm-4.0.10.jar;" +
|
||||||
path + "/lib/bld/kotlin-as-java-plugin-" + dokkaJar + ";path1;path2;path3;path4",
|
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",
|
"-outputDir", path + "/build",
|
||||||
"-delayTemplateSubstitution",
|
"-delayTemplateSubstitution",
|
||||||
"-failOnWarning",
|
"-failOnWarning",
|
||||||
|
@ -87,9 +92,9 @@ class DokkaOperationTest {
|
||||||
IntStream.range(0, args.size()).forEach(i -> {
|
IntStream.range(0, args.size()).forEach(i -> {
|
||||||
if (args.get(i).contains(".jar;")) {
|
if (args.get(i).contains(".jar;")) {
|
||||||
var jars = args.get(i).split(";");
|
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 {
|
} else {
|
||||||
assertThat(args.get(i)).isEqualTo(matches.get(i));
|
assertThat(args.get(i)).as(args.get(i)).isEqualTo(matches.get(i));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ class SourceSetTest {
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
@SuppressWarnings("PMD.AvoidDuplicateLiterals")
|
||||||
void sourceSetTest() {
|
void sourceSetTest() {
|
||||||
var args = new SourceSet()
|
var sourceSet = new SourceSet()
|
||||||
.classpath("classpath1", "classpath2")
|
.classpath("classpath1", "classpath2")
|
||||||
.dependentSourceSets("moduleName", "sourceSetName")
|
.dependentSourceSets("moduleName", "sourceSetName")
|
||||||
.documentedVisibilities(DocumentedVisibility.PACKAGE, DocumentedVisibility.PRIVATE)
|
.documentedVisibilities(DocumentedVisibility.PACKAGE, DocumentedVisibility.PRIVATE)
|
||||||
|
@ -76,8 +76,9 @@ class SourceSetTest {
|
||||||
.noStdlibLink(true)
|
.noStdlibLink(true)
|
||||||
.reportUndocumented(true)
|
.reportUndocumented(true)
|
||||||
.skipDeprecated(true)
|
.skipDeprecated(true)
|
||||||
.sourceSetName("setName")
|
.sourceSetName("setName");
|
||||||
.args();
|
|
||||||
|
var args = sourceSet.args();
|
||||||
|
|
||||||
var matches = List.of(
|
var matches = List.of(
|
||||||
"-analysisPlatform", "jvm",
|
"-analysisPlatform", "jvm",
|
||||||
|
@ -105,5 +106,9 @@ class SourceSetTest {
|
||||||
assertThat(args).hasSize(matches.size());
|
assertThat(args).hasSize(matches.size());
|
||||||
|
|
||||||
IntStream.range(0, args.size()).forEach(i -> assertThat(args.get(i)).isEqualTo(matches.get(i)));
|
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue