Skip to content

Commit 7345f9b

Browse files
committed
Add Kotlindoc-only publishing and enable for Dataconnect
1 parent 546cbcb commit 7345f9b

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

firebase-dataconnect/firebase-dataconnect.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ firebaseLibrary {
2828
libraryGroup = "dataconnect"
2929
testLab.enabled = false
3030
publishJavadoc = true
31+
onlyPublishKotlindoc = true
3132
releaseNotes {
3233
name.set("{{data_connect_short}}")
3334
versionName.set("data-connect")

plugins/src/main/java/com/google/firebase/gradle/plugins/BaseFirebaseLibraryPlugin.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ abstract class BaseFirebaseLibraryPlugin : Plugin<Project> {
5656
project.gradle.sharedServices.registerIfAbsent<GMavenService, _>("gmaven")
5757
previewMode.convention("")
5858
publishJavadoc.convention(true)
59+
onlyPublishKotlindoc.convention(false)
5960
artifactId.convention(project.name)
6061
groupId.convention(project.provider { project.group.toString() })
6162
libraryGroup.convention(artifactId)

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ data class ExternalDocumentationLink(val packageList: File, val externalLink: St
9898
abstract class GenerateDocumentationTask
9999
@Inject
100100
constructor(private val workerExecutor: WorkerExecutor) : GenerateDocumentationTaskExtension() {
101+
@get:Input abstract val kotlindocOnly: Property<Boolean>
101102

102103
@TaskAction
103104
fun build() {
@@ -120,7 +121,11 @@ constructor(private val workerExecutor: WorkerExecutor) : GenerateDocumentationT
120121
"java.lang.Override",
121122
)
122123
val annotationsNotToDisplayKotlin = listOf("kotlin.ExtensionFunctionType")
123-
124+
var javadoc: String? = "android"
125+
if (kotlindocOnly.get()) {
126+
// A null path disables javadoc generation
127+
javadoc = null
128+
}
124129
val jsonMap =
125130
mapOf(
126131
"moduleName" to "",
@@ -152,7 +157,7 @@ constructor(private val workerExecutor: WorkerExecutor) : GenerateDocumentationT
152157
JSONObject(
153158
mapOf(
154159
"docRootPath" to "/docs/reference/",
155-
"javaDocsPath" to "android",
160+
"javaDocsPath" to javadoc,
156161
"kotlinDocsPath" to "kotlin",
157162
"projectPath" to "client/${clientName.get()}",
158163
"includedHeadTagsPathJava" to

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ abstract class DackkaPlugin : Plugin<Project> {
123123
// TODO(b/270576405): remove afterEvalutate after fixed
124124
project.afterEvaluate {
125125
if (weShouldPublish(this)) {
126-
val generateDocumentation = registerGenerateDackkaDocumentationTask(project)
126+
val kdocOnly = publishKotlindocOnly(this)
127+
val generateDocumentation = registerGenerateDackkaDocumentationTask(project, kdocOnly)
127128

128129
val outputDir = generateDocumentation.flatMap { it.outputDirectory }
129130

@@ -153,6 +154,14 @@ abstract class DackkaPlugin : Plugin<Project> {
153154
*/
154155
private fun weShouldPublish(project: Project) = project.firebaseLibrary.publishJavadoc.get()
155156

157+
/**
158+
* Checks if the [Project] should only release Kotlindocs
159+
*
160+
* This is done via the [FirebaseLibraryExtension.onlyPublishKotlindoc] property.
161+
*/
162+
private fun publishKotlindocOnly(project: Project) =
163+
project.firebaseLibrary.onlyPublishKotlindoc.get()
164+
156165
/**
157166
* Applies common configuration to the [javadocConfig], that is otherwise not present.
158167
*
@@ -168,9 +177,10 @@ abstract class DackkaPlugin : Plugin<Project> {
168177
}
169178

170179
private fun registerGenerateDackkaDocumentationTask(
171-
project: Project
180+
project: Project, kotlindocOnly: Boolean
172181
): TaskProvider<GenerateDocumentationTask> =
173182
project.tasks.register<GenerateDocumentationTask>("generateDackkaDocumentation") {
183+
this.kotlindocOnly.set(kotlindocOnly)
174184
with(project.extensions.getByType<LibraryExtension>()) {
175185
libraryVariants.all {
176186
if (name == "release") {

plugins/src/main/java/com/google/firebase/gradle/plugins/FirebaseLibraryExtension.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@ constructor(val project: Project, val type: LibraryType) {
6969
*/
7070
abstract val publishJavadoc: Property<Boolean>
7171

72+
/**
73+
* Only publish Kotlindocs instead of also publishing Javadocs for this library.
74+
*
75+
* Defaults to `false`.
76+
*
77+
* ```sh
78+
* ./gradlew :firebase-common:kotlindoc
79+
* ```
80+
*
81+
* @see [FirebaseLibraryExtension]
82+
* @see publishJavadoc
83+
*/
84+
abstract val onlyPublishKotlindoc: Property<Boolean>
85+
7286
/**
7387
* Indicates the library is in a preview mode (such as `alpha` or `beta`).
7488
*

0 commit comments

Comments
 (0)