Skip to content

Commit e9dfd4b

Browse files
daymxnqdpham13
authored andcommitted
Add projectSpecificSources back to the DackkaPlugin (#4110)
* Added extra method for TaskProviders * Added specificSources method back * Revert to dependsOn for docstubs dep
1 parent 0be80e9 commit e9dfd4b

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ abstract class DackkaPlugin : Plugin<Project> {
168168
val classpath = compileConfiguration.getJars() + project.javadocConfig.getJars() + project.files(bootClasspath)
169169

170170
val sourcesForJava = sourceSets.flatMap {
171+
// TODO(b/246984444): Investigate why kotlinDirectories includes javaDirectories
171172
it.javaDirectories.map { it.absoluteFile }
172173
}
173174

@@ -177,13 +178,12 @@ abstract class DackkaPlugin : Plugin<Project> {
177178
}
178179

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

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

189189
javaSources.set(fixedJavaSources)
@@ -206,11 +206,20 @@ abstract class DackkaPlugin : Plugin<Project> {
206206
include("**/package-list")
207207
}.toList()
208208

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+
209218
// TODO(b/243534168): Remove when fixed
210219
private fun projectSpecificSuppressedFiles(project: Project): List<File> =
211220
when (project.name) {
212221
"firebase-common" -> {
213-
project.files("${project.docStubs}/com/google/firebase/firestore").toList()
222+
project.project(":firebase-firestore").files("src/main/java/com/google/firebase/firestore").toList()
214223
}
215224
"firebase-firestore" -> {
216225
project.files("${project.docStubs}/com/google/firebase/Timestamp.java").toList()
@@ -226,6 +235,7 @@ abstract class DackkaPlugin : Plugin<Project> {
226235

227236
dackkaJarFile.set(dackkaFile)
228237
outputDirectory.set(dackkaOutputDirectory)
238+
clientName.set(project.firebaseConfigValue { artifactId })
229239
}
230240

231241
// TODO(b/243833009): Make task cacheable

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

Lines changed: 9 additions & 0 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")
@@ -62,6 +63,14 @@ fun <T : Task, R : Task> T.dependsOnAndMustRunAfter(otherTask: R) {
6263
dependsOn(otherTask)
6364
}
6465

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+
6574
/**
6675
* Utility method to call [Task.mustRunAfter] and [Task.dependsOn] on the specified task name
6776
*/

0 commit comments

Comments
 (0)