Skip to content

Commit 2319f36

Browse files
committed
Merge branch 'master' of https://github.com/firebase/firebase-android-sdk into rpf-storage-flows
2 parents 535c184 + 4f24be3 commit 2319f36

File tree

70 files changed

+936
-837
lines changed

Some content is hidden

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

70 files changed

+936
-837
lines changed

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import com.google.firebase.gradle.MultiProjectReleasePlugin
1717

1818
buildscript {
1919
ext.kotlinVersion = '1.7.10'
20+
ext.coroutinesVersion = '1.6.4'
21+
2022
repositories {
2123
google()
2224
mavenCentral()

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: 2 additions & 1 deletion
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)

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

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,11 @@ abstract class DackkaPlugin : Plugin<Project> {
120120
project.afterEvaluate {
121121
if (shouldWePublish(project)) {
122122
val generateDocumentation = registerGenerateDackkaDocumentationTask(project)
123-
val outputDirectory = generateDocumentation.flatMap { it.outputDirectory }
124-
val firesiteTransform = registerFiresiteTransformTask(project, outputDirectory)
125-
val copyJavaDocToCommonDirectory = registerCopyJavaDocToCommonDirectoryTask(project, outputDirectory)
126-
val copyKotlinDocToCommonDirectory = registerCopyKotlinDocToCommonDirectoryTask(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)
127128

128129
project.tasks.register("kotlindoc") {
129130
group = "documentation"
@@ -168,6 +169,7 @@ abstract class DackkaPlugin : Plugin<Project> {
168169
val classpath = compileConfiguration.getJars() + project.javadocConfig.getJars() + project.files(bootClasspath)
169170

170171
val sourcesForJava = sourceSets.flatMap {
172+
// TODO(b/246984444): Investigate why kotlinDirectories includes javaDirectories
171173
it.javaDirectories.map { it.absoluteFile }
172174
}
173175

@@ -177,13 +179,12 @@ abstract class DackkaPlugin : Plugin<Project> {
177179
}
178180

179181
docsTask.configure {
180-
clientName.set(project.firebaseConfigValue { artifactId })
181-
// this will become useful with the agp upgrade, as they're separate in 7.x+
182-
val sourcesForKotlin = emptyList<File>()
182+
if (!isKotlin) dependsOn(docStubs)
183+
184+
val sourcesForKotlin = emptyList<File>() + projectSpecificSources(project)
183185
val packageLists = fetchPackageLists(project)
184186

185-
if (!isKotlin) dependsOn(docStubs)
186-
val excludedFiles = if (!isKotlin) projectSpecificSuppressedFiles(project) else emptyList()
187+
val excludedFiles = projectSpecificSuppressedFiles(project)
187188
val fixedJavaSources = if (!isKotlin) listOf(project.docStubs) else sourcesForJava
188189

189190
javaSources.set(fixedJavaSources)
@@ -206,11 +207,20 @@ abstract class DackkaPlugin : Plugin<Project> {
206207
include("**/package-list")
207208
}.toList()
208209

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+
209219
// TODO(b/243534168): Remove when fixed
210220
private fun projectSpecificSuppressedFiles(project: Project): List<File> =
211221
when (project.name) {
212222
"firebase-common" -> {
213-
project.files("${project.docStubs}/com/google/firebase/firestore").toList()
223+
project.project(":firebase-firestore").files("src/main/java/com/google/firebase/firestore").toList()
214224
}
215225
"firebase-firestore" -> {
216226
project.files("${project.docStubs}/com/google/firebase/Timestamp.java").toList()
@@ -226,14 +236,15 @@ abstract class DackkaPlugin : Plugin<Project> {
226236

227237
dackkaJarFile.set(dackkaFile)
228238
outputDirectory.set(dackkaOutputDirectory)
239+
clientName.set(project.firebaseConfigValue { artifactId })
229240
}
230241

231-
// TODO(b/243833009): Make task cacheable
232-
private fun registerFiresiteTransformTask(project: Project, outputDirectory: Provider<File>) =
242+
private fun registerFiresiteTransformTask(project: Project, dackkaFilesDirectory: Provider<File>) =
233243
project.tasks.register<FiresiteTransformTask>("firesiteTransform") {
234244
mustRunAfter("generateDackkaDocumentation")
235245

236-
dackkaFiles.set(outputDirectory)
246+
dackkaFiles.set(dackkaFilesDirectory)
247+
outputDirectory.set(project.file("${project.buildDir}/dackkaTransformedFiles"))
237248
}
238249

239250
// TODO(b/246593212): Migrate doc files to single directory
@@ -277,5 +288,7 @@ abstract class DackkaPlugin : Plugin<Project> {
277288
group = "cleanup"
278289

279290
delete("${project.buildDir}/dackkaDocumentation")
291+
delete("${project.buildDir}/dackkaTransformedFiles")
292+
delete("${project.rootProject.buildDir}/firebase-kotlindoc")
280293
}
281294
}

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ package com.google.firebase.gradle.plugins
33
import java.io.File
44
import org.gradle.api.DefaultTask
55
import org.gradle.api.provider.Property
6+
import org.gradle.api.tasks.CacheableTask
67
import org.gradle.api.tasks.InputDirectory
8+
import org.gradle.api.tasks.OutputDirectory
9+
import org.gradle.api.tasks.PathSensitive
10+
import org.gradle.api.tasks.PathSensitivity
711
import org.gradle.api.tasks.TaskAction
812

913
/**
@@ -21,10 +25,15 @@ import org.gradle.api.tasks.TaskAction
2125
* **Please note:**
2226
* This task is idempotent- meaning it can safely be ran multiple times on the same set of files.
2327
*/
28+
@CacheableTask
2429
abstract class FiresiteTransformTask : DefaultTask() {
2530
@get:InputDirectory
31+
@get:PathSensitive(PathSensitivity.RELATIVE)
2632
abstract val dackkaFiles: Property<File>
2733

34+
@get:OutputDirectory
35+
abstract val outputDirectory: Property<File>
36+
2837
@TaskAction
2938
fun build() {
3039
val namesOfFilesWeDoNotNeed = listOf(
@@ -33,14 +42,18 @@ abstract class FiresiteTransformTask : DefaultTask() {
3342
"packages.html",
3443
"package-list"
3544
)
45+
val rootDirectory = dackkaFiles.get()
46+
val targetDirectory = outputDirectory.get()
47+
targetDirectory.deleteRecursively()
48+
49+
rootDirectory.walkTopDown().forEach {
50+
if (it.name !in namesOfFilesWeDoNotNeed) {
51+
val relativePath = it.toRelativeString(rootDirectory)
52+
val newFile = it.copyTo(File("${targetDirectory.path}/$relativePath"), true)
3653

37-
dackkaFiles.get().walkTopDown().forEach {
38-
if (it.name in namesOfFilesWeDoNotNeed) {
39-
it.delete()
40-
} else {
4154
when (it.extension) {
42-
"html" -> it.fixHTMLFile()
43-
"yaml" -> it.fixYamlFile()
55+
"html" -> newFile.fixHTMLFile()
56+
"yaml" -> newFile.fixYamlFile()
4457
}
4558
}
4659
}

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)