Skip to content

Commit 5bba4bc

Browse files
committed
Merge branch 'master' into realtime-rc-merge
2 parents 65ed037 + 523730a commit 5bba4bc

File tree

69 files changed

+1010
-685
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1010
-685
lines changed

buildSrc/src/main/java/com/google/firebase/gradle/bomgenerator/BomGeneratorTask.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class BomGeneratorTask extends DefaultTask {
5454
"com.google.firebase:firebase-analytics-ktx",
5555
"com.google.firebase:firebase-appcheck-debug",
5656
"com.google.firebase:firebase-appcheck-debug-testing",
57+
"com.google.firebase:firebase-appcheck-ktx",
5758
"com.google.firebase:firebase-appcheck-playintegrity",
5859
"com.google.firebase:firebase-appcheck-safetynet",
5960
"com.google.firebase:firebase-appcheck",

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.google.firebase.gradle.plugins
33
import java.io.File
44
import javax.inject.Inject
55
import org.gradle.api.DefaultTask
6+
import org.gradle.api.file.FileCollection
67
import org.gradle.api.provider.ListProperty
78
import org.gradle.api.provider.Property
89
import org.gradle.api.provider.SetProperty
@@ -38,7 +39,7 @@ abstract class GenerateDocumentationTaskExtension : DefaultTask() {
3839
abstract val dackkaJarFile: Property<File>
3940

4041
@get:[InputFiles Classpath]
41-
abstract val dependencies: ListProperty<File>
42+
abstract val dependencies: Property<FileCollection>
4243

4344
@get:InputFiles
4445
@get:PathSensitive(PathSensitivity.RELATIVE)
@@ -127,7 +128,8 @@ abstract class GenerateDocumentationTask @Inject constructor(
127128
"android" to "https://developer.android.com/reference/kotlin/",
128129
"google" to "https://developers.google.com/android/reference/",
129130
"firebase" to "https://firebase.google.com/docs/reference/kotlin/",
130-
"coroutines" to "https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/"
131+
"coroutines" to "https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/",
132+
"kotlin" to "https://kotlinlang.org/api/latest/jvm/stdlib/"
131133
)
132134

133135
return packageLists.get().map {

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

Lines changed: 59 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -90,26 +90,23 @@ tasks above). While we do not currently offer any configuration for the Dackka
9090
plugin, this could change in the future as needed. Currently, the DackkaPlugin
9191
provides sensible defaults to output directories, package lists, and so forth.
9292
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].
9697
9798
_cleanDackkaDocumentation_ is exactly what it sounds like, a task to clean up (delete)
9899
the output of Dackka. This is useful when testing Dackka outputs itself- and
99100
shouldn't be apart of the normal flow. The reasoning is that it would otherwise
100101
invalidate the gradle cache.
101102
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.
113110
114111
Currently, the DackkaPlugin builds Java sources separate from Kotlin Sources. There is an open bug
115112
for Dackka in which hidden parent classes and annotations do not hide themselves from children classes.
@@ -125,16 +122,16 @@ abstract class DackkaPlugin : Plugin<Project> {
125122
val generateDocumentation = registerGenerateDackkaDocumentationTask(project)
126123
val outputDirectory = generateDocumentation.flatMap { it.outputDirectory }
127124
val firesiteTransform = registerFiresiteTransformTask(project, outputDirectory)
128-
val deleteJavaReferences = registerDeleteDackkaGeneratedJavaReferencesTask(project, outputDirectory)
129-
val copyOutputToCommonDirectory = registerCopyDackkaOutputToCommonDirectoryTask(project, outputDirectory)
125+
val copyJavaDocToCommonDirectory = registerCopyJavaDocToCommonDirectoryTask(project, outputDirectory)
126+
val copyKotlinDocToCommonDirectory = registerCopyKotlinDocToCommonDirectoryTask(project, outputDirectory)
130127

131128
project.tasks.register("kotlindoc") {
132129
group = "documentation"
133130
dependsOn(
134131
generateDocumentation,
135132
firesiteTransform,
136-
deleteJavaReferences,
137-
copyOutputToCommonDirectory
133+
copyJavaDocToCommonDirectory,
134+
copyKotlinDocToCommonDirectory
138135
)
139136
}
140137
} else {
@@ -171,6 +168,7 @@ abstract class DackkaPlugin : Plugin<Project> {
171168
val classpath = compileConfiguration.getJars() + project.javadocConfig.getJars() + project.files(bootClasspath)
172169

173170
val sourcesForJava = sourceSets.flatMap {
171+
// TODO(b/246984444): Investigate why kotlinDirectories includes javaDirectories
174172
it.javaDirectories.map { it.absoluteFile }
175173
}
176174

@@ -180,13 +178,12 @@ abstract class DackkaPlugin : Plugin<Project> {
180178
}
181179

182180
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>()
181+
if (!isKotlin) dependsOn(docStubs)
182+
183+
val sourcesForKotlin = emptyList<File>() + projectSpecificSources(project)
186184
val packageLists = fetchPackageLists(project)
187185

188-
if (!isKotlin) dependsOn(docStubs)
189-
val excludedFiles = if (!isKotlin) projectSpecificSuppressedFiles(project) else emptyList()
186+
val excludedFiles = projectSpecificSuppressedFiles(project)
190187
val fixedJavaSources = if (!isKotlin) listOf(project.docStubs) else sourcesForJava
191188

192189
javaSources.set(fixedJavaSources)
@@ -209,11 +206,20 @@ abstract class DackkaPlugin : Plugin<Project> {
209206
include("**/package-list")
210207
}.toList()
211208

209+
// TODO(b/243534168): Remove when fixed
210+
private fun projectSpecificSources(project: Project) =
211+
when (project.name) {
212+
"firebase-common" -> {
213+
project.project(":firebase-firestore").files("src/main/java/com/google/firebase").toList()
214+
}
215+
else -> emptyList()
216+
}
217+
212218
// TODO(b/243534168): Remove when fixed
213219
private fun projectSpecificSuppressedFiles(project: Project): List<File> =
214220
when (project.name) {
215221
"firebase-common" -> {
216-
project.files("${project.docStubs}/com/google/firebase/firestore").toList()
222+
project.project(":firebase-firestore").files("src/main/java/com/google/firebase/firestore").toList()
217223
}
218224
"firebase-firestore" -> {
219225
project.files("${project.docStubs}/com/google/firebase/Timestamp.java").toList()
@@ -229,43 +235,50 @@ abstract class DackkaPlugin : Plugin<Project> {
229235

230236
dackkaJarFile.set(dackkaFile)
231237
outputDirectory.set(dackkaOutputDirectory)
238+
clientName.set(project.firebaseConfigValue { artifactId })
232239
}
233240

234241
// TODO(b/243833009): Make task cacheable
235242
private fun registerFiresiteTransformTask(project: Project, outputDirectory: Provider<File>) =
236243
project.tasks.register<FiresiteTransformTask>("firesiteTransform") {
244+
mustRunAfter("generateDackkaDocumentation")
245+
237246
dackkaFiles.set(outputDirectory)
238247
}
239248

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-
mustRunAfter("generateDackkaDocumentation")
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-
}
249+
// TODO(b/246593212): Migrate doc files to single directory
250+
private fun registerCopyJavaDocToCommonDirectoryTask(project: Project, outputDirectory: Provider<File>) =
251+
project.tasks.register<Copy>("copyJavaDocToCommonDirectory") {
252+
/**
253+
* This is not currently cache compliant. The need for this property is
254+
* temporary while we test it alongside the current javaDoc task. Since it's such a
255+
* temporary behavior, losing cache compliance is fine for now.
256+
*/
257+
if (project.rootProject.findProperty("dackkaJavadoc") == "true") {
258+
mustRunAfter("firesiteTransform")
259+
260+
val outputFolder = project.file("${project.rootProject.buildDir}/firebase-kotlindoc/android")
261+
val clientFolder = outputDirectory.map { project.file("${it.path}/reference/client") }
262+
val comFolder = outputDirectory.map { project.file("${it.path}/reference/com") }
263+
264+
fromDirectory(clientFolder)
265+
fromDirectory(comFolder)
266+
267+
into(outputFolder)
254268
}
255-
256-
delete(filesToDelete)
257269
}
258270

259-
private fun registerCopyDackkaOutputToCommonDirectoryTask(project: Project, outputDirectory: Provider<File>) =
260-
project.tasks.register<Copy>("copyDackkaOutputToCommonDirectory") {
261-
mustRunAfter("deleteDackkaGeneratedJavaReferences")
271+
// TODO(b/246593212): Migrate doc files to single directory
272+
private fun registerCopyKotlinDocToCommonDirectoryTask(project: Project, outputDirectory: Provider<File>) =
273+
project.tasks.register<Copy>("copyKotlinDocToCommonDirectory") {
262274
mustRunAfter("firesiteTransform")
263275

264-
val referenceFolder = outputDirectory.map { project.file("${it.path}/reference") }
265276
val outputFolder = project.file("${project.rootProject.buildDir}/firebase-kotlindoc")
277+
val kotlinFolder = outputDirectory.map { project.file("${it.path}/reference/kotlin") }
278+
279+
fromDirectory(kotlinFolder)
266280

267-
from(referenceFolder)
268-
destinationDir = outputFolder
281+
into(outputFolder)
269282
}
270283

271284
// Useful for local testing, but may not be desired for standard use (that's why it's not depended on)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.google.firebase.gradle.plugins
2+
3+
import java.io.File
4+
import org.gradle.api.provider.Provider
5+
import org.gradle.api.tasks.Copy
6+
7+
fun Copy.fromDirectory(directory: Provider<File>) =
8+
from(directory) {
9+
into(directory.map { it.name })
10+
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import org.gradle.api.artifacts.Configuration
2323
import org.gradle.api.file.FileCollection
2424
import org.gradle.api.provider.Property
2525
import org.gradle.api.provider.SetProperty
26+
import org.gradle.api.tasks.Classpath
2627
import org.gradle.api.tasks.Input
2728
import org.gradle.api.tasks.InputFile
2829
import org.gradle.api.tasks.InputFiles
@@ -68,7 +69,7 @@ abstract class GenerateStubsTask : DefaultTask() {
6869
@get:InputFiles
6970
abstract val sources: SetProperty<File>
7071

71-
@get:InputFiles
72+
@get:[InputFiles Classpath]
7273
lateinit var classPath: FileCollection
7374

7475
@get:OutputDirectory

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import org.gradle.api.Project
1717
import org.gradle.api.Task
1818
import org.gradle.api.artifacts.Configuration
1919
import org.gradle.api.attributes.Attribute
20+
import org.gradle.api.provider.Provider
2021

2122
fun Project.isAndroid(): Boolean =
2223
listOf("com.android.application", "com.android.library", "com.android.test")
@@ -50,8 +51,7 @@ val Project.dackkaConfig: Configuration
5051
*/
5152
fun Configuration.getJars() = incoming.artifactView {
5253
attributes {
53-
// TODO(b/241795594): replace value with android-class instead of jar after agp upgrade
54-
attribute(Attribute.of("artifactType", String::class.java), "jar")
54+
attribute(Attribute.of("artifactType", String::class.java), "android-classes")
5555
}
5656
}.artifacts.artifactFiles
5757

@@ -63,6 +63,14 @@ fun <T : Task, R : Task> T.dependsOnAndMustRunAfter(otherTask: R) {
6363
dependsOn(otherTask)
6464
}
6565

66+
/**
67+
* Utility method to call [Task.mustRunAfter] and [Task.dependsOn] on the specified task
68+
*/
69+
fun <T : Task, R : Task> T.dependsOnAndMustRunAfter(otherTask: Provider<R>) {
70+
mustRunAfter(otherTask)
71+
dependsOn(otherTask)
72+
}
73+
6674
/**
6775
* Utility method to call [Task.mustRunAfter] and [Task.dependsOn] on the specified task name
6876
*/

0 commit comments

Comments
 (0)