|
| 1 | +import java.util.Properties |
| 2 | + |
| 3 | +plugins { |
| 4 | + alias(libs.plugins.android.application) |
| 5 | + alias(libs.plugins.kotlin.compose) |
| 6 | +} |
| 7 | + |
| 8 | +// Read local.properties at configure time so we can surface CIAM_* fields into |
| 9 | +// BuildConfig (read at runtime) and into AndroidManifest.xml (intent filter). |
| 10 | +val localProps = Properties().apply { |
| 11 | + val f = rootProject.file("local.properties") |
| 12 | + if (f.exists()) f.inputStream().use { load(it) } |
| 13 | +} |
| 14 | +fun localProp(key: String): String = localProps.getProperty(key, "") |
| 15 | + |
| 16 | +android { |
| 17 | + namespace = "com.secureauth.quickstart" |
| 18 | + compileSdk = 36 |
| 19 | + |
| 20 | + defaultConfig { |
| 21 | + applicationId = "com.secureauth.quickstart.android.login" |
| 22 | + minSdk = 26 |
| 23 | + targetSdk = 36 |
| 24 | + versionCode = 1 |
| 25 | + versionName = "1.0" |
| 26 | + |
| 27 | + buildConfigField("String", "CIAM_CLIENT_ID", "\"${localProp("CLIENT_ID")}\"") |
| 28 | + buildConfigField("String", "CIAM_ISSUER_HOST", "\"${localProp("ISSUER_HOST")}\"") |
| 29 | + buildConfigField("String", "CIAM_ISSUER_PATH", "\"${localProp("ISSUER_PATH")}\"") |
| 30 | + buildConfigField("String", "CIAM_REDIRECT_SCHEME", "\"${localProp("REDIRECT_SCHEME")}\"") |
| 31 | + buildConfigField("String", "CIAM_SCOPES", "\"${localProp("SCOPES")}\"") |
| 32 | + |
| 33 | + // AppAuth-Android's RedirectUriReceiverActivity intent filter is parameterised |
| 34 | + // on ${appAuthRedirectScheme}. Tying both to the same source value (the |
| 35 | + // REDIRECT_SCHEME entry in local.properties) prevents drift between code and |
| 36 | + // manifest. |
| 37 | + manifestPlaceholders["appAuthRedirectScheme"] = localProp("REDIRECT_SCHEME") |
| 38 | + } |
| 39 | + |
| 40 | + buildFeatures { |
| 41 | + compose = true |
| 42 | + buildConfig = true |
| 43 | + } |
| 44 | + |
| 45 | + compileOptions { |
| 46 | + sourceCompatibility = JavaVersion.VERSION_21 |
| 47 | + targetCompatibility = JavaVersion.VERSION_21 |
| 48 | + isCoreLibraryDesugaringEnabled = false |
| 49 | + } |
| 50 | + |
| 51 | + buildTypes { |
| 52 | + debug { isMinifyEnabled = false } |
| 53 | + release { |
| 54 | + isMinifyEnabled = false |
| 55 | + proguardFiles( |
| 56 | + getDefaultProguardFile("proguard-android-optimize.txt"), |
| 57 | + "proguard-rules.pro", |
| 58 | + ) |
| 59 | + } |
| 60 | + } |
| 61 | +} |
| 62 | + |
| 63 | +dependencies { |
| 64 | + implementation(libs.appauth) |
| 65 | + |
| 66 | + implementation(libs.androidx.core.ktx) |
| 67 | + implementation(libs.androidx.activity.compose) |
| 68 | + implementation(libs.androidx.lifecycle.viewmodel.compose) |
| 69 | + |
| 70 | + val composeBom = platform(libs.androidx.compose.bom) |
| 71 | + implementation(composeBom) |
| 72 | + implementation(libs.androidx.compose.ui) |
| 73 | + implementation(libs.androidx.compose.ui.tooling.preview) |
| 74 | + implementation(libs.androidx.compose.material3) |
| 75 | + debugImplementation(libs.androidx.compose.ui.tooling) |
| 76 | + |
| 77 | + testImplementation(libs.junit) |
| 78 | + // org.json.JSONObject is part of the Android framework (android.jar) but stubbed |
| 79 | + // out in pure-JVM unit tests. The standalone Apache org.json JAR provides a |
| 80 | + // working implementation for unit tests; production code uses the framework one. |
| 81 | + testImplementation(libs.org.json) |
| 82 | +} |
0 commit comments