Skip to content

Commit 6776cf7

Browse files
committed
Optimize build performance
Signed-off-by: Alex Saveau <[email protected]>
1 parent 4cd8b74 commit 6776cf7

File tree

6 files changed

+31
-34
lines changed

6 files changed

+31
-34
lines changed

build.gradle.kts

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,15 @@ buildscript {
2323
}
2424

2525
plugins {
26+
`build-scan` version "1.16"
2627
id("com.github.ben-manes.versions") version "0.20.0"
2728
}
2829

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

@@ -124,9 +130,9 @@ fun Project.configureQuality() {
124130
apply(plugin = "checkstyle")
125131

126132
configure<CheckstyleExtension> { toolVersion = "8.10.1" }
127-
check { dependsOn("checkstyle") }
133+
tasks.named("check").configure { dependsOn("checkstyle") }
128134

129-
task<Checkstyle>("checkstyle") {
135+
tasks.register<Checkstyle>("checkstyle") {
130136
configFile = file("$configDir/checkstyle.xml")
131137
source("src")
132138
include("**/*.java")
@@ -136,76 +142,70 @@ fun Project.configureQuality() {
136142
}
137143

138144
fun Project.setupPublishing() {
139-
val sourcesJar = task<Jar>("sourcesJar") {
145+
val sourcesJar = tasks.register<Jar>("sourcesJar") {
140146
classifier = "sources"
141147
from(project.the<BaseExtension>().sourceSets["main"].java.srcDirs)
142148
}
143149

144-
val javadoc = task<Javadoc>("javadoc") {
150+
val javadoc = tasks.register<Javadoc>("javadoc") {
145151
setSource(project.the<BaseExtension>().sourceSets["main"].java.srcDirs)
146152
classpath += configurations["compile"]
147153
classpath += project.files(project.the<BaseExtension>().bootClasspath)
148154
}
149155

150-
val javadocJar = task<Jar>("javadocJar") {
156+
val javadocJar = tasks.register<Jar>("javadocJar") {
151157
dependsOn(javadoc)
152158
classifier = "javadoc"
153-
from(javadoc.destinationDir)
159+
from(javadoc.get().destinationDir)
154160
}
155161

156162
artifacts.add("archives", javadocJar)
157163
artifacts.add("archives", sourcesJar)
158164

159-
tasks.whenTaskAdded {
160-
if (name.contains("publish") && name.contains("publication", true)) {
161-
dependsOn("assembleRelease")
162-
}
163-
}
164-
165165
afterEvaluate {
166166
if (isLibrary) {
167-
task("testAll") {
167+
tasks.register("testAll") {
168168
dependsOn(*Config.submodules.map {
169169
":$it:testDebugUnitTest"
170170
}.toTypedArray())
171171
}
172172

173-
task("prepareArtifacts") {
173+
tasks.register("prepareArtifacts") {
174174
dependsOn(javadocJar, sourcesJar, "assembleRelease")
175175
dependsOn("generatePomFileForMonolithLibraryPublication")
176176
dependsOn(*Config.submodules.map {
177177
":$it:prepareArtifacts"
178178
}.toTypedArray())
179179
}
180180

181-
task("publishAllToMavenLocal") {
181+
tasks.register("publishAllToMavenLocal") {
182182
dependsOn("publishMonolithLibraryPublicationToMavenLocal")
183183
dependsOn(*Config.submodules.map {
184184
":$it:publish${it.capitalize()}LibraryPublicationToMavenLocal"
185185
}.toTypedArray())
186186
}
187187

188-
task("publishAllToCustomLocal") {
188+
tasks.register("publishAllToCustomLocal") {
189189
dependsOn("publishMonolithLibraryPublicationToCustomLocalRepository")
190190
dependsOn(*Config.submodules.map {
191191
":$it:publish${it.capitalize()}LibraryPublicationToCustomLocalRepository"
192192
}.toTypedArray())
193193
}
194194

195-
task("bintrayUploadAll") {
195+
tasks.register("bintrayUploadAll") {
196196
dependsOn("bintrayUpload")
197197
dependsOn(*Config.submodules.map {
198198
":$it:bintrayUpload"
199199
}.toTypedArray())
200200
}
201201
} else {
202202
val pomTask = "generatePomFileFor${project.name.capitalize()}LibraryPublication"
203-
task("prepareArtifacts") {
203+
tasks.register("prepareArtifacts") {
204204
dependsOn(javadocJar, sourcesJar, "assembleRelease", pomTask)
205205
}
206206
}
207207

208-
tasks["bintrayUpload"].dependsOn("prepareArtifacts")
208+
tasks.named("bintrayUpload").configure { dependsOn("prepareArtifacts") }
209209
}
210210

211211
apply(plugin = "maven-publish")
@@ -251,8 +251,8 @@ fun Project.setupPublishing() {
251251
""".trimMargin())
252252

253253
artifact(releaseAar)
254-
artifact(javadocJar)
255-
artifact(sourcesJar)
254+
artifact(javadocJar.get())
255+
artifact(sourcesJar.get())
256256

257257
pom {
258258
name.set("FirebaseUI ${project.name.capitalize()}")
@@ -325,6 +325,12 @@ fun Project.setupPublishing() {
325325
}
326326
}
327327

328+
tasks.matching {
329+
it.name.contains("publish") && it.name.contains("publication", true)
330+
}.forEach {
331+
it.dependsOn("assembleRelease")
332+
}
333+
328334
val bintrayUsername = properties["bintrayUser"] as String?
329335
?: System.getProperty("BINTRAY_USER") ?: System.getenv("BINTRAY_USER")
330336
val bintrayKey = properties["bintrayKey"] as String?

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: 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 {

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

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 {

0 commit comments

Comments
 (0)