Skip to content

Commit c4395f2

Browse files
vkryachkorlazo
andauthored
Migrate core libraries to Gradle Kotlin DSL. (#4452)
* Migrate core libraries to Gradle Kotlin DSL. * update * Add functions, fix tests * fix docs * fix functions ktx minSdk version. * Apply suggestions from code review Co-authored-by: Rodrigo Lazo <[email protected]> Co-authored-by: Rodrigo Lazo <[email protected]>
1 parent f133454 commit c4395f2

File tree

21 files changed

+468
-486
lines changed

21 files changed

+468
-486
lines changed

appcheck/firebase-appcheck-debug-testing/firebase-appcheck-debug-testing.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ android {
3131
targetSdkVersion project.targetSdkVersion
3232
minSdkVersion project.minSdkVersion
3333
versionName version
34+
multiDexEnabled = true
3435
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3536
testInstrumentationRunnerArgument "firebaseAppCheckDebugSecret", System.getenv("FIREBASE_APP_CHECK_DEBUG_SECRET") ?: ''
3637
}

appcheck/firebase-appcheck/firebase-appcheck.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ android {
2929
defaultConfig {
3030
targetSdkVersion project.targetSdkVersion
3131
minSdkVersion project.minSdkVersion
32+
multiDexEnabled = true
3233
versionName version
3334
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3435
}

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ fun toBoolean(value: Any?): Boolean {
3232

3333
/** Finds or creates the javadocClasspath [Configuration]. */
3434
val Project.javadocConfig: Configuration
35-
get() = configurations.findByName("javadocClasspath") ?: configurations.create("javadocClasspath")
35+
get() =
36+
configurations.findByName("javadocClasspath")
37+
?: configurations.create("javadocClasspath").also { javadocClasspath ->
38+
configurations.all {
39+
if (name == "compileOnly") {
40+
javadocClasspath.extendsFrom(this)
41+
}
42+
}
43+
}
3644

3745
/**
3846
* Finds or creates the dackkaArtifacts [Configuration].

contributor-docs/best_practices/dependency_injection.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ plugins {
4747
4848
dependencies {
4949
implementation(libs.javax.inject)
50-
vendor(libs.dagger) {
50+
vendor(libs.dagger.dagger) {
5151
exclude group: "javax.inject", module: "javax.inject"
5252
}
5353
annotationProcessor(libs.dagger.compiler)

firebase-annotations/firebase-annotations.gradle renamed to firebase-annotations/firebase-annotations.gradle.kts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,22 @@
1313
// limitations under the License.
1414

1515
plugins {
16-
id 'firebase-java-library'
16+
id("firebase-java-library")
1717
}
1818

1919
firebaseLibrary {
20-
publishSources = true
21-
publishJavadoc = false
20+
publishSources = true
21+
publishJavadoc = false
2222
}
2323

2424
java {
25-
sourceCompatibility JavaVersion.VERSION_1_8
26-
targetCompatibility JavaVersion.VERSION_1_8
25+
sourceCompatibility = JavaVersion.VERSION_1_8
26+
targetCompatibility = JavaVersion.VERSION_1_8
2727
}
28-
29-
tasks.withType(JavaCompile) {
30-
options.compilerArgs << "-Werror"
28+
tasks.withType<JavaCompile> {
29+
options.compilerArgs.add("-Werror")
3130
}
3231

3332
dependencies {
34-
implementation 'javax.inject:javax.inject:1'
33+
implementation(libs.javax.inject)
3534
}

firebase-common/data-collection-tests/data-collection-tests.gradle

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2022 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+
plugins {
16+
id("com.android.application")
17+
}
18+
19+
android {
20+
val targetSdkVersion : Int by rootProject
21+
val minSdkVersion : Int by rootProject
22+
compileSdk = targetSdkVersion
23+
defaultConfig {
24+
minSdk = minSdkVersion
25+
targetSdk = targetSdkVersion
26+
multiDexEnabled = true
27+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
28+
}
29+
compileOptions {
30+
sourceCompatibility = JavaVersion.VERSION_1_8
31+
targetCompatibility = JavaVersion.VERSION_1_8
32+
}
33+
testOptions.unitTests.isIncludeAndroidResources = true
34+
}
35+
36+
dependencies {
37+
implementation(project(":firebase-common"))
38+
implementation(project(":firebase-components"))
39+
testImplementation(libs.androidx.test.runner)
40+
testImplementation(libs.androidx.test.junit)
41+
testImplementation(libs.robolectric)
42+
testImplementation(libs.autovalue.annotations)
43+
testImplementation(libs.junit)
44+
testImplementation(libs.truth)
45+
testImplementation(libs.mockito.core)
46+
testImplementation(libs.androidx.core)
47+
}

firebase-common/firebase-common.gradle

Lines changed: 0 additions & 100 deletions
This file was deleted.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
// Copyright 2022 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+
plugins {
16+
id("firebase-library")
17+
}
18+
19+
firebaseLibrary {
20+
testLab.enabled = true
21+
publishSources = true
22+
}
23+
24+
android {
25+
val targetSdkVersion : Int by rootProject
26+
val minSdkVersion : Int by rootProject
27+
28+
compileSdk = targetSdkVersion
29+
defaultConfig {
30+
minSdk = minSdkVersion
31+
targetSdk = targetSdkVersion
32+
multiDexEnabled = true
33+
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
34+
consumerProguardFiles("proguard.txt")
35+
}
36+
sourceSets {
37+
getByName("androidTest") {
38+
java.srcDirs("src/testUtil")
39+
}
40+
getByName("test") {
41+
java.srcDirs("src/testUtil")
42+
}
43+
}
44+
compileOptions {
45+
sourceCompatibility = JavaVersion.VERSION_1_8
46+
targetCompatibility = JavaVersion.VERSION_1_8
47+
}
48+
testOptions.unitTests.isIncludeAndroidResources = true
49+
}
50+
51+
dependencies {
52+
implementation(project(":firebase-annotations"))
53+
implementation(project(":firebase-components"))
54+
implementation(libs.androidx.futures)
55+
implementation(libs.playservices.basement)
56+
implementation(libs.playservices.tasks)
57+
58+
annotationProcessor(libs.autovalue)
59+
60+
compileOnly(libs.autovalue.annotations)
61+
compileOnly(libs.findbugs.jsr305)
62+
// needed for Kotlin detection to compile, but not necessarily present at runtime.
63+
compileOnly(libs.kotlin.stdlib)
64+
65+
// FirebaseApp references storage, so storage needs to be on classpath when dokka runs.
66+
javadocClasspath(project(":firebase-storage"))
67+
68+
testImplementation(libs.androidx.test.junit)
69+
testImplementation(libs.androidx.test.junit)
70+
testImplementation(libs.androidx.test.runner)
71+
testImplementation(libs.junit)
72+
testImplementation(libs.mockito.core)
73+
testImplementation(libs.org.json)
74+
testImplementation(libs.robolectric)
75+
testImplementation(libs.truth)
76+
77+
androidTestImplementation(libs.androidx.test.junit)
78+
androidTestImplementation(libs.androidx.test.runner)
79+
androidTestImplementation(libs.junit)
80+
androidTestImplementation(libs.mockito.core)
81+
androidTestImplementation(libs.mockito.dexmaker)
82+
androidTestImplementation(libs.truth)
83+
androidTestImplementation(project(":integ-testing"))
84+
}

firebase-common/lint-baseline.xml

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)