Skip to content

Commit 7f141d1

Browse files
authored
Merge branch 'master' into ehsann/in-expansion-2
2 parents 56344f9 + 6071e9d commit 7f141d1

File tree

54 files changed

+633
-342
lines changed

Some content is hidden

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

54 files changed

+633
-342
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=16.1.1
2-
latestReleasedVersion=16.1.0
1+
version=16.1.2
2+
latestReleasedVersion=16.1.1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=16.1.1
2-
latestReleasedVersion=16.1.0
1+
version=16.1.2
2+
latestReleasedVersion=16.1.1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=16.1.1
2-
latestReleasedVersion=16.1.0
1+
version=16.1.2
2+
latestReleasedVersion=16.1.1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=16.1.1
2-
latestReleasedVersion=16.1.0
1+
version=16.1.2
2+
latestReleasedVersion=16.1.1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=16.1.1
2-
latestReleasedVersion=16.1.0
1+
version=16.1.2
2+
latestReleasedVersion=16.1.1
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=16.1.1
2-
latestReleasedVersion=16.1.0
1+
version=16.1.2
2+
latestReleasedVersion=16.1.1
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
package="com.google.firebase.appcheck.ktx">
3+
<!--Although the *SdkVersion is captured in gradle build files, this is required for non gradle builds-->
4+
<!--<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23" />-->
5+
<uses-permission android:name="android.permission.INTERNET"/>
6+
<application>
7+
<uses-library android:name="android.test.runner" />
8+
</application>
9+
10+
<instrumentation
11+
android:name="androidx.test.runner.AndroidJUnitRunner"
12+
android:targetPackage="com.google.firebase.appcheck.ktx" />
13+
</manifest>

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ buildscript {
3939
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.14'
4040
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:1.3.0'
4141
classpath 'gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.9'
42-
classpath 'com.google.gms:google-services:4.3.3'
42+
classpath 'com.google.gms:google-services:4.3.15'
4343
classpath "com.ncorti.ktfmt.gradle:plugin:0.11.0"
4444
}
4545
}
@@ -54,6 +54,7 @@ ext {
5454
robolectricVersion = libs.versions.robolectric.get()
5555
protocVersion = libs.versions.protoc.get()
5656
javaliteVersion = libs.versions.javalite.get()
57+
protobufJavaUtilVersion = libs.versions.protobufjavautil.get()
5758
}
5859

5960
apply plugin: com.google.firebase.gradle.plugins.publish.PublishingPlugin

buildSrc/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ dependencies {
6262
implementation("org.eclipse.jgit:org.eclipse.jgit:6.3.0.202209071007-r")
6363

6464
implementation("com.google.code.gson:gson:2.8.9")
65-
implementation("com.android.tools.build:gradle:7.4.0")
66-
implementation("com.android.tools.build:builder-test-api:7.4.0")
65+
implementation("com.android.tools.build:gradle:7.2.2")
66+
implementation("com.android.tools.build:builder-test-api:7.2.2")
6767
implementation("gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.9")
6868

6969
testImplementation("junit:junit:4.13.2")

buildSrc/src/main/java/com/google/firebase/gradle/bomgenerator/tagging/ShellExecutor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.util.function.Consumer;
2424
import org.gradle.api.GradleException;
2525

26+
// TODO(b/267668143): With modernization efforts
2627
public class ShellExecutor {
2728
private final Runtime runtime;
2829
private final File cwd;

buildSrc/src/main/java/com/google/firebase/gradle/plugins/FirebaseLibraryPlugin.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,20 @@ public void apply(Project project) {
9090
test.systemProperty("javax.net.ssl.trustStoreType", "JKS");
9191
})));
9292

93+
// skip debug tests in CI
94+
// TODO(vkryachko): provide ability for teams to control this if needed
95+
if (System.getenv().containsKey("FIREBASE_CI")) {
96+
android.setTestBuildType("release");
97+
project
98+
.getTasks()
99+
.all(
100+
task -> {
101+
if ("testDebugUnitTest".equals(task.getName())) {
102+
task.setEnabled(false);
103+
}
104+
});
105+
}
106+
93107
setupApiInformationAnalysis(project, android);
94108
android.testServer(new FirebaseTestServer(project, firebaseLibrary.testLab, android));
95109

@@ -109,6 +123,8 @@ public void apply(Project project) {
109123
ImmutableList.of("-module-name", kotlinModuleName(project))));
110124

111125
project.getPluginManager().apply(DackkaPlugin.class);
126+
project.getPluginManager().apply(GitSubmodulePlugin.class);
127+
project.getTasks().getByName("preBuild").dependsOn("updateGitSubmodules");
112128
}
113129

