Skip to content

Commit d50a3d1

Browse files
authored
Make dackka task depend on docStubs task. (#4072)
* Make dackka task depend on docStubs task. Otherwise no docs are produced for java sdks. * Fix toc.yaml path. * Fix tests and dgc url.
1 parent 005fc6b commit d50a3d1

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

buildSrc/src/main/java/com/google/firebase/gradle/plugins/DackkaGenerationTask.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.gradle.api.provider.Property
88
import org.gradle.api.provider.SetProperty
99
import org.gradle.api.tasks.CacheableTask
1010
import org.gradle.api.tasks.Classpath
11+
import org.gradle.api.tasks.Input
1112
import org.gradle.api.tasks.InputFile
1213
import org.gradle.api.tasks.InputFiles
1314
import org.gradle.api.tasks.OutputDirectory
@@ -19,7 +20,6 @@ import org.gradle.workers.WorkAction
1920
import org.gradle.workers.WorkParameters
2021
import org.gradle.workers.WorkerExecutor
2122
import org.json.JSONObject
22-
2323
/**
2424
* Extension class for [GenerateDocumentationTask].
2525
*
@@ -56,6 +56,9 @@ abstract class GenerateDocumentationTaskExtension : DefaultTask() {
5656
@get:PathSensitive(PathSensitivity.RELATIVE)
5757
abstract val packageListFiles: ListProperty<File>
5858

59+
@get:Input
60+
abstract val clientName: Property<String>
61+
5962
@get:OutputDirectory
6063
abstract val outputDirectory: Property<File>
6164
}
@@ -89,7 +92,7 @@ abstract class GenerateDocumentationTask @Inject constructor(
8992
@TaskAction
9093
fun build() {
9194
val configFile = saveToJsonFile(constructArguments())
92-
launchDackka(configFile, workerExecutor)
95+
launchDackka(clientName, configFile, workerExecutor)
9396
}
9497

9598
private fun constructArguments(): JSONObject {
@@ -122,7 +125,7 @@ abstract class GenerateDocumentationTask @Inject constructor(
122125
private fun createExternalLinks(packageLists: ListProperty<File>): List<ExternalDocumentationLink> {
123126
val linksMap = mapOf(
124127
"android" to "https://developer.android.com/reference/kotlin/",
125-
"google" to "https://developer.android.com/reference/",
128+
"google" to "https://developers.google.com/android/reference/",
126129
"firebase" to "https://firebase.google.com/docs/reference/kotlin/",
127130
"coroutines" to "https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/"
128131
)
@@ -142,13 +145,13 @@ abstract class GenerateDocumentationTask @Inject constructor(
142145
return outputFile
143146
}
144147

145-
private fun launchDackka(argsFile: File, workerExecutor: WorkerExecutor) {
148+
private fun launchDackka(clientName: Property<String>, argsFile: File, workerExecutor: WorkerExecutor) {
146149
val workQueue = workerExecutor.noIsolation()
147150

148151
workQueue.submit(DackkaWorkAction::class.java) {
149152
args.set(listOf(argsFile.path, "-loggingLevel", "WARN"))
150153
classpath.set(setOf(dackkaJarFile.get()))
151-
projectName.set(project.name)
154+
projectName.set(clientName)
152155
}
153156
}
154157
}

buildSrc/src/main/java/com/google/firebase/gradle/plugins/DackkaPlugin.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ abstract class DackkaPlugin : Plugin<Project> {
5454
}
5555
}
5656

57+
fun <T> Project.firebaseConfigValue(getter: FirebaseLibraryExtension.() -> T): T =
58+
project.extensions.getByType<FirebaseLibraryExtension>().getter()
59+
5760
private fun shouldWePublish(project: Project) =
58-
project.extensions.getByType<FirebaseLibraryExtension>().publishJavadoc
61+
project.firebaseConfigValue { publishJavadoc }
5962

6063
private fun prepareJavadocConfiguration(project: Project) {
6164
val javadocConfig = project.javadocConfig
@@ -76,22 +79,24 @@ abstract class DackkaPlugin : Plugin<Project> {
7679
if (name == "release") {
7780
val isKotlin = project.plugins.hasPlugin("kotlin-android")
7881

79-
val classpath = runtimeConfiguration.getJars() + project.javadocConfig.getJars() + bootClasspath
82+
val classpath = compileConfiguration.getJars() + project.javadocConfig.getJars() + project.files(bootClasspath)
8083

8184
val sourcesForJava = sourceSets.flatMap {
8285
it.javaDirectories.map { it.absoluteFile }
8386
}
8487

8588
docStubs.configure {
86-
classPath = project.files(classpath)
89+
classPath = classpath
8790
sources.set(project.provider { sourcesForJava })
8891
}
8992

9093
docsTask.configure {
94+
clientName.set(project.firebaseConfigValue { artifactId })
9195
// this will become useful with the agp upgrade, as they're separate in 7.x+
9296
val sourcesForKotlin = emptyList<File>()
9397
val packageLists = fetchPackageLists(project)
9498

99+
if (!isKotlin) dependsOn(docStubs)
95100
val excludedFiles = if (!isKotlin) projectSpecificSuppressedFiles(project) else emptyList()
96101
val fixedJavaSources = if (!isKotlin) listOf(project.docStubs) else sourcesForJava
97102

0 commit comments

Comments
 (0)