Skip to content

Commit

Permalink
Fix generation with K2 by wiring source sets: kotlin-dsl dependsOn ja…
Browse files Browse the repository at this point in the history
…va-sources
  • Loading branch information
whyoleg committed Sep 16, 2024
1 parent a08e8ba commit 041c5bd
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import gradlebuild.basics.BuildEnvironmentKt;
import kotlin.Unit;
import org.gradle.api.NamedDomainObjectContainer;
import org.gradle.api.NamedDomainObjectProvider;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
Expand Down Expand Up @@ -107,24 +107,25 @@ private static void wireInArtificialSourceSet(Project project, GradleDocumentati
task.getGeneratedClasses().set(project.getLayout().getBuildDirectory().dir("gradle-kotlin-dsl-extensions/classes"));
});

NamedDomainObjectContainer<DokkaSourceSetSpec> kotlinSourceSet = getDokkaExtension(project).getDokkaSourceSets();
kotlinSourceSet.register("kotlin_dsl", spec -> {
spec.getDisplayName().set("DSL");
spec.getSourceRoots().from(extension.getKotlinDslSource());
spec.getSourceRoots().from(runtimeExtensions.flatMap(GradleKotlinDslRuntimeGeneratedSources::getGeneratedSources));
NamedDomainObjectProvider<DokkaSourceSetSpec> javaSourceSet = getDokkaExtension(project).getDokkaSourceSets().register("java_api", spec -> {
spec.getDisplayName().set("API");
spec.getSourceRoots().from(extension.getDocumentedSource());
spec.getClasspath().from(extension.getClasspath());
spec.getClasspath().from(runtimeExtensions.flatMap(GradleKotlinDslRuntimeGeneratedSources::getGeneratedClasses));
spec.getIncludes().from(extension.getSourceRoot().file("kotlin/Module.md"));
configureSourceLinks(project, extension, spec);
});

NamedDomainObjectContainer<DokkaSourceSetSpec> javaSourceSet = getDokkaExtension(project).getDokkaSourceSets();
javaSourceSet.register("java_api", spec -> {
spec.getDisplayName().set("API");
spec.getSourceRoots().from(extension.getDocumentedSource());
NamedDomainObjectProvider<DokkaSourceSetSpec> kotlinSourceSet = getDokkaExtension(project).getDokkaSourceSets().register("kotlin_dsl", spec -> {
spec.getDisplayName().set("DSL");
spec.getSourceRoots().from(extension.getKotlinDslSource());
spec.getSourceRoots().from(runtimeExtensions.flatMap(GradleKotlinDslRuntimeGeneratedSources::getGeneratedSources));
spec.getClasspath().from(extension.getClasspath());
spec.getClasspath().from(runtimeExtensions.flatMap(GradleKotlinDslRuntimeGeneratedSources::getGeneratedClasses));
spec.getIncludes().from(extension.getSourceRoot().file("kotlin/Module.md"));
configureSourceLinks(project, extension, spec);

// with Dokka K2 analysis, we need to wire source-sets to have resolve between them
spec.getDependentSourceSets().addLater(javaSourceSet.flatMap(DokkaSourceSetSpec::getSourceSetId));
});
}

Expand Down

0 comments on commit 041c5bd

Please sign in to comment.