Skip to content

Commit 8a8cb39

Browse files
committed
Merge remote-tracking branch 'origin/master' into daymon-improve-docs-dackka
2 parents 587b37b + d84113e commit 8a8cb39

File tree

77 files changed

+2173
-264
lines changed

Some content is hidden

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

77 files changed

+2173
-264
lines changed

.github/workflows/changelog.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Changelog
2+
3+
on:
4+
pull_request
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
danger:
12+
runs-on: ubuntu-22.04
13+
env:
14+
BUNDLE_GEMFILE: ./ci/danger/Gemfile
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 100
19+
submodules: true
20+
- uses: ruby/setup-ruby@v1
21+
with:
22+
ruby-version: '2.7'
23+
- name: Setup Bundler
24+
run: ./ci/danger/setup_bundler.sh
25+
- name: Danger CHANGELOG verifier
26+
env:
27+
DANGER_GITHUB_API_TOKEN: ${{ secrets.GOOGLE_OSS_BOT_TOKEN }}
28+
run:
29+
'[ ! -z $DANGER_GITHUB_API_TOKEN ] && bundle exec danger --dangerfile=./ci/danger/Dangerfile || echo "Skipping Danger for External Contributor"'
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
version=16.0.1
1+
version=16.0.2
2+
latestReleasedVersion=16.0.1
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
version=16.0.1
1+
version=16.0.2
2+
latestReleasedVersion=16.0.1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=16.0.1
2-
latestReleasedVersion=16.0.0
1+
version=16.0.2
2+
latestReleasedVersion=16.0.1
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
version=16.0.1
1+
version=16.0.2
2+
latestReleasedVersion=16.0.1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=16.0.1
1+
version=16.0.2
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
version=16.0.1
1+
version=16.0.2
2+
latestReleasedVersion=16.0.1

appcheck/firebase-appcheck/ktx/src/main/kotlin/com/google/firebase/appcheck/ktx/FirebaseAppCheck.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ operator fun AppCheckToken.component2() = expireTimeMillis
4646

4747
internal const val LIBRARY_NAME: String = "fire-app-check-ktx"
4848

