Skip to content

Commit 371ae42

Browse files
authored
Merge branch 'master' into rl.guava.dep
2 parents 1d634a5 + 5aa056e commit 371ae42

File tree

53 files changed

+439
-504
lines changed

Some content is hidden

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

53 files changed

+439
-504
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=16.1.3
1+
version=17.0.0
22
latestReleasedVersion=16.1.2
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=16.1.3
1+
version=17.0.0
22
latestReleasedVersion=16.1.2

appcheck/firebase-appcheck-interop/api.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package com.google.firebase.appcheck {
33

44
public abstract class AppCheckTokenResult {
55
ctor public AppCheckTokenResult();
6-
method @Nullable public abstract com.google.firebase.FirebaseException getError();
6+
method @Nullable public abstract Exception getError();
77
method @NonNull public abstract String getToken();
88
}
99

appcheck/firebase-appcheck-interop/firebase-appcheck-interop.gradle

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ android {
4242
}
4343

4444
dependencies {
45-
implementation 'com.google.firebase:firebase-common:20.3.1'
46-
implementation 'com.google.firebase:firebase-components:17.1.0'
4745
implementation 'com.google.android.gms:play-services-base:18.0.1'
4846
implementation 'com.google.android.gms:play-services-tasks:18.0.1'
4947

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=16.1.2
1+
version=17.0.0
22
latestReleasedVersion=16.1.1

appcheck/firebase-appcheck-interop/src/main/java/com/google/firebase/appcheck/AppCheckTokenResult.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,12 @@
1616

1717
import androidx.annotation.NonNull;
1818
import androidx.annotation.Nullable;
19-
import com.google.firebase.FirebaseException;
2019

2120
/**
2221
* Class to hold the result emitted by a Firebase App Check service application verification
2322
* attempt. The result will always contain a token, which will either be a valid raw JWT attesting
24-
* application identity, or a dummy value. The result may optionally contain a {@link
25-
* FirebaseException} if application verification does not succeed.
23+
* application identity, or a dummy value. The result may optionally contain an {@link Exception} if
24+
* application verification does not succeed.
2625
*/
2726
public abstract class AppCheckTokenResult {
2827

@@ -34,9 +33,9 @@ public abstract class AppCheckTokenResult {
3433
public abstract String getToken();
3534

3635
/**
37-
* Returns the {@link FirebaseException} if the {@link
38-
* com.google.firebase.appcheck.interop.InternalAppCheckTokenProvider} failed to obtain a token.
36+
* Returns the {@link Exception} if the {@link
37+
* com.google.firebase.appcheck.interop.InteropAppCheckTokenProvider} failed to obtain a token.
3938
*/
4039
@Nullable
41-
public abstract FirebaseException getError();
40+
public abstract Exception getError();
4241
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import com.google.firebase.appcheck.AppCheckTokenResult;
2020

2121
/** @hide */
22-
public interface InternalAppCheckTokenProvider {
22+
public interface InteropAppCheckTokenProvider {
2323

2424
/**
2525
* Requests an {@link AppCheckTokenResult} from the installed {@code AppCheckFactory}. This will
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=16.1.3
1+
version=17.0.0
22
latestReleasedVersion=16.1.2

appcheck/firebase-appcheck/api.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ package com.google.firebase.appcheck {
1515
method @NonNull public abstract String getToken();
1616
}
1717

18-
public abstract class FirebaseAppCheck implements com.google.firebase.appcheck.interop.InternalAppCheckTokenProvider {
18+
public abstract class FirebaseAppCheck implements com.google.firebase.appcheck.interop.InteropAppCheckTokenProvider {
1919
ctor public FirebaseAppCheck();
2020
method public abstract void addAppCheckListener(@NonNull com.google.firebase.appcheck.FirebaseAppCheck.AppCheckListener);
2121
method @NonNull public abstract com.google.android.gms.tasks.Task<com.google.firebase.appcheck.AppCheckToken> getAppCheckToken(boolean);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=16.1.3
1+
version=17.0.0
22
latestReleasedVersion=16.1.2

appcheck/firebase-appcheck/src/androidTest/java/com/google/firebase/appcheck/StrictModeTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import androidx.test.ext.junit.runners.AndroidJUnit4;
1919
import com.google.firebase.FirebaseApp;
2020
import com.google.firebase.FirebaseOptions;
21-
import com.google.firebase.appcheck.interop.InternalAppCheckTokenProvider;
21+
import com.google.firebase.appcheck.interop.InteropAppCheckTokenProvider;
2222
import com.google.firebase.testing.integ.StrictModeRule;
2323
import org.junit.Rule;
2424
import org.junit.Test;
@@ -43,7 +43,7 @@ public void initializingFirebaseAppcheck_shouldNotViolateStrictMode() {
4343
.build(),
4444
"hello");
4545
app.get(FirebaseAppCheck.class);
46-
app.get(InternalAppCheckTokenProvider.class);
46+
app.get(InteropAppCheckTokenProvider.class);
4747
});
4848
}
4949
}

appcheck/firebase-appcheck/src/main/java/com/google/firebase/appcheck/FirebaseAppCheck.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import com.google.android.gms.tasks.Task;
2020
import com.google.firebase.FirebaseApp;
2121
import com.google.firebase.appcheck.interop.AppCheckTokenListener;
22-
import com.google.firebase.appcheck.interop.InternalAppCheckTokenProvider;
22+
import com.google.firebase.appcheck.interop.InteropAppCheckTokenProvider;
2323

24-
public abstract class FirebaseAppCheck implements InternalAppCheckTokenProvider {
24+
public abstract class FirebaseAppCheck implements InteropAppCheckTokenProvider {
2525

2626
/** Gets the default instance of {@code FirebaseAppCheck}. */
2727
@NonNull

appcheck/firebase-appcheck/src/main/java/com/google/firebase/appcheck/FirebaseAppCheckRegistrar.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import com.google.firebase.annotations.concurrent.Lightweight;
2222
import com.google.firebase.annotations.concurrent.UiThread;
2323
import com.google.firebase.appcheck.internal.DefaultFirebaseAppCheck;
24-
import com.google.firebase.appcheck.interop.InternalAppCheckTokenProvider;
24+
import com.google.firebase.appcheck.interop.InteropAppCheckTokenProvider;
2525
import com.google.firebase.components.Component;
2626
import com.google.firebase.components.ComponentRegistrar;
2727
import com.google.firebase.components.Dependency;
@@ -53,7 +53,7 @@ public List<Component<?>> getComponents() {
5353
Qualified.qualified(Blocking.class, ScheduledExecutorService.class);
5454

5555
return Arrays.asList(
56-
Component.builder(FirebaseAppCheck.class, (InternalAppCheckTokenProvider.class))
56+
Component.builder(FirebaseAppCheck.class, (InteropAppCheckTokenProvider.class))
5757
.name(LIBRARY_NAME)
5858
.add(Dependency.required(FirebaseApp.class))
5959
.add(Dependency.required(uiExecutor))

appcheck/firebase-appcheck/src/main/java/com/google/firebase/appcheck/internal/DefaultAppCheckTokenResult.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public String getToken() {
5858

5959
@Nullable
6060
@Override
61-
public FirebaseException getError() {
61+
public Exception getError() {
6262
return error;
6363
}
6464
}

buildSrc/src/main/java/com/google/firebase/gradle/MultiProjectReleasePlugin.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@
4949
*/
5050
public class MultiProjectReleasePlugin implements Plugin<Project> {
5151

52+
// TODO() - Will be removed once migrated to Kotlin
53+
private static String findStringProperty(Project p, String property) {
54+
Object value = p.findProperty(property);
55+
return value != null ? value.toString() : null;
56+
}
57+
5258
@Override
5359
public void apply(Project project) {
5460
project.apply(ImmutableMap.of("plugin", PublishingPlugin.class));
@@ -73,10 +79,10 @@ public void apply(Project project) {
7379
ReleaseGenerator.class,
7480
task -> {
7581
task.getCurrentRelease()
76-
.convention(project.property("currentRelease").toString());
77-
task.getPastRelease().convention(project.property("pastRelease").toString());
82+
.convention(findStringProperty(project, "currentRelease"));
83+
task.getPastRelease().convention(findStringProperty(project, "pastRelease"));
7884
task.getPrintReleaseConfig()
79-
.convention(project.property("printOutput").toString());
85+
.convention(findStringProperty(project, "printOutput"));
8086
task.getReleaseConfigFile()
8187
.convention(project.getLayout().getBuildDirectory().file("release.cfg"));
8288
task.getReleaseReportFile()

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

Lines changed: 164 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,18 @@ import java.io.File
1818
import java.nio.file.Paths
1919
import org.gradle.api.Plugin
2020
import org.gradle.api.Project
21+
import org.gradle.api.artifacts.ProjectDependency
2122
import org.gradle.api.publish.PublishingExtension
23+
import org.gradle.api.publish.maven.MavenPom
2224
import org.gradle.api.publish.maven.MavenPublication
2325
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin
2426
import org.gradle.api.tasks.TaskProvider
2527
import org.gradle.kotlin.dsl.apply
2628
import org.gradle.kotlin.dsl.configure
2729
import org.gradle.kotlin.dsl.create
30+
import org.gradle.kotlin.dsl.findByType
2831
import org.gradle.kotlin.dsl.register
32+
import org.w3c.dom.Element
2933

3034
abstract class BaseFirebaseLibraryPlugin : Plugin<Project> {
3135

@@ -94,22 +98,173 @@ abstract class BaseFirebaseLibraryPlugin : Plugin<Project> {
9498
sources.value(project.provider { srcDirs })
9599
}
96100

101+
/**
102+
* Adds + configures the [MavenPublishPlugin] for the given [project].
103+
*
104+
* This provides the repository we publish to (a folder in the root build directory), and
105+
* configures maven pom generation.
106+
*
107+
* @see [applyPomTransformations]
108+
* @see [FirebaseLibraryExtension.applyPomCustomization]
109+
*/
97110
protected fun configurePublishing(project: Project, firebaseLibrary: FirebaseLibraryExtension) {
98-
project.afterEvaluate {
99-
project.apply<MavenPublishPlugin>()
100-
project.extensions.configure<PublishingExtension> {
111+
with(project) {
112+
apply<MavenPublishPlugin>()
113+
extensions.configure<PublishingExtension> {
101114
repositories.maven {
102-
val s = project.rootProject.buildDir.toString() + "/m2repository"
103-
url = File(s).toURI()
115+
url = rootProject.fileFromBuildDir("m2repository").toURI()
104116
name = "BuildDir"
105117
}
106118
publications.create<MavenPublication>("mavenAar") {
107-
from(project.components.findByName(firebaseLibrary.type.componentName))
108-
artifactId = firebaseLibrary.artifactId.get()
109-
groupId = firebaseLibrary.groupId.get()
110-
firebaseLibrary.applyPomCustomization(pom)
119+
afterEvaluate {
120+
artifactId =
121+
firebaseLibrary.artifactId.get() // these dont get populated until afterEvaluate :(
122+
groupId = firebaseLibrary.groupId.get()
123+
124+
firebaseLibrary.applyPomCustomization(pom)
125+
firebaseLibrary.applyPomTransformations(pom)
126+
from(components.findByName(firebaseLibrary.type.componentName))
127+
}
111128
}
112129
}
113130
}
114131
}
132+
133+
/**
134+
* Performs various transformations needed to ensure the given [pom] is ready for a release.
135+
*
136+
* The transformations are done lazily via the [withXml][MavenPom.withXml] provider.
137+
*
138+
* @param pom the [MavenPom] to prepare
139+
* @see [convertToCompileDependency]
140+
* @see [addTypeWithAARSupport]
141+
*/
142+
// TODO(b/270576405): Combine with applyPomCustomization when migrating FirebaseLibraryExtension
143+
private fun FirebaseLibraryExtension.applyPomTransformations(pom: MavenPom) {
144+
pom.withXml {
145+
val dependencies = asElement().findElementsByTag("dependency")
146+
val androidDependencies = resolveAndroidDependencies()
147+
for (dependency in dependencies) {
148+
convertToCompileDependency(dependency)
149+
addTypeWithAARSupport(dependency, androidDependencies)
150+
}
151+
}
152+
}
153+
154+
/**
155+
* Adds + configures the `scope` element as a direct descendant of the provided [Element].
156+
*
157+
* Sets the [textContent][Element.getTextContent] of `scope` to "compile"- regardless of its
158+
* initial value. This is needed to avoid a breaking change until the bug below is fixed.
159+
*
160+
* @param dependency the element to append the `scope` to
161+
* @see applyPomTransformations
162+
*/
163+
// TODO(b/277605778): Remove after configurations have been migrated to the right type
164+
private fun convertToCompileDependency(dependency: Element) {
165+
dependency.findOrCreate("scope").textContent = "compile"
166+
}
167+
168+
/**
169+
* Adds + configures the `type` element as a direct descendant of the provided [Element].
170+
*
171+
* The `type` element specifies what the given [dependency] is published as. This could be another
172+
* `pom`, a `jar`, an `aar`, etc., Usually, the [MavenPublishPlugin] can infer these types; this
173+
* is not the case however with `aar` artifacts.
174+
*
175+
* This method will check if the provided [dependency] is in the provided list of artifact strings
176+
* ([androidLibraries]), and map it to an `aar` or `jar` as needed.
177+
*
178+
* The following is an example of a `type` element:
179+
* ```
180+
* <dependency>
181+
* <type>aar</type>
182+
* </dependency>
183+
* ```
184+
*
185+
* @param dependency the element to append the `type` to
186+
* @param androidLibraries a list of dependencies for this given SDK that publish `aar` artifacts
187+
* @see applyPomTransformations
188+
*/
189+
// TODO(b/277607560): Remove when Gradle's MavenPublishPlugin adds functionality for aar types
190+
private fun addTypeWithAARSupport(dependency: Element, androidLibraries: List<String>) {
191+
dependency.findOrCreate("type").apply {
192+
textContent = if (androidLibraries.contains(dependency.toArtifactString())) "aar" else "jar"
193+
}
194+
}
115195
}
196+
197+
/**
198+
* A list of _all_ dependencies that publish `aar` artifacts.
199+
*
200+
* This is collected via the [runtimeClasspath][FirebaseLibraryExtension.getRuntimeClasspath], and
201+
* includes project level dependencies as well as external dependencies.
202+
*
203+
* The dependencies are mapped to their [artifactName].
204+
*
205+
* @see resolveProjectLevelDependencies
206+
* @see resolveExternalAndroidLibraries
207+
*/
208+
// TODO(b/277607560): Remove when Gradle's MavenPublishPlugin adds functionality for aar types
209+
fun FirebaseLibraryExtension.resolveAndroidDependencies() =
210+
resolveExternalAndroidLibraries() +
211+
resolveProjectLevelDependencies()
212+
.filter { it.type == LibraryType.ANDROID }
213+
.map { it.artifactName }
214+
215+
/**
216+
* A list of project level dependencies.
217+
*
218+
* This is collected via the [runtimeClasspath][FirebaseLibraryExtension.getRuntimeClasspath].
219+
*
220+
* @throws RuntimeException if a project level dependency is found that doesn't have
221+
* [FirebaseLibraryExtension]
222+
*/
223+
// TODO(b/277607560): Remove when Gradle's MavenPublishPlugin adds functionality for aar types
224+
fun FirebaseLibraryExtension.resolveProjectLevelDependencies() =
225+
project.configurations
226+
.getByName(runtimeClasspath)
227+
.allDependencies
228+
.mapNotNull { it as? ProjectDependency }
229+
.map {
230+
it.dependencyProject.extensions.findByType<FirebaseLibraryExtension>()
231+
?: throw RuntimeException(
232+
"Project level dependencies must have the firebaseLibrary plugin. The following dependency does not: ${it.artifactName}"
233+
)
234+
}
235+
236+
/**
237+
* A list of _external_ dependencies that publish `aar` artifacts.
238+
*
239+
* This is collected via the [runtimeClasspath][FirebaseLibraryExtension.getRuntimeClasspath], using
240+
* an [ArtifactView][org.gradle.api.artifacts.ArtifactView] that filters for `aar` artifactType.
241+
*
242+
* Artifacts are mapped to their respective display name:
243+
* ```
244+
* groupId:artifactId:version
245+
* ```
246+
*/
247+
// TODO(b/277607560): Remove when Gradle's MavenPublishPlugin adds functionality for aar types
248+
fun FirebaseLibraryExtension.resolveExternalAndroidLibraries() =
249+
project.configurations
250+
.getByName(runtimeClasspath)
251+
.incoming
252+
.artifactView { attributes { attribute("artifactType", "aar") } }
253+
.artifacts
254+
.map { it.variant.displayName.substringBefore(" ") }
255+
256+
/**
257+
* The name provided to this artifact when published.
258+
*
259+
* Syntax sugar for:
260+
* ```
261+
* "$mavenName:$version"
262+
* ```
263+
*
264+
* For example, the following could be an artifact name:
265+
* ```
266+
* "com.google.firebase:firebase-common:16.0.5"
267+
* ```
268+
*/
269+
val FirebaseLibraryExtension.artifactName: String
270+
get() = "$mavenName:$version"

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ package com.google.firebase.gradle.plugins
1616

1717
import org.gradle.api.DefaultTask
1818
import org.gradle.api.GradleException
19-
import org.gradle.api.artifacts.ProjectDependency
2019
import org.gradle.api.provider.ListProperty
2120
import org.gradle.api.tasks.Input
2221
import org.gradle.api.tasks.TaskAction
@@ -54,12 +53,8 @@ abstract class CheckHeadDependencies : DefaultTask() {
5453
}
5554
}
5655

57-
fun FirebaseLibraryExtension.projectDependenciesByName(): List<String> =
58-
project.configurations
59-
.getByName(runtimeClasspath)
60-
.allDependencies
61-
.filter { it is ProjectDependency }
62-
.map { it.name }
56+
private fun FirebaseLibraryExtension.projectDependenciesByName() =
57+
resolveProjectLevelDependencies().map { it.artifactId.get() }
6358

6459
companion object {
6560
val DEPENDENCIES_TO_IGNORE: List<String> = listOf("protolite-well-known-types")

0 commit comments

Comments
 (0)