summaryrefslogtreecommitdiffhomepage
path: root/android
diff options
context:
space:
mode:
authorAlbin <albin@mullvad.net>2024-08-15 16:27:58 +0200
committerAlbin <albin@mullvad.net>2024-08-15 16:43:44 +0200
commitfaabc4e3ad1a7b77d7ed95da3e255c7d15582fac (patch)
tree2b014f4606b2f5b181d18e245bbf461c0ff7f909 /android
parentcb1df6aef6a3f09123f7ec15611188a245853e0d (diff)
downloadmullvadvpn-faabc4e3ad1a7b77d7ed95da3e255c7d15582fac.tar.xz
mullvadvpn-faabc4e3ad1a7b77d7ed95da3e255c7d15582fac.zip
Refactor lockfile script and gradle tasks
Diffstat (limited to 'android')
-rw-r--r--android/app/build.gradle.kts33
-rwxr-xr-xandroid/scripts/update-lockfile.sh21
2 files changed, 34 insertions, 20 deletions
diff --git a/android/app/build.gradle.kts b/android/app/build.gradle.kts
index 3c01abf080..ecde2e9132 100644
--- a/android/app/build.gradle.kts
+++ b/android/app/build.gradle.kts
@@ -19,6 +19,7 @@ plugins {
val repoRootPath = rootProject.projectDir.absoluteFile.parentFile.absolutePath
val extraAssetsDirectory = "${project.buildDir}/extraAssets"
+val relayListPath = "$extraAssetsDirectory/relays.json"
val defaultChangelogAssetsDirectory = "$repoRootPath/android/src/main/play/release-notes/"
val extraJniDirectory = "${project.buildDir}/extraJni"
@@ -146,10 +147,6 @@ android {
)
}
- tasks.withType<MergeSourceSetFolders> { dependsOn(getTasksByName("copyExtraAssets", true)) }
-
- tasks.withType<LintModelWriterTask> { dependsOn(getTasksByName("copyExtraAssets", true)) }
-
// Suppressing since we don't seem have much of an option than using this api. The impact should
// also be limited to tests.
@Suppress("UnstableApiUsage")
@@ -238,10 +235,14 @@ android {
}
createDistBundle.dependsOn("bundle$capitalizedVariantName")
- }
- project.tasks.assemble.dependsOn("ensureJniDirectoryExist")
- project.tasks.assemble.dependsOn("ensureValidVersionCode")
+ // Ensure all relevant assemble tasks depend on our ensure tasks.
+ tasks.get("assemble$capitalizedVariantName").apply {
+ dependsOn(tasks.get("ensureRelayListExist"))
+ dependsOn(tasks.get("ensureJniDirectoryExist"))
+ dependsOn(tasks.get("ensureValidVersionCode"))
+ }
+ }
}
junitPlatform {
@@ -274,14 +275,16 @@ configure<org.owasp.dependencycheck.gradle.extension.DependencyCheckExtension> {
skipConfigurations = listOf("lintClassPath")
}
-tasks.register("copyExtraAssets", Copy::class) {
- from("$repoRootPath/build")
- include("relays.json")
- into(extraAssetsDirectory)
+tasks.register("ensureRelayListExist") {
+ doLast {
+ if (!file(relayListPath).exists()) {
+ throw GradleException("Missing relay list: $relayListPath")
+ }
+ }
}
tasks.register("ensureJniDirectoryExist") {
- doFirst {
+ doLast {
if (!file(extraJniDirectory).exists()) {
throw GradleException("Missing JNI directory: $extraJniDirectory")
}
@@ -306,12 +309,6 @@ tasks.create("printVersion") {
}
}
-afterEvaluate {
- tasks.withType(com.android.build.gradle.internal.lint.AndroidLintAnalysisTask::class.java) {
- mustRunAfter(tasks.getByName("copyExtraAssets"))
- }
-}
-
play { serviceAccountCredentials.set(file("play-api-key.json")) }
dependencies {
diff --git a/android/scripts/update-lockfile.sh b/android/scripts/update-lockfile.sh
index d215da116b..83c8def349 100755
--- a/android/scripts/update-lockfile.sh
+++ b/android/scripts/update-lockfile.sh
@@ -11,7 +11,18 @@ GRADLE_OPTS="-Dorg.gradle.daemon=false"
# We must provide a template for mktemp to work properly on macOS.
GRADLE_USER_HOME=$(mktemp -d -t gradle-home-XXX)
TEMP_GRADLE_PROJECT_CACHE_DIR=$(mktemp -d -t gradle-cache-XXX)
-GRADLE_TASKS=("assemble" "compileDebugUnitTestKotlin" "assembleAndroidTest" "lint")
+# Task list to discover all tasks and their dependencies since
+# just running the suggested 'help' task isn't sufficient.
+GRADLE_TASKS=(
+ "assemble"
+ "compileDebugUnitTestKotlin"
+ "assembleAndroidTest"
+ "lint"
+)
+EXCLUDED_GRADLE_TASKS=(
+ "-xensureRelayListExist"
+ "-xensureJniDirectoryExist"
+)
export GRADLE_OPTS
export GRADLE_USER_HOME
@@ -30,6 +41,12 @@ echo ""
echo "Removing old components..."
sed -i '/<components>/,/<\/components>/d' ../gradle/verification-metadata.xml
+echo ""
echo "Generating new components..."
-../gradlew -q -p .. --project-cache-dir "$TEMP_GRADLE_PROJECT_CACHE_DIR" -M sha256 "${GRADLE_TASKS[@]}"
+# Using a loop here since providing all tasks at once result in gradle task dependency issues.
+for GRADLE_TASK in "${GRADLE_TASKS[@]}"; do
+ echo "Gradle task: $GRADLE_TASK"
+ ../gradlew -q -p .. --project-cache-dir "$TEMP_GRADLE_PROJECT_CACHE_DIR" -M sha256 "$GRADLE_TASK" "${EXCLUDED_GRADLE_TASKS[@]}"
+ echo ""
+done