49+
/** @suppress */
4950
class FirebaseAppCheckKtxRegistrar : ComponentRegistrar {
5051
override fun getComponents(): List<Component<*>> =
5152
listOf(LibraryVersionComponent.create(LIBRARY_NAME, BuildConfig.VERSION_NAME))

build.gradle

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ buildscript {
2525
}
2626
maven {
2727
url 'https://storage.googleapis.com/android-ci/mvn/'
28+
metadataSources {
29+
artifact()
30+
}
2831
}
2932

3033
}
@@ -47,7 +50,7 @@ ext {
4750
playServicesVersion = '16.0.1'
4851
supportAnnotationsVersion = '28.0.0'
4952
googleTruthVersion = '1.1.2'
50-
grpcVersion = '1.44.1'
53+
grpcVersion = '1.48.1'
5154
robolectricVersion = '4.3.1'
5255
protocVersion = '3.17.3'
5356
javaliteVersion = '3.17.3'
@@ -77,6 +80,9 @@ configure(subprojects) {
7780
mavenCentral()
7881
maven {
7982
url 'https://storage.googleapis.com/android-ci/mvn/'
83+
metadataSources {
84+
artifact()
85+
}
8086
}
8187
}
8288

buildSrc/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ gradlePlugin {
7272
id = "LicenseResolverPlugin"
7373
implementationClass = "com.google.firebase.gradle.plugins.license.LicenseResolverPlugin"
7474
}
75+
register("dackkaPlugin") {
76+
id = "DackkaPlugin"
77+
implementationClass = "com.google.firebase.gradle.plugins.DackkaPlugin"
78+
}
7579
register("multiProjectReleasePlugin") {
7680
id = "MultiProjectReleasePlugin"
7781
implementationClass = "com.google.firebase.gradle.MultiProjectReleasePlugin"
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
package com.google.firebase.gradle.plugins
2+
3+
import java.io.File
4+
import javax.inject.Inject
5+
import org.gradle.api.DefaultTask
6+
import org.gradle.api.provider.ListProperty
7+
import org.gradle.api.provider.Property
8+
import org.gradle.api.provider.SetProperty
9+
import org.gradle.api.tasks.CacheableTask
10+
import org.gradle.api.tasks.Classpath
11+
import org.gradle.api.tasks.InputFile
12+
import org.gradle.api.tasks.InputFiles
13+
import org.gradle.api.tasks.OutputDirectory
14+
import org.gradle.api.tasks.PathSensitive
15+
import org.gradle.api.tasks.PathSensitivity
16+
import org.gradle.api.tasks.TaskAction
17+
import org.gradle.process.ExecOperations
18+
import org.gradle.workers.WorkAction
19+
import org.gradle.workers.WorkParameters
20+
import org.gradle.workers.WorkerExecutor
21+
import org.json.JSONObject
22+
23+
/**
24+
* Extension class for [GenerateDocumentationTask].
25+
*
26+
* Provides public configurations for the task.
27+
*
28+
* @property dackkaJarFile a [File] of the Dackka fat jar
29+
* @property dependencies a list of all dependent jars (the classpath)
30+
* @property kotlinSources a list of kotlin source roots
31+
* @property javaSources a list of java source roots
32+
* @property suppressedFiles a list of files to exclude from documentation
33+
* @property outputDirectory where to store the generated files
34+
*/
35+
@CacheableTask
36+
abstract class GenerateDocumentationTaskExtension : DefaultTask() {
37+
@get:[InputFile Classpath]
38+
abstract val dackkaJarFile: Property<File>
39+
40+
@get:[InputFiles Classpath]
41+
abstract val dependencies: ListProperty<File>
42+
43+
@get:InputFiles
44+
@get:PathSensitive(PathSensitivity.RELATIVE)
45+
abstract val kotlinSources: ListProperty<File>
46+
47+
@get:InputFiles
48+
@get:PathSensitive(PathSensitivity.RELATIVE)
49+
abstract val javaSources: ListProperty<File>
50+
51+
@get:InputFiles
52+
@get:PathSensitive(PathSensitivity.RELATIVE)
53+
abstract val suppressedFiles: ListProperty<File>
54+
55+
@get:InputFiles
56+
@get:PathSensitive(PathSensitivity.RELATIVE)
57+
abstract val packageListFiles: ListProperty<File>
58+
59+
@get:OutputDirectory
60+
abstract val outputDirectory: Property<File>
61+
}
62+
63+
/**
64+
* Wrapper data class for External package-lists in Dokka
65+
*
66+
* This class allows us to map package-lists in a type-safe way, versus inline straight to
67+
* a map. This extra step could be removed- but it could also catch bugs in the future.
68+
*
69+
* @property packageList the prepared package-list file to map against
70+
* @property externalLink the url to map with when generating the docs
71+
*/
72+
data class ExternalDocumentationLink(
73+
val packageList: File,
74+
val externalLink: String
75+
)
76+
77+
/**
78+
* Task to run Dackka on a project.
79+
*
80+
* Since dackka needs to be run on the command line, we have to organize the arguments for dackka into
81+
* a json file. We then pass that json file to dackka as an argument.
82+
*
83+
* @see GenerateDocumentationTaskExtension
84+
*/
85+
abstract class GenerateDocumentationTask @Inject constructor(
86+
private val workerExecutor: WorkerExecutor
87+
) : GenerateDocumentationTaskExtension() {
88+
89+
@TaskAction
90+
fun build() {
91+
val configFile = saveToJsonFile(constructArguments())
92+
launchDackka(configFile, workerExecutor)
93+
}
94+
95+
private fun constructArguments(): JSONObject {
96+
val jsonMap = mapOf(
97+
"moduleName" to "",
98+
"outputDir" to outputDirectory.get().path,
99+
"globalLinks" to "",
100+
"sourceSets" to listOf(mutableMapOf(
101+
"sourceSetID" to mapOf(
102+
"scopeId" to "androidx",
103+
"sourceSetName" to "main"
104+
),
105+
"sourceRoots" to kotlinSources.get().map { it.path } + javaSources.get().map { it.path },
106+
"classpath" to dependencies.get().map { it.path },
107+
"documentedVisibilities" to listOf("PUBLIC", "PROTECTED"),
108+
"skipEmptyPackages" to "true",
109+
"suppressedFiles" to suppressedFiles.get().map { it.path },
110+
"externalDocumentationLinks" to createExternalLinks(packageListFiles).map { mapOf(
111+
"url" to it.externalLink,
112+
"packageListUrl" to it.packageList.toURI()
113+
) }
114+
)),
115+
"offlineMode" to "true",
116+
"noJdkLink" to "true"
117+
)
118+
119+
return JSONObject(jsonMap)
120+
}
121+
122+
private fun createExternalLinks(packageLists: ListProperty<File>): List<ExternalDocumentationLink> {
123+
val linksMap = mapOf(
124+
"android" to "https://developer.android.com/reference/kotlin/",
125+
"google" to "https://developer.android.com/reference/",
126+
"firebase" to "https://firebase.google.com/docs/reference/kotlin/",
127+
"coroutines" to "https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/"
128+
)
129+
130+
return packageLists.get().map {
131+
val externalLink = linksMap[it.parentFile.nameWithoutExtension] ?: throw RuntimeException("Unexpected package-list found: ${it.name}")
132+
ExternalDocumentationLink(it, externalLink)
133+
}
134+
}
135+
136+
private fun saveToJsonFile(jsonObject: JSONObject): File {
137+
val outputFile = File.createTempFile("dackkaArgs", ".json")
138+
139+
outputFile.deleteOnExit()
140+
outputFile.writeText(jsonObject.toString(2))
141+
142+
return outputFile
143+
}
144+
145+
private fun launchDackka(argsFile: File, workerExecutor: WorkerExecutor) {
146+
val workQueue = workerExecutor.noIsolation()
147+
148+
workQueue.submit(DackkaWorkAction::class.java) {
149+
args.set(listOf(argsFile.path, "-loggingLevel", "WARN"))
150+
classpath.set(setOf(dackkaJarFile.get()))
151+
projectName.set(project.name)
152+
}
153+
}
154+
}
155+
156+
/**
157+
* Parameters needs to launch the Dackka fat jar on the command line.
158+
*
159+
* @property args a list of arguments to pass to Dackka- should include the json arguments file
160+
* @property classpath the classpath to use during execution of the jar file
161+
* @property projectName name of the calling project, used for the devsite tenant (output directory)
162+
*/
163+
interface DackkaParams : WorkParameters {
164+
val args: ListProperty<String>
165+
val classpath: SetProperty<File>
166+
val projectName: Property<String>
167+
}
168+
169+
/**
170+
* Work action to launch dackka with a [DackkaParams].
171+
*
172+
* Work actions are organized sections of work, offered by gradle.
173+
*/
174+
abstract class DackkaWorkAction @Inject constructor(
175+
private val execOperations: ExecOperations
176+
) : WorkAction<DackkaParams> {
177+
override fun execute() {
178+
execOperations.javaexec {
179+
mainClass.set("org.jetbrains.dokka.MainKt")
180+
args = parameters.args.get()
181+
classpath(parameters.classpath.get())
182+
183+
environment("DEVSITE_TENANT", "client/${parameters.projectName.get()}")
184+
}
185+
}
186+
}

0 commit comments

Comments
 (0)