Skip to content

Commit 07b4dc3

Browse files
committed
Various changes due to Ashwin's comments
1 parent 377a00b commit 07b4dc3

File tree

5 files changed

+24
-41
lines changed

5 files changed

+24
-41
lines changed

buildSrc/src/main/groovy/com/google/firebase/gradle/GenerateMeasurementsTask.groovy

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,20 @@ public class GenerateMeasurementsTask extends DefaultTask {
3636
* The file storing the SDK map.
3737
*
3838
* <p>This may be any type recognized by Gradle as a file. The format of the file's contents is
39-
* headerless CSVwith a colon as a delimiter: projectName_buildVariant:sdkId. The first column
40-
* contains both the project name and build variant separated by an hyphen, {@code
41-
* firestore-aggressive}, for example.
39+
* headerless CSV with a colon as a delimiter: projectName-buildVariant:sdkId. The first column
40+
* contains both the project name and build variant separated by an hyphen. The SDK ID is the
41+
* integer identifier used by the SQL database to represent this SDK and build variant pair.
42+
*
43+
* <p>A complete example follows:
44+
* <pre>{@code
45+
* database-debug:1
46+
* database-release:2
47+
* firestore-release:7
48+
* firestore-debug:4
49+
*}</pre>
4250
*/
4351
@InputFile
44-
File sdkMap
52+
File sdkMapFile
4553

4654
/**
4755
* The file for storing the report.
@@ -50,7 +58,7 @@ public class GenerateMeasurementsTask extends DefaultTask {
5058
* overwritten by the new report.
5159
*/
5260
@OutputFile
53-
File report
61+
File reportFile
5462

5563
@Override
5664
Task configure(Closure closure) {
@@ -71,21 +79,25 @@ public class GenerateMeasurementsTask extends DefaultTask {
7179
def sizes = calculateSizes(sdks, project.android.applicationVariants)
7280
def report = createReport(sizes)
7381

74-
project.file(this.report).withWriter {
82+
reportFile.withWriter {
7583
it.write(report)
7684
}
7785
}
7886

7987
private def calculateSizes(sdks, variants) {
8088
def sizes = [:]
8189

90+
// Each variant should have exactly one APK. If there are multiple APKs, then this file is out
91+
// of sync with our Gradle configuration, and this task fails. If an APK is missing, it is
92+
// silently ignored, and the APKs from the other variants will be used to build the report.
8293
variants.each { variant ->
8394
def name = "${variant.flavorName}-${variant.buildType.name}"
8495
def apks = variant.outputs.findAll { it.outputFile.name.endsWith(".apk") }
8596
if (apks.size() > 1) {
8697
throw new IllegalStateException("${name} produced more than one APK")
8798
}
8899

100+
// This runs at most once, as each variant at this point has zero or one APK.
89101
apks.each {
90102
def size = it.outputFile.size();
91103
def sdk = sdks[name];
@@ -168,9 +180,8 @@ public class GenerateMeasurementsTask extends DefaultTask {
168180

169181
private def createSdkMap() {
170182
def map = [:]
171-
def path = project.file(sdkMap)
172183

173-
path.eachLine {
184+
sdkMapFile.eachLine {
174185
def delimiter = it.indexOf(":")
175186
def key = it.substring(0, delimiter).trim()
176187
def value = it.substring(delimiter + 1).trim()

buildSrc/src/main/groovy/com/google/firebase/gradle/UploadMeasurementsTask.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class UploadMeasurementsTask extends DefaultTask {
5050
* provided they run first.
5151
*/
5252
@InputFile
53-
File report
53+
File reportFile
5454

5555
@TaskAction
5656
def upload() {
@@ -72,7 +72,7 @@ public class UploadMeasurementsTask extends DefaultTask {
7272
"-jar",
7373
jar,
7474
"--config_path=${configuration}",
75-
"--proto_path=${report}",
75+
"--proto_path=${reportFile}",
7676
)
7777
}.rethrowFailure()
7878
}

tools/apksize/apksize.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ apply from: "src/functions/functions.gradle"
4242
* @param -Ppull_request the pull request number to be included in the report
4343
*/
4444
task generateMeasurements(type: GenerateMeasurementsTask) {
45-
sdkMap = file("sdks.csv")
46-
report = file("$buildDir/size-report.textpb")
45+
sdkMapFile = file("sdks.csv")
46+
reportFile = file("$buildDir/size-report.textpb")
4747
}
4848

4949
/**
@@ -55,7 +55,7 @@ task generateMeasurements(type: GenerateMeasurementsTask) {
5555
task uploadMeasurements(type: UploadMeasurementsTask) {
5656
dependsOn generateMeasurements
5757

58-
report = file("$buildDir/size-report.textpb")
58+
reportFile = file("$buildDir/size-report.textpb")
5959
uploader = "https://storage.googleapis.com/firebase-engprod-metrics/upload_tool.jar"
6060
}
6161

tools/apksize/default.gradle

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ android {
3636
versionName '1.0'
3737
}
3838

39-
signingConfigs {
40-
debug {
41-
keyAlias 'androiddebugkey'
42-
keyPassword 'android'
43-
storeFile file('debug.keystore')
44-
storePassword 'android'
45-
}
46-
}
47-
4839
packagingOptions {
4940
exclude 'META-INF/LICENSE'
5041
exclude 'META-INF/LICENSE-FIREBASE.txt'
Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1 @@
1-
# Add project specific ProGuard rules here.
2-
# By default, the flags in this file are appended to flags specified
3-
# in /usr/local/google/home/askutarenko/Android/Sdk/tools/proguard/proguard-android.txt
4-
# You can edit the include path and order by changing the proguardFiles
5-
# directive in build.gradle.
6-
#
7-
# For more details, see
8-
# http://developer.android.com/guide/developing/tools/proguard.html
9-
10-
# Add any project specific keep options here:
11-
12-
# If your project uses WebView with JS, uncomment the following
13-
# and specify the fully qualified class name to the JavaScript interface
14-
# class:-keepclassmembers class fqcn.of.javascript.interface.for.webview {
15-
# public *;
16-
#}
17-
-assumenosideeffects public class com.google.android.gms.ads.internal.ClientApi {
18-
public static void retainReference(...);
19-
}
201
-dontwarn **

0 commit comments

Comments
 (0)