@@ -90,26 +90,23 @@ tasks above). While we do not currently offer any configuration for the Dackka
90
90
plugin, this could change in the future as needed. Currently, the DackkaPlugin
91
91
provides sensible defaults to output directories, package lists, and so forth.
92
92
93
- The DackkaPlugin also provides two extra tasks:
94
- [cleanDackkaDocumentation][registerCleanDackkaDocumentation] and
95
- [deleteDackkaGeneratedJavaReferences][registerDeleteDackkaGeneratedJavaReferencesTask].
93
+ The DackkaPlugin also provides three extra tasks:
94
+ [cleanDackkaDocumentation][registerCleanDackkaDocumentation],
95
+ [copyJavaDocToCommonDirectory][registerCopyJavaDocToCommonDirectoryTask] and
96
+ [copyKotlinDocToCommonDirectory][registerCopyKotlinDocToCommonDirectoryTask].
96
97
97
98
_cleanDackkaDocumentation_ is exactly what it sounds like, a task to clean up (delete)
98
99
the output of Dackka. This is useful when testing Dackka outputs itself- and
99
100
shouldn't be apart of the normal flow. The reasoning is that it would otherwise
100
101
invalidate the gradle cache.
101
102
102
- _deleteDackkaGeneratedJavaReferences_ is a temporary addition. Dackka generates
103
- two separate styles of docs for every source set: Java & Kotlin. Regardless of
104
- whether the source is in Java or Kotlin. The Java output is how the source looks
105
- from Java, and the Kotlin output is how the source looks from Kotlin. We publish
106
- these under two separate categories, which you can see here:
107
- [Java](https://firebase.google.com/docs/reference/android/packages)
108
- or
109
- [Kotlin](https://firebase.google.com/docs/reference/kotlin/packages).
110
- Although, we do not currently publish Java packages with Dackka- and will wait
111
- until we are more comfortable with the output of Dackka to do so. So until then,
112
- this task will remove all generate Java references from the Dackka output.
103
+ _copyJavaDocToCommonDirectory_ copies the JavaDoc variant of the Dackka output for each sdk,
104
+ and pastes it in a common directory under the root project's build directory. This makes it easier
105
+ to zip the doc files for staging.
106
+
107
+ _copyKotlinDocToCommonDirectory_ copies the KotlinDoc variant of the Dackka output for each sdk,
108
+ and pastes it in a common directory under the root project's build directory. This makes it easier
109
+ to zip the doc files for staging.
113
110
114
111
Currently, the DackkaPlugin builds Java sources separate from Kotlin Sources. There is an open bug
115
112
for Dackka in which hidden parent classes and annotations do not hide themselves from children classes.
@@ -123,18 +120,19 @@ abstract class DackkaPlugin : Plugin<Project> {
123
120
project.afterEvaluate {
124
121
if (shouldWePublish(project)) {
125
122
val generateDocumentation = registerGenerateDackkaDocumentationTask(project)
126
- val outputDirectory = generateDocumentation.flatMap { it.outputDirectory }
127
- val firesiteTransform = registerFiresiteTransformTask(project, outputDirectory)
128
- val deleteJavaReferences = registerDeleteDackkaGeneratedJavaReferencesTask(project, outputDirectory)
129
- val copyOutputToCommonDirectory = registerCopyDackkaOutputToCommonDirectoryTask(project, outputDirectory)
123
+ val dackkaFilesDirectory = generateDocumentation.flatMap { it.outputDirectory }
124
+ val firesiteTransform = registerFiresiteTransformTask(project, dackkaFilesDirectory)
125
+ val transformedFilesDirectory = firesiteTransform.flatMap { it.outputDirectory }
126
+ val copyJavaDocToCommonDirectory = registerCopyJavaDocToCommonDirectoryTask(project, transformedFilesDirectory)
127
+ val copyKotlinDocToCommonDirectory = registerCopyKotlinDocToCommonDirectoryTask(project, transformedFilesDirectory)
130
128
131
129
project.tasks.register(" kotlindoc" ) {
132
130
group = " documentation"
133
131
dependsOn(
134
132
generateDocumentation,
135
133
firesiteTransform,
136
- deleteJavaReferences ,
137
- copyOutputToCommonDirectory
134
+ copyJavaDocToCommonDirectory ,
135
+ copyKotlinDocToCommonDirectory
138
136
)
139
137
}
140
138
} else {
@@ -171,6 +169,7 @@ abstract class DackkaPlugin : Plugin<Project> {
171
169
val classpath = compileConfiguration.getJars() + project.javadocConfig.getJars() + project.files(bootClasspath)
172
170
173
171
val sourcesForJava = sourceSets.flatMap {
172
+ // TODO(b/246984444): Investigate why kotlinDirectories includes javaDirectories
174
173
it.javaDirectories.map { it.absoluteFile }
175
174
}
176
175
@@ -180,13 +179,12 @@ abstract class DackkaPlugin : Plugin<Project> {
180
179
}
181
180
182
181
docsTask.configure {
183
- clientName.set(project.firebaseConfigValue { artifactId } )
184
- // this will become useful with the agp upgrade, as they're separate in 7.x+
185
- val sourcesForKotlin = emptyList<File >()
182
+ if ( ! isKotlin) dependsOn(docStubs )
183
+
184
+ val sourcesForKotlin = emptyList<File >() + projectSpecificSources(project)
186
185
val packageLists = fetchPackageLists(project)
187
186
188
- if (! isKotlin) dependsOn(docStubs)
189
- val excludedFiles = if (! isKotlin) projectSpecificSuppressedFiles(project) else emptyList()
187
+ val excludedFiles = projectSpecificSuppressedFiles(project)
190
188
val fixedJavaSources = if (! isKotlin) listOf (project.docStubs) else sourcesForJava
191
189
192
190
javaSources.set(fixedJavaSources)
@@ -209,11 +207,20 @@ abstract class DackkaPlugin : Plugin<Project> {
209
207
include(" **/package-list" )
210
208
}.toList()
211
209
210
+ // TODO(b/243534168): Remove when fixed
211
+ private fun projectSpecificSources (project : Project ) =
212
+ when (project.name) {
213
+ " firebase-common" -> {
214
+ project.project(" :firebase-firestore" ).files(" src/main/java/com/google/firebase" ).toList()
215
+ }
216
+ else -> emptyList()
217
+ }
218
+
212
219
// TODO(b/243534168): Remove when fixed
213
220
private fun projectSpecificSuppressedFiles (project : Project ): List <File > =
214
221
when (project.name) {
215
222
" firebase-common" -> {
216
- project.files( " ${project.docStubs} /com/google/firebase/firestore" ).toList()
223
+ project.project( " :firebase-firestore " ).files( " src/main/java /com/google/firebase/firestore" ).toList()
217
224
}
218
225
" firebase-firestore" -> {
219
226
project.files(" ${project.docStubs} /com/google/firebase/Timestamp.java" ).toList()
@@ -229,43 +236,50 @@ abstract class DackkaPlugin : Plugin<Project> {
229
236
230
237
dackkaJarFile.set(dackkaFile)
231
238
outputDirectory.set(dackkaOutputDirectory)
239
+ clientName.set(project.firebaseConfigValue { artifactId })
232
240
}
233
241
234
- // TODO(b/243833009): Make task cacheable
235
- private fun registerFiresiteTransformTask (project : Project , outputDirectory : Provider <File >) =
242
+ private fun registerFiresiteTransformTask (project : Project , dackkaFilesDirectory : Provider <File >) =
236
243
project.tasks.register<FiresiteTransformTask >(" firesiteTransform" ) {
237
- dackkaFiles.set(outputDirectory)
238
- }
239
-
240
- // If we decide to publish java variants, we'll need to address the generated format as well
241
- // TODO(b/243833009): Make task cacheable
242
- private fun registerDeleteDackkaGeneratedJavaReferencesTask (project : Project , outputDirectory : Provider <File >) =
243
- project.tasks.register<Delete >(" deleteDackkaGeneratedJavaReferences" ) {
244
244
mustRunAfter(" generateDackkaDocumentation" )
245
245
246
- val filesWeDoNotNeed = listOf (
247
- " reference/client" ,
248
- " reference/com"
249
- )
250
- val filesToDelete = outputDirectory.map { dir ->
251
- filesWeDoNotNeed.map {
252
- project.files(" ${dir.path} /$it " )
253
- }
254
- }
246
+ dackkaFiles.set(dackkaFilesDirectory)
247
+ outputDirectory.set(project.file(" ${project.buildDir} /dackkaTransformedFiles" ))
248
+ }
255
249
256
- delete(filesToDelete)
250
+ // TODO(b/246593212): Migrate doc files to single directory
251
+ private fun registerCopyJavaDocToCommonDirectoryTask (project : Project , outputDirectory : Provider <File >) =
252
+ project.tasks.register<Copy >(" copyJavaDocToCommonDirectory" ) {
253
+ /* *
254
+ * This is not currently cache compliant. The need for this property is
255
+ * temporary while we test it alongside the current javaDoc task. Since it's such a
256
+ * temporary behavior, losing cache compliance is fine for now.
257
+ */
258
+ if (project.rootProject.findProperty(" dackkaJavadoc" ) == " true" ) {
259
+ mustRunAfter(" firesiteTransform" )
260
+
261
+ val outputFolder = project.file(" ${project.rootProject.buildDir} /firebase-kotlindoc/android" )
262
+ val clientFolder = outputDirectory.map { project.file(" ${it.path} /reference/client" ) }
263
+ val comFolder = outputDirectory.map { project.file(" ${it.path} /reference/com" ) }
264
+
265
+ fromDirectory(clientFolder)
266
+ fromDirectory(comFolder)
267
+
268
+ into(outputFolder)
269
+ }
257
270
}
258
271
259
- private fun registerCopyDackkaOutputToCommonDirectoryTask ( project : Project , outputDirectory : Provider < File >) =
260
- project.tasks.register< Copy >( " copyDackkaOutputToCommonDirectory " ) {
261
- mustRunAfter( " deleteDackkaGeneratedJavaReferences " )
272
+ // TODO(b/246593212): Migrate doc files to single directory
273
+ private fun registerCopyKotlinDocToCommonDirectoryTask ( project : Project , outputDirectory : Provider < File >) =
274
+ project.tasks.register< Copy >( " copyKotlinDocToCommonDirectory " ) {
262
275
mustRunAfter(" firesiteTransform" )
263
276
264
- val referenceFolder = outputDirectory.map { project.file(" ${it.path} /reference" ) }
265
277
val outputFolder = project.file(" ${project.rootProject.buildDir} /firebase-kotlindoc" )
278
+ val kotlinFolder = outputDirectory.map { project.file(" ${it.path} /reference/kotlin" ) }
279
+
280
+ fromDirectory(kotlinFolder)
266
281
267
- from(referenceFolder)
268
- destinationDir = outputFolder
282
+ into(outputFolder)
269
283
}
270
284
271
285
// Useful for local testing, but may not be desired for standard use (that's why it's not depended on)
@@ -274,5 +288,7 @@ abstract class DackkaPlugin : Plugin<Project> {
274
288
group = " cleanup"
275
289
276
290
delete(" ${project.buildDir} /dackkaDocumentation" )
291
+ delete(" ${project.buildDir} /dackkaTransformedFiles" )
292
+ delete(" ${project.rootProject.buildDir} /firebase-kotlindoc" )
277
293
}
278
294
}
0 commit comments