Skip to content

Commit 2274696

Browse files
authored
Optimize build performance (#1422)
2 parents a8c0f47 + a83aa37 commit 2274696

File tree

12 files changed

+45
-51
lines changed

12 files changed

+45
-51
lines changed

app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ android {
77
}
88

99
buildTypes {
10-
getByName("release") {
10+
named("release").configure {
1111
// For the purposes of the sample, allow testing of a proguarded release build
1212
// using the debug key
1313
signingConfig = signingConfigs["debug"]

auth/build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
21
import com.android.build.gradle.internal.dsl.TestOptions
32

43
android {
54
buildTypes {
6-
getByName("release") {
5+
named("release").configure {
76
postprocessing {
87
consumerProguardFiles("auth-proguard.pro")
98
}

build.gradle.kts

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ buildscript {
2424
}
2525

2626
plugins {
27+
`build-scan` version "1.16"
2728
id("com.github.ben-manes.versions") version "0.20.0"
2829
}
2930

31+
buildScan {
32+
setTermsOfServiceUrl("https://gradle.com/terms-of-service")
33+
setTermsOfServiceAgree("yes")
34+
}
35+
3036
// See https://github.com/gradle/kotlin-dsl/issues/607#issuecomment-375687119
3137
subprojects { parent!!.path.takeIf { it != rootProject.path }?.let { evaluationDependsOn(it) } }
3238

@@ -47,7 +53,7 @@ allprojects {
4753
}
4854
}
4955

50-
tasks.withType<Wrapper> {
56+
tasks.withType<Wrapper>().configureEach {
5157
distributionType = Wrapper.DistributionType.ALL
5258
}
5359

@@ -115,10 +121,10 @@ fun Project.configureQuality() {
115121
apply(plugin = "checkstyle")
116122

117123
configure<CheckstyleExtension> { toolVersion = "8.10.1" }
118-
check { dependsOn("checkstyle") }
124+
tasks.named("check").configure { dependsOn("checkstyle") }
119125

120-
task<Checkstyle>("checkstyle") {
121-
configFile = file("$configDir/checkstyle.xml")
126+
tasks.register<Checkstyle>("checkstyle") {
127+
configFile = file("${project.configDir}/checkstyle.xml")
122128
source("src")
123129
include("**/*.java")
124130
exclude("**/gen/**")
@@ -127,85 +133,77 @@ fun Project.configureQuality() {
127133
}
128134

129135
fun Project.setupPublishing() {
130-
val sourcesJar = task<Jar>("sourcesJar") {
136+
val sourcesJar = tasks.register<Jar>("sourcesJar") {
131137
classifier = "sources"
132138
from(project.the<BaseExtension>().sourceSets["main"].java.srcDirs)
133139
}
134140

135-
val javadoc = task<Javadoc>("javadoc") {
136-
afterEvaluate {
137-
dependsOn(project.the<LibraryExtension>().libraryVariants.map { it.assemble })
141+
val javadoc = tasks.register<Javadoc>("javadoc") {
142+
setSource(project.the<BaseExtension>().sourceSets["main"].java.srcDirs)
143+
classpath += files(project.the<BaseExtension>().bootClasspath)
138144

139-
setSource(project.the<BaseExtension>().sourceSets["main"].java.srcDirs)
140-
classpath += files(project.the<BaseExtension>().bootClasspath)
141-
classpath += files(project.the<LibraryExtension>().libraryVariants.map {
142-
(it.javaCompiler as AbstractCompile).classpath
143-
})
145+
project.the<LibraryExtension>().libraryVariants.configureEach {
146+
dependsOn(assemble)
147+
classpath += files((javaCompiler as AbstractCompile).classpath)
144148
}
145149

146150
// Ignore warnings about incomplete documentation
147151
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
148152
}
149153

150-
val javadocJar = task<Jar>("javadocJar") {
154+
val javadocJar = tasks.register<Jar>("javadocJar") {
151155
dependsOn(javadoc)
152156
classifier = "javadoc"
153-
from(javadoc.destinationDir)
157+
from(javadoc.get().destinationDir)
154158
}
155159

156160
artifacts.add("archives", javadocJar)
157161
artifacts.add("archives", sourcesJar)
158162

159-
tasks.whenTaskAdded {
160-
if (name.contains("publish") && name.contains("publication", true)) {
161-
dependsOn("assembleRelease")
162-
}
163-
}
164-
165163
afterEvaluate {
166164
if (isLibrary) {
167-
task("testAll") {
165+
tasks.register("testAll") {
168166
dependsOn(*Config.submodules.map {
169167
":$it:testDebugUnitTest"
170168
}.toTypedArray())
171169
}
172170

173-
task("prepareArtifacts") {
171+
tasks.register("prepareArtifacts") {
174172
dependsOn(javadocJar, sourcesJar, "assembleRelease")
175173
dependsOn("generatePomFileForMonolithLibraryPublication")
176174
dependsOn(*Config.submodules.map {
177175
":$it:prepareArtifacts"
178176
}.toTypedArray())
179177
}
180178

181-
task("publishAllToMavenLocal") {
179+
tasks.register("publishAllToMavenLocal") {
182180
dependsOn("publishMonolithLibraryPublicationToMavenLocal")
183181
dependsOn(*Config.submodules.map {
184182
":$it:publish${it.capitalize()}LibraryPublicationToMavenLocal"
185183
}.toTypedArray())
186184
}
187185

188-
task("publishAllToCustomLocal") {
186+
tasks.register("publishAllToCustomLocal") {
189187
dependsOn("publishMonolithLibraryPublicationToCustomLocalRepository")
190188
dependsOn(*Config.submodules.map {
191189
":$it:publish${it.capitalize()}LibraryPublicationToCustomLocalRepository"
192190
}.toTypedArray())
193191
}
194192

195-
task("bintrayUploadAll") {
193+
tasks.register("bintrayUploadAll") {
196194
dependsOn("bintrayUpload")
197195
dependsOn(*Config.submodules.map {
198196
":$it:bintrayUpload"
199197
}.toTypedArray())
200198
}
201199
} else {
202200
val pomTask = "generatePomFileFor${name.capitalize()}LibraryPublication"
203-
task("prepareArtifacts") {
201+
tasks.register("prepareArtifacts") {
204202
dependsOn(javadocJar, sourcesJar, "assembleRelease", pomTask)
205203
}
206204
}
207205

208-
tasks["bintrayUpload"].dependsOn("prepareArtifacts")
206+
tasks.named("bintrayUpload").configure { dependsOn("prepareArtifacts") }
209207
}
210208

211209
apply(plugin = "maven-publish")
@@ -251,8 +249,8 @@ fun Project.setupPublishing() {
251249
""".trimMargin())
252250

253251
artifact(releaseAar)
254-
artifact(javadocJar)
255-
artifact(sourcesJar)
252+
artifact(javadocJar.get())
253+
artifact(sourcesJar.get())
256254

257255
pom {
258256
name.set("FirebaseUI ${project.name.capitalize()}")
@@ -325,6 +323,12 @@ fun Project.setupPublishing() {
325323
}
326324
}
327325

326+
tasks.matching {
327+
it.name.contains("publish") && it.name.contains("publication", true)
328+
}.configureEach {
329+
dependsOn("assembleRelease")
330+
}
331+
328332
val bintrayUsername = properties["bintrayUser"] as String?
329333
?: System.getProperty("BINTRAY_USER") ?: System.getenv("BINTRAY_USER")
330334
val bintrayKey = properties["bintrayKey"] as String?
@@ -341,7 +345,7 @@ fun Project.setupPublishing() {
341345
})
342346
}
343347

344-
tasks.withType<ArtifactoryTask> { publications(publicationName) }
348+
tasks.withType<ArtifactoryTask>().configureEach { publications(publicationName) }
345349

346350
configure<BintrayExtension> {
347351
user = bintrayUsername

buildSrc/src/main/kotlin/Projects.kt

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

database/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
check { dependsOn("compileDebugAndroidTestJavaWithJavac") }
1+
tasks.named("check").configure { dependsOn("compileDebugAndroidTestJavaWithJavac") }
22

33
android {
44
defaultConfig {

firestore/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
check { dependsOn("compileDebugAndroidTestJavaWithJavac") }
1+
tasks.named("check").configure { dependsOn("compileDebugAndroidTestJavaWithJavac") }
22

33
android {
44
defaultConfig {
55
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
66
}
77

88
buildTypes {
9-
getByName("release") {
9+
named("release").configure {
1010
postprocessing {
1111
consumerProguardFiles("proguard-rules.pro")
1212
}

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
org.gradle.jvmargs=-Xmx6g -XX:ReservedCodeCacheSize=2g -Dfile.encoding=UTF-8
1+
org.gradle.jvmargs=-Xmx4g -Dfile.encoding=UTF-8
22
org.gradle.parallel=true
33
org.gradle.configureondemand=true
44
org.gradle.caching=true

gradle/wrapper/gradle-wrapper.jar

-5 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-rc-3-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

internal/lint/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dependencies {
1010
testImplementation(Config.Libs.Lint.tests)
1111
}
1212

13-
tasks.withType<Jar> {
13+
tasks.withType<Jar>().configureEach {
1414
manifest {
1515
attributes(mapOf("Lint-Registry-v2" to "com.firebaseui.lint.LintIssueRegistry"))
1616
}

library/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
check { dependsOn("testAll", "prepareArtifacts") }
1+
tasks.named("check").configure { dependsOn("testAll", "prepareArtifacts") }
22

33
android {
44
lintOptions {

proguard-tests/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ android {
44
}
55

66
buildTypes {
7-
getByName("release") {
7+
named("release").configure {
88
// For the purposes of the sample, allow testing of a proguarded release build
99
// using the debug key
1010
signingConfig = signingConfigs["debug"]

0 commit comments

Comments
 (0)