Skip to content

Combine Java/Kotlin sources in Dackka Plugin #4166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ import org.json.JSONObject
*
* @property dackkaJarFile a [File] of the Dackka fat jar
* @property dependencies a list of all dependent jars (the classpath)
* @property kotlinSources a list of kotlin source roots
* @property javaSources a list of java source roots
* @property sources a list of source roots
* @property suppressedFiles a list of files to exclude from documentation
* @property outputDirectory where to store the generated files
*/
Expand All @@ -43,11 +42,7 @@ abstract class GenerateDocumentationTaskExtension : DefaultTask() {

@get:InputFiles
@get:PathSensitive(PathSensitivity.RELATIVE)
abstract val kotlinSources: ListProperty<File>

@get:InputFiles
@get:PathSensitive(PathSensitivity.RELATIVE)
abstract val javaSources: ListProperty<File>
abstract val sources: ListProperty<File>

@get:InputFiles
@get:PathSensitive(PathSensitivity.RELATIVE)
Expand Down Expand Up @@ -106,7 +101,7 @@ abstract class GenerateDocumentationTask @Inject constructor(
"scopeId" to "androidx",
"sourceSetName" to "main"
),
"sourceRoots" to kotlinSources.get().map { it.path } + javaSources.get().map { it.path },
"sourceRoots" to sources.get().map { it.path },
"classpath" to dependencies.get().map { it.path },
"documentedVisibilities" to listOf("PUBLIC", "PROTECTED"),
"skipEmptyPackages" to "true",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,32 +183,28 @@ abstract class DackkaPlugin : Plugin<Project> {

val classpath = compileConfiguration.getJars() + project.javadocConfig.getJars() + project.files(bootClasspath)

val sourcesForJava = sourceSets.flatMap {
// TODO(b/246984444): Investigate why kotlinDirectories includes javaDirectories
val sourceDirectories = sourceSets.flatMap {
it.javaDirectories.map { it.absoluteFile }
}

docStubs.configure {
classPath = classpath
sources.set(project.provider { sourcesForJava })
sources.set(project.provider { sourceDirectories })
}

docsTask.configure {
if (!isKotlin) dependsOn(docStubs)

val sourcesForKotlin = emptyList<File>() + projectSpecificSources(project)
val packageLists = fetchPackageLists(project)

val excludedFiles = projectSpecificSuppressedFiles(project)
val fixedJavaSources = if (!isKotlin) listOf(project.docStubs) else sourcesForJava
val fixedSourceDirectories = if (!isKotlin) listOf(project.docStubs) else sourceDirectories

javaSources.set(fixedJavaSources)
sources.set(fixedSourceDirectories + projectSpecificSources(project))
suppressedFiles.set(excludedFiles)
packageListFiles.set(packageLists)

kotlinSources.set(sourcesForKotlin)
dependencies.set(classpath)

outputDirectory.set(targetDirectory)

applyCommonConfigurations()
Expand Down