114130
private static void setupApiInformationAnalysis(Project project, LibraryExtension android) {
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
// Copyright 2023 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.gradle.plugins
16+
17+
import java.io.File
18+
import org.gradle.api.Plugin
19+
import org.gradle.api.Project
20+
import org.gradle.api.provider.Property
21+
import org.gradle.api.tasks.Exec
22+
import org.gradle.kotlin.dsl.create
23+
import org.gradle.kotlin.dsl.register
24+
25+
/**
26+
* Exposes configuration for [GitSubmodulePlugin].
27+
*
28+
* @param submodules the parent directory of the SDK's Git Submodules. Defaults to `src/third_party`
29+
*/
30+
interface GitSubmodulePluginExtension {
31+
val submodules: Property<File>
32+
}
33+
34+
/**
35+
* Helper plugin for common actions regarding Git Submodules
36+
*
37+
* At the time of writing this, we only have one SDK with submodules. Although, that could grow in
38+
* the future. More importantly though, this provides a way for us to make sure the submodules are
39+
* initilized whenever we are building said SDKs- while keeping our system clean and modular.
40+
*
41+
* This plugin is automatically applied to all SDKs that utilize [FirebaseLibraryPlugin], and is
42+
* subsequently bound to the `preBuild` task that is apart of all gradle modules.
43+
*
44+
* The following tasks are registered when this plugin is applied:
45+
* - [initializeGitSubmodules][registerInitializeGitSubmodulesTask]
46+
* - [updateGitSubmodules][registerUpdateGitSubmodulesTask]
47+
* - [removeGitSubmodules][registerRemoveGitSubmodulesTask]
48+
*
49+
* __Documentation explaining each task is provided in the annotation for each task__
50+
*
51+
* @see [GitSubmodulePluginExtension]
52+
*/
53+
abstract class GitSubmodulePlugin : Plugin<Project> {
54+
55+
override fun apply(project: Project) {
56+
with(configureExtension(project)) {
57+
registerInitializeGitSubmodulesTask(project, submodules.get())
58+
registerUpdateGitSubmodulesTask(project, submodules.get())
59+
registerRemoveGitSubmodulesTask(project, submodules.get())
60+
}
61+
}
62+
63+
private fun configureExtension(project: Project) =
64+
project.extensions.create<GitSubmodulePluginExtension>("GitSubmodule").apply {
65+
submodules.convention(project.file("src/third_party"))
66+
}
67+
68+
/**
69+
* Registers the initializeGitSubmodules Task for the provided [Project].
70+
*
71+
* Creates a local configuration for the predefined submodules. It does this by running the
72+
* command `git submodule init` from the [project]'s root directory.
73+
*
74+
* If there aren't any submodules to initialize, this task is skipped- saving resources.
75+
*
76+
* @param project the [Project] to register this task to
77+
* @param submodules the root directory of where the submodules live
78+
*/
79+
private fun registerInitializeGitSubmodulesTask(project: Project, submodules: File) =
80+
project.tasks.register<Exec>("initializeGitSubmodules") {
81+
onlyIf { hasEmptySubmodules(submodules) }
82+
83+
workingDir = project.projectDir
84+
commandLine = "git submodule init".split(" ")
85+
}
86+
87+
/**
88+
* Registers the updateGitSubmodules Task for the provided [Project].
89+
*
90+
* Pulls the latest data for each submodule, similiar to `git pull`. It does this by running the
91+
* command `git submodule update` from the [project]'s root directory.
92+
*
93+
* If there aren't any submodules, this task is skipped- saving resources.
94+
*
95+
* @param project the [Project] to register this task to
96+
* @param submodules the root directory of where the submodules live
97+
*/
98+
private fun registerUpdateGitSubmodulesTask(project: Project, submodules: File) =
99+
project.tasks.register<Exec>("updateGitSubmodules") {
100+
onlyIf { hasEmptySubmodules(submodules) }
101+
dependsOn("initializeGitSubmodules")
102+
103+
workingDir = project.projectDir
104+
commandLine = "git submodule update".split(" ")
105+
}
106+
107+
/**
108+
* Registers the removeGitSubmodules Task for the provided [Project].
109+
*
110+
* Removes and de initilizes all submodules for the given [project]. It does this by running the
111+
* command `git submodule deinit --all` from the [project]'s root directory.
112+
*
113+
* If there aren't any submodules to remove, this task is skipped- saving resources.
114+
*
115+
* @param project the [Project] to register this task to
116+
* @param submodules the root directory of where the submodules live
117+
*/
118+
private fun registerRemoveGitSubmodulesTask(project: Project, submodules: File) =
119+
project.tasks.register<Exec>("removeGitSubmodules") {
120+
onlyIf { submodules.exists() }
121+
122+
workingDir = project.projectDir
123+
commandLine = "git submodule deinit --all".split(" ")
124+
}
125+
126+
private fun hasEmptySubmodules(parentFolder: File) =
127+
parentFolder.listFilesOrEmpty().any { it.isDirectory && it.listFilesOrEmpty().isEmpty() }
128+
}

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,15 @@ fun Project.fileFromBuildDir(path: String) = file("$buildDir/$path")
4444
*/
4545
fun Project.childFile(provider: Provider<File>, childPath: String) =
4646
provider.map { file("${it.path}/$childPath") }
47+
48+
/**
49+
* Returns a list of children files, or an empty list if this [File] doesn't exist or doesn't have
50+
* any children.
51+
*
52+
* Syntax sugar for:
53+
*
54+
* ```
55+
* listFiles().orEmpty()
56+
* ```
57+
*/
58+
fun File.listFilesOrEmpty() = listFiles().orEmpty()

0 commit comments

Comments
 (0)