Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion AnkiDroid/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,13 @@ dependencies {
localProperties.load(project.rootProject.file("local.properties").inputStream())
}
if (localProperties["local_backend"] == "true") {
implementation(files(rootProject.file("../Anki-Android-Backend/rsdroid/build/outputs/aar/rsdroid-release.aar")))
// Local AARs have no Maven metadata, so both the API and Android artifacts are needed.
implementation(
files(
rootProject.file("../Anki-Android-Backend/rsdroid/build/outputs/aar/rsdroid-release.aar"),
rootProject.file("../Anki-Android-Backend/rsdroid-android/build/outputs/aar/rsdroid-android-release.aar"),
),
)
testImplementation(files(rootProject.file("../Anki-Android-Backend/rsdroid-testing/build/libs/rsdroid-testing.jar")))
} else {
implementation(libs.ankiBackend.backend)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PageWebViewClientAssetTest : PageWebViewClientTestBase() {

// Pin the entire declaration, including the bootstrap script hash, to require review on backend updates.
// Backend updates are expected to change this hash and fail this test until the new declaration is reviewed.
val expectedPolicy = "script-src 'self' 'sha256-KgVk6DKxcC2FwNZfJ2E4h8ryzLcg38Fu9Id96eo1C5A='"
val expectedPolicy = "script-src 'self' 'sha256-ZtbRHoVXnThxdihCTDoE7B58+asHn6tYkHhb2gnJ6hA='"
assertEquals(
listOf(expectedPolicy),
policies,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import org.gradle.kotlin.dsl.DependencyHandlerScope
import java.io.File
import java.util.Properties

// The Anki backend (rsdroid) is consumed either as a locally-built artifact in
// The Anki backend (rsdroid) is consumed either as locally-built artifacts in
// ../Anki-Android-Backend (when `local_backend=true` in local.properties) or as
// the published library from the version catalog.

// Paths within the `Anki-Android-Backend` checkout, which sits beside the repo root.
private const val RSDROID_AAR =
"rsdroid/build/outputs/aar/rsdroid-release.aar"
private const val RSDROID_ANDROID_AAR =
"rsdroid-android/build/outputs/aar/rsdroid-android-release.aar"
private const val RSDROID_TESTING_JAR =
"rsdroid-testing/build/libs/rsdroid-testing.jar"

Expand All @@ -29,15 +31,35 @@ fun DependencyHandlerScope.addAnkiBackendDependencies(project: Project) {
with(project) {
val useLocalBackend = localBackendEnabled()

addBackendArtifact("implementation", useLocalBackend, RSDROID_AAR, "ankiBackend-backend")
addBackendArtifact("testImplementation", useLocalBackend, RSDROID_TESTING_JAR, "ankiBackend-testing")
addBackendArtifact(
configuration = "implementation",
useLocalBackend = useLocalBackend,
catalogAlias = "ankiBackend-backend",
localPaths = arrayOf(RSDROID_AAR, RSDROID_ANDROID_AAR),
)
addBackendArtifact(
configuration = "testImplementation",
useLocalBackend = useLocalBackend,
catalogAlias = "ankiBackend-testing",
localPaths = arrayOf(RSDROID_TESTING_JAR),
)

// protobuf is required when loading from a file, regardless of the backend source
dependencies.addProvider("implementation", libsLibrary("protobuf-kotlin-lite"))

if (project.hasTestFixtures) {
addBackendArtifact("testFixturesImplementation", useLocalBackend, RSDROID_AAR, "ankiBackend-backend")
addBackendArtifact("testFixturesImplementation", useLocalBackend, RSDROID_TESTING_JAR, "ankiBackend-testing")
addBackendArtifact(
configuration = "testFixturesImplementation",
useLocalBackend = useLocalBackend,
catalogAlias = "ankiBackend-backend",
localPaths = arrayOf(RSDROID_AAR, RSDROID_ANDROID_AAR),
)
addBackendArtifact(
configuration = "testFixturesImplementation",
useLocalBackend = useLocalBackend,
catalogAlias = "ankiBackend-testing",
localPaths = arrayOf(RSDROID_TESTING_JAR),
)
dependencies.addProvider("testFixturesImplementation", libsLibrary("protobuf-kotlin-lite"))
}
}
Expand All @@ -56,13 +78,14 @@ private fun Project.localBackendEnabled(): Boolean {
private fun Project.addBackendArtifact(
configuration: String,
useLocalBackend: Boolean,
localPath: String,
catalogAlias: String,
vararg localPaths: String,
) {
if (useLocalBackend) {
// ../Anki-Android-Backend
val backendCheckout = File(rootProject.projectDir.parentFile, "Anki-Android-Backend")
dependencies.add(configuration, files(File(backendCheckout, localPath)))
// Local AARs have no Maven metadata, so both the API and Android artifacts are needed.
dependencies.add(configuration, files(localPaths.map { File(backendCheckout, it) }))
} else {
dependencies.addProvider(configuration, libsLibrary(catalogAlias))
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ androidxWebkit = "1.16.0"
# https://developer.android.com/jetpack/androidx/releases/work
androidxWork = "2.12.0"
# https://github.com/ankidroid/Anki-Android-Backend/
ankiBackend = '0.1.74-anki26.09.3'
ankiBackend = '0.1.75-anki26.09.3' # Also update expectedPolicy in PageWebViewClientAssetTest
autoService = "1.1.1"
autoServiceAnnotations = "1.1.1"
# https://github.com/skydoves/ColorPickerView/releases
Expand Down
Loading