diff --git a/build-logic/application/build.gradle.kts b/build-logic/application/build.gradle.kts new file mode 100644 index 000000000..523255e6b --- /dev/null +++ b/build-logic/application/build.gradle.kts @@ -0,0 +1,16 @@ +plugins { + `kotlin-dsl` +} + +dependencies { + compileOnly(core.gradle.build.tools) +} + +gradlePlugin { + plugins { + register("infomaniakApplication") { + id = "com.infomaniak.core.application" + implementationClass = "com.infomaniak.core.application.InfomaniakApplicationPlugin" + } + } +} diff --git a/build-logic/application/src/main/kotlin/com/infomaniak/core/application/InfomaniakApplicationPlugin.kt b/build-logic/application/src/main/kotlin/com/infomaniak/core/application/InfomaniakApplicationPlugin.kt new file mode 100644 index 000000000..2bd712fdc --- /dev/null +++ b/build-logic/application/src/main/kotlin/com/infomaniak/core/application/InfomaniakApplicationPlugin.kt @@ -0,0 +1,54 @@ +/* + * Infomaniak Core - Android + * Copyright (C) 2025 Infomaniak Network SA + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.infomaniak.core.application + +import com.android.build.api.dsl.CommonExtension +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure +import java.io.File + +/** + * Configures the shared debug signing certificate for Android application modules. + */ +class InfomaniakApplicationPlugin : Plugin { + + override fun apply(target: Project) { + val keystoreFile = listOf( + target.rootProject.file("debug.keystore"), + target.rootProject.file("Core/config/debug.keystore"), + target.rootProject.file("config/debug.keystore"), + ).firstOrNull(File::exists) + + requireNotNull(keystoreFile) { + "Shared debug keystore not found. Expected it under /debug.keystore or Core/config/debug.keystore." + } + + target.rootProject.allprojects { + plugins.withId("com.android.application") { + extensions.configure> ("android") { + signingConfigs { + getByName("debug") { + storeFile = keystoreFile + } + } + } + } + } + } +} diff --git a/build-logic/settings.gradle.kts b/build-logic/settings.gradle.kts index 43e6182f6..6244556b7 100644 --- a/build-logic/settings.gradle.kts +++ b/build-logic/settings.gradle.kts @@ -15,4 +15,5 @@ rootProject.name = "build-logic" include( ":composite", ":composeLint", + ":application", ) diff --git a/config/debug.keystore b/config/debug.keystore new file mode 100644 index 000000000..4b2ff4f49 Binary files /dev/null and b/config/debug.keystore differ diff --git a/gradle/core.versions.toml b/gradle/core.versions.toml index 648761eb0..1d124c557 100644 --- a/gradle/core.versions.toml +++ b/gradle/core.versions.toml @@ -243,6 +243,7 @@ android-library = { id = "com.android.library", version.ref = "agp" } android-kmp-library = { id = "com.android.kotlin.multiplatform.library", version.ref = "agp" } compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" } compose-lint = { id = "com.infomaniak.core.compose.lint" } +infomaniak-application = { id = "com.infomaniak.core.application" } dagger-hilt = { id = "com.google.dagger.hilt.android", version.ref = "hiltAndroid" } google-services = { id = "com.google.gms.google-services", version.ref = "googleServices" } kapt = { id = "org.jetbrains.kotlin.kapt", version.ref = "kotlin" }