Skip to content

Commit aceb5b2

Browse files
committed
Set test type to release only in CI.
This fixes Android Studio issue, where it is impossible to run integration tests in debug mode. Additionally move build type configuration to FirebaseLibraryPlugin to avoid projects.all configuration in gradle.
1 parent b69b2c8 commit aceb5b2

File tree

2 files changed

+19
-33
lines changed

2 files changed

+19
-33
lines changed

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.google.firebase.gradle.plugins.ci.device.FirebaseTestServer;
2121
import org.gradle.api.Plugin;
2222
import org.gradle.api.Project;
23-
import org.gradle.api.tasks.bundling.Jar;
2423
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile;
2524

2625
public class FirebaseLibraryPlugin implements Plugin<Project> {
@@ -32,6 +31,25 @@ public void apply(Project project) {
3231
project.getExtensions().create("firebaseLibrary", FirebaseLibraryExtension.class, project);
3332

3433
LibraryExtension android = project.getExtensions().getByType(LibraryExtension.class);
34+
android.buildTypes(
35+
types ->
36+
types
37+
.getByName("release")
38+
.setSigningConfig(types.getByName("debug").getSigningConfig()));
39+
40+
// skip debug tests in CI
41+
// TODO(vkryachko): provide ability for teams to control this if needed
42+
if (System.getenv().containsKey("FIREBASE_CI")) {
43+
android.setTestBuildType("release");
44+
project
45+
.getTasks()
46+
.all(
47+
task -> {
48+
if ("testDebugUnitTest".equals(task.getName())) {
49+
task.setEnabled(false);
50+
}
51+
});
52+
}
3553

3654
android.testServer(new FirebaseTestServer(project, firebaseLibrary.testLab));
3755

root-project.gradle

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -140,38 +140,6 @@ configure(subprojects) {
140140
}
141141
}
142142

143-
/**
144-
* Disable "debug" build type for all subprojects.
145-
*
146-
* They are identical to "release" and are not used in either release or smoke tests. Disabling them
147-
* to reduce the number of tests we run on pre/post-submit.
148-
*/
149-
configure(subprojects) {
150-
afterEvaluate { Project sub ->
151-
if (!sub.plugins.hasPlugin('com.android.library') && !sub.plugins.hasPlugin('com.android.application')) {
152-
return
153-
}
154-
155-
// skip debug unit tests in CI
156-
// TODO(vkryachko): provide ability for teams to control this if needed
157-
if (System.getenv().containsKey("FIREBASE_CI")) {
158-
sub.tasks.all {Task task ->
159-
if (task.name == 'testDebugUnitTest') {
160-
task.enabled = false
161-
}
162-
}
163-
}
164-
sub.android {
165-
testBuildType "release"
166-
167-
buildTypes {
168-
// In the case of and android library signing config only affects instrumentation test APK.
169-
// We need it signed with default debug credentials in order for FTL to accept the APK.
170-
release.signingConfig = debug.signingConfig
171-
}
172-
}
173-
}
174-
}
175143

176144
/**
177145
* Configure "Preguarding" and Desugaring for the subprojects.

0 commit comments

Comments
 (0)