mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-20 02:58:45 +00:00
Add support for configuration cache.
This commit is contained in:
committed by
Cody Henthorne
parent
0f72c6face
commit
eba5c5ceeb
@@ -1,6 +1,7 @@
|
||||
@file:Suppress("UnstableApiUsage")
|
||||
|
||||
import com.android.build.api.dsl.ManagedVirtualDevice
|
||||
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.io.FileInputStream
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
@@ -634,39 +635,25 @@ fun assertIsGitRepo() {
|
||||
fun getLastCommitTimestamp(): String {
|
||||
assertIsGitRepo()
|
||||
|
||||
ByteArrayOutputStream().use { os ->
|
||||
exec {
|
||||
executable = "git"
|
||||
args = listOf("log", "-1", "--pretty=format:%ct")
|
||||
standardOutput = os
|
||||
}
|
||||
|
||||
return os.toString() + "000"
|
||||
}
|
||||
return providers.exec {
|
||||
commandLine("git", "log", "-1", "--pretty=format:%ct")
|
||||
}.standardOutput.asText.get() + "000"
|
||||
}
|
||||
|
||||
fun getGitHash(): String {
|
||||
assertIsGitRepo()
|
||||
|
||||
val stdout = ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine = listOf("git", "rev-parse", "HEAD")
|
||||
standardOutput = stdout
|
||||
}
|
||||
|
||||
return stdout.toString().trim().substring(0, 12)
|
||||
return providers.exec {
|
||||
commandLine("git", "rev-parse", "HEAD")
|
||||
}.standardOutput.asText.get().trim().substring(0, 12)
|
||||
}
|
||||
|
||||
fun getCurrentGitTag(): String? {
|
||||
assertIsGitRepo()
|
||||
|
||||
val stdout = ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine = listOf("git", "tag", "--points-at", "HEAD")
|
||||
standardOutput = stdout
|
||||
}
|
||||
|
||||
val output: String = stdout.toString().trim()
|
||||
val output = providers.exec {
|
||||
commandLine("git", "tag", "--points-at", "HEAD")
|
||||
}.standardOutput.asText.get().trim()
|
||||
|
||||
return if (output.isNotEmpty()) {
|
||||
val tags = output.split("\n").toList()
|
||||
@@ -686,19 +673,10 @@ tasks.withType<Test>().configureEach {
|
||||
}
|
||||
}
|
||||
|
||||
project.tasks.configureEach {
|
||||
if (name.lowercase().contains("nightly") && name != "checkNightlyParams") {
|
||||
dependsOn(tasks.getByName("checkNightlyParams"))
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("checkNightlyParams") {
|
||||
doFirst {
|
||||
if (project.gradle.startParameter.taskNames.any { it.lowercase().contains("nightly") }) {
|
||||
|
||||
if (!file("${project.rootDir}/nightly-url.txt").exists()) {
|
||||
throw GradleException("Cannot find 'nightly-url.txt' for nightly build! It must exist in the root of this project and contain the location of the nightly manifest.")
|
||||
}
|
||||
gradle.taskGraph.whenReady {
|
||||
if (gradle.startParameter.taskNames.any { it.contains("nightly", ignoreCase = true) }) {
|
||||
if (!file("nightly-url.txt").exists()) {
|
||||
throw GradleException("Missing required file: nightly-url.txt")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ tasks.register("format") {
|
||||
}
|
||||
|
||||
tasks.register("checkStopship") {
|
||||
val cachedProjectDir = projectDir
|
||||
doLast {
|
||||
val excludedFiles = listOf(
|
||||
"build.gradle.kts",
|
||||
@@ -125,11 +126,11 @@ tasks.register("checkStopship") {
|
||||
|
||||
val allowedExtensions = setOf("kt", "kts", "java", "xml")
|
||||
|
||||
val allFiles = projectDir.walkTopDown()
|
||||
val allFiles = cachedProjectDir.walkTopDown()
|
||||
.asSequence()
|
||||
.filter { it.isFile && it.extension in allowedExtensions }
|
||||
.filterNot {
|
||||
val path = it.relativeTo(projectDir).path
|
||||
val path = it.relativeTo(cachedProjectDir).path
|
||||
excludedFiles.contains(path) || excludedDirectories.any { d -> path.startsWith(d) }
|
||||
}
|
||||
.toList()
|
||||
@@ -143,7 +144,7 @@ tasks.register("checkStopship") {
|
||||
allFiles.map { file ->
|
||||
scope.async {
|
||||
if (file.readText().contains("STOPSHIP")) {
|
||||
stopshipFiles += file.relativeTo(projectDir).path
|
||||
stopshipFiles += file.relativeTo(cachedProjectDir).path
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
org.gradle.jvmargs=-Xmx12g -Xms256m -XX:MaxMetaspaceSize=1g
|
||||
android.useAndroidX=true
|
||||
android.experimental.androidTest.numManagedDeviceShards=4
|
||||
org.gradle.configuration-cache=true
|
||||
# We never want to use auto-provisioning, as it breaks reproducible builds.
|
||||
# This should not be a problem, because we never configure a "javaRepositories"
|
||||
# item to tell Gradle where to auto-provision the toolchain from, but adding
|
||||
|
||||
Reference in New Issue
Block a user