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