diff --git a/build.gradle.kts b/build.gradle.kts
index 0039fd6c..0d2baf80 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -14,9 +14,6 @@ buildscript {
google()
mavenCentral()
}
- dependencies {
- classpath(libs.secrets.gradle.plugin)
- }
}
val localPropertiesFile = rootProject.file("local.properties")
diff --git a/example-app/build.gradle.kts b/example-app/build.gradle.kts
index e8608290..4cb9db41 100644
--- a/example-app/build.gradle.kts
+++ b/example-app/build.gradle.kts
@@ -1,40 +1,25 @@
plugins {
-
alias(libs.plugins.android.application)
-
alias(libs.plugins.kotlin.android)
-
alias(libs.plugins.kotlin.compose)
-
- id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin")
-
id("org.jlleitschuh.gradle.ktlint")
}
ktlint {
-
android.set(true)
-
reporters {
-
reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.PLAIN)
-
reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.CHECKSTYLE)
}
}
android {
-
namespace = "com.mapconductor.example"
-
compileSdk = project.property("compileSdk").toString().toInt()
defaultConfig {
-
applicationId = "com.mapconductor.example"
-
minSdk = project.property("minSdk").toString().toInt()
-
targetSdk = project.property("targetSdk").toString().toInt()
ndk {
abiFilters += listOf("arm64-v8a")
@@ -44,23 +29,18 @@ android {
}
versionCode = 5
-
versionName = "1.0.4"
-
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
composeOptions {
-
kotlinCompilerExtensionVersion =
-
project.property("kotlinCompilerExtensionVersion").toString()
}
buildTypes {
debug {
-
isMinifyEnabled = false
proguardFiles(
@@ -150,25 +130,6 @@ android {
}
}
-secrets {
-
- // To add your Maps API key to this project:
-
- // 1. If the secrets.properties file does not exist, create it in the same folder as the local.properties file.
-
- // 2. Add this line, where YOUR_API_KEY is your API key:
-
- // MAPS_API_KEY=YOUR_API_KEY
-
- propertiesFileName = "secrets.properties"
-
- // A properties file containing default secret values. This file can be
-
- // checked in version control.
-
- defaultPropertiesFileName = "local.defaults.properties"
-}
-
dependencies {
implementation(libs.androidx.core.ktx)
diff --git a/example-app/src/main/AndroidManifest.xml b/example-app/src/main/AndroidManifest.xml
index ad65088c..23730101 100644
--- a/example-app/src/main/AndroidManifest.xml
+++ b/example-app/src/main/AndroidManifest.xml
@@ -18,24 +18,6 @@
android:theme="@style/Theme.OverlayTest"
tools:targetApi="35">
-
-
-
-
-
-
-
-
+ if (line.startsWith("ARCGIS_API_KEY=")) {
+ val value = line.substringAfter("=").trim()
+ if (value.isNotEmpty() && value != "ARCGIS_API_KEY") {
+ return value
+ }
+ }
+ }
+ }
+
+ // Fallback to local.defaults.properties
+ if (defaultsFile.exists()) {
+ val content = defaultsFile.readText()
+ content.lines().forEach { line ->
+ if (line.startsWith("ARCGIS_API_KEY=")) {
+ val value = line.substringAfter("=").trim()
+ if (value.isNotEmpty()) {
+ return value
+ }
+ }
+ }
+ }
+
+ // Return placeholder if no valid key found
+ return "ARCGIS_API_KEY"
+}
android {
namespace = "com.mapconductor.arcgis"
compileSdk = project.property("compileSdk").toString().toInt()
@@ -24,6 +92,9 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
+
+ // Set the ArcGIS API key from secrets.properties
+ manifestPlaceholders["ARCGIS_API_KEY"] = getArcgisApiKey()
}
buildFeatures {
@@ -51,6 +122,11 @@ android {
)
}
}
+
+ // Run ensureSecretsFiles before processing manifests
+ tasks.matching { it.name.contains("process") && it.name.contains("Manifest") }.configureEach {
+ dependsOn("ensureSecretsFiles")
+ }
compileOptions {
sourceCompatibility = JavaVersion.toVersion(project.property("javaVersion").toString())
targetCompatibility = JavaVersion.toVersion(project.property("javaVersion").toString())
diff --git a/mapconductor-for-arcgis/src/main/AndroidManifest.xml b/mapconductor-for-arcgis/src/main/AndroidManifest.xml
index 78c3e858..06e5f3c4 100644
--- a/mapconductor-for-arcgis/src/main/AndroidManifest.xml
+++ b/mapconductor-for-arcgis/src/main/AndroidManifest.xml
@@ -1,2 +1,10 @@
-
+
+
+
+
+
+
+
diff --git a/mapconductor-for-googlemaps/build.gradle.kts b/mapconductor-for-googlemaps/build.gradle.kts
index c7eabe7c..b168597c 100644
--- a/mapconductor-for-googlemaps/build.gradle.kts
+++ b/mapconductor-for-googlemaps/build.gradle.kts
@@ -15,6 +15,75 @@ ktlint {
}
}
+// Task to create secrets.properties in root project if it doesn't exist
+tasks.register("ensureSecretsFiles") {
+ doFirst {
+ val secretsFile = rootProject.file("secrets.properties")
+ val defaultsFile = rootProject.file("local.defaults.properties")
+
+ // Create secrets.properties if it doesn't exist
+ if (!secretsFile.exists()) {
+ secretsFile.createNewFile()
+ println("Created secrets.properties in root project")
+ }
+
+ // Create local.defaults.properties if it doesn't exist
+ if (!defaultsFile.exists()) {
+ defaultsFile.createNewFile()
+ println("Created local.defaults.properties in root project")
+ }
+
+ // Ensure GOOGLE_MAPS_API_KEY exists in secrets.properties
+ val secretsContent = secretsFile.readText()
+ if (!secretsContent.contains("GOOGLE_MAPS_API_KEY=")) {
+ secretsFile.appendText("GOOGLE_MAPS_API_KEY=GOOGLE_MAPS_API_KEY\n")
+ println("Added GOOGLE_MAPS_API_KEY to secrets.properties")
+ }
+
+ // Ensure GOOGLE_MAPS_API_KEY exists in local.defaults.properties
+ val defaultsContent = defaultsFile.readText()
+ if (!defaultsContent.contains("GOOGLE_MAPS_API_KEY=")) {
+ defaultsFile.appendText("GOOGLE_MAPS_API_KEY=GOOGLE_MAPS_API_KEY\n")
+ println("Added GOOGLE_MAPS_API_KEY to local.defaults.properties")
+ }
+ }
+}
+
+// Function to read API key from secrets.properties
+fun getGoogleMapsApiKey(): String {
+ val secretsFile = rootProject.file("secrets.properties")
+ val defaultsFile = rootProject.file("local.defaults.properties")
+
+ // Try to read from secrets.properties first
+ if (secretsFile.exists()) {
+ val content = secretsFile.readText()
+ content.lines().forEach { line ->
+ if (line.startsWith("GOOGLE_MAPS_API_KEY=")) {
+ val value = line.substringAfter("=").trim()
+ if (value.isNotEmpty() && value != "GOOGLE_MAPS_API_KEY") {
+ return value
+ }
+ }
+ }
+ }
+
+ // Fallback to local.defaults.properties
+ if (defaultsFile.exists()) {
+ val content = defaultsFile.readText()
+ content.lines().forEach { line ->
+ if (line.startsWith("GOOGLE_MAPS_API_KEY=")) {
+ val value = line.substringAfter("=").trim()
+ if (value.isNotEmpty()) {
+ return value
+ }
+ }
+ }
+ }
+
+ // Return placeholder if no valid key found
+ return "GOOGLE_MAPS_API_KEY"
+}
+
android {
namespace = "com.mapconductor.googlemaps"
compileSdk = project.property("compileSdk").toString().toInt()
@@ -24,6 +93,9 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
+
+ // Set the Google Maps API key from secrets.properties
+ manifestPlaceholders["GOOGLE_MAPS_API_KEY"] = getGoogleMapsApiKey()
}
buildFeatures {
@@ -51,6 +123,11 @@ android {
)
}
}
+
+ // Run ensureSecretsFiles before processing manifests
+ tasks.matching { it.name.contains("process") && it.name.contains("Manifest") }.configureEach {
+ dependsOn("ensureSecretsFiles")
+ }
compileOptions {
sourceCompatibility = JavaVersion.toVersion(project.property("javaVersion").toString())
targetCompatibility = JavaVersion.toVersion(project.property("javaVersion").toString())
diff --git a/mapconductor-for-googlemaps/src/main/AndroidManifest.xml b/mapconductor-for-googlemaps/src/main/AndroidManifest.xml
index 44008a43..118224ea 100644
--- a/mapconductor-for-googlemaps/src/main/AndroidManifest.xml
+++ b/mapconductor-for-googlemaps/src/main/AndroidManifest.xml
@@ -1,4 +1,9 @@
-
+
-
\ No newline at end of file
+
+
+
+
diff --git a/mapconductor-for-here/build.gradle.kts b/mapconductor-for-here/build.gradle.kts
index 60f72572..43628872 100644
--- a/mapconductor-for-here/build.gradle.kts
+++ b/mapconductor-for-here/build.gradle.kts
@@ -15,6 +15,116 @@ ktlint {
}
}
+// Task to create secrets.properties in root project if it doesn't exist
+tasks.register("ensureSecretsFiles") {
+ doFirst {
+ val secretsFile = rootProject.file("secrets.properties")
+ val defaultsFile = rootProject.file("local.defaults.properties")
+
+ // Create secrets.properties if it doesn't exist
+ if (!secretsFile.exists()) {
+ secretsFile.createNewFile()
+ println("Created secrets.properties in root project")
+ }
+
+ // Create local.defaults.properties if it doesn't exist
+ if (!defaultsFile.exists()) {
+ defaultsFile.createNewFile()
+ println("Created local.defaults.properties in root project")
+ }
+
+ // Ensure HERE_ACCESS_KEY_ID and HERE_ACCESS_KEY_SECRET exist in secrets.properties
+ val secretsContent = secretsFile.readText()
+ if (!secretsContent.contains("HERE_ACCESS_KEY_ID=")) {
+ secretsFile.appendText("HERE_ACCESS_KEY_ID=HERE_ACCESS_KEY_ID\n")
+ println("Added HERE_ACCESS_KEY_ID to secrets.properties")
+ }
+ if (!secretsContent.contains("HERE_ACCESS_KEY_SECRET=")) {
+ secretsFile.appendText("HERE_ACCESS_KEY_SECRET=HERE_ACCESS_KEY_SECRET\n")
+ println("Added HERE_ACCESS_KEY_SECRET to secrets.properties")
+ }
+
+ // Ensure HERE_ACCESS_KEY_ID and HERE_ACCESS_KEY_SECRET exist in local.defaults.properties
+ val defaultsContent = defaultsFile.readText()
+ if (!defaultsContent.contains("HERE_ACCESS_KEY_ID=")) {
+ defaultsFile.appendText("HERE_ACCESS_KEY_ID=HERE_ACCESS_KEY_ID\n")
+ println("Added HERE_ACCESS_KEY_ID to local.defaults.properties")
+ }
+ if (!defaultsContent.contains("HERE_ACCESS_KEY_SECRET=")) {
+ defaultsFile.appendText("HERE_ACCESS_KEY_SECRET=HERE_ACCESS_KEY_SECRET\n")
+ println("Added HERE_ACCESS_KEY_SECRET to local.defaults.properties")
+ }
+ }
+}
+
+// Functions to read API keys from secrets.properties
+fun getHereAccessKeyId(): String {
+ val secretsFile = rootProject.file("secrets.properties")
+ val defaultsFile = rootProject.file("local.defaults.properties")
+
+ // Try to read from secrets.properties first
+ if (secretsFile.exists()) {
+ val content = secretsFile.readText()
+ content.lines().forEach { line ->
+ if (line.startsWith("HERE_ACCESS_KEY_ID=")) {
+ val value = line.substringAfter("=").trim()
+ if (value.isNotEmpty() && value != "HERE_ACCESS_KEY_ID") {
+ return value
+ }
+ }
+ }
+ }
+
+ // Fallback to local.defaults.properties
+ if (defaultsFile.exists()) {
+ val content = defaultsFile.readText()
+ content.lines().forEach { line ->
+ if (line.startsWith("HERE_ACCESS_KEY_ID=")) {
+ val value = line.substringAfter("=").trim()
+ if (value.isNotEmpty()) {
+ return value
+ }
+ }
+ }
+ }
+
+ // Return placeholder if no valid key found
+ return "HERE_ACCESS_KEY_ID"
+}
+
+fun getHereAccessKeySecret(): String {
+ val secretsFile = rootProject.file("secrets.properties")
+ val defaultsFile = rootProject.file("local.defaults.properties")
+
+ // Try to read from secrets.properties first
+ if (secretsFile.exists()) {
+ val content = secretsFile.readText()
+ content.lines().forEach { line ->
+ if (line.startsWith("HERE_ACCESS_KEY_SECRET=")) {
+ val value = line.substringAfter("=").trim()
+ if (value.isNotEmpty() && value != "HERE_ACCESS_KEY_SECRET") {
+ return value
+ }
+ }
+ }
+ }
+
+ // Fallback to local.defaults.properties
+ if (defaultsFile.exists()) {
+ val content = defaultsFile.readText()
+ content.lines().forEach { line ->
+ if (line.startsWith("HERE_ACCESS_KEY_SECRET=")) {
+ val value = line.substringAfter("=").trim()
+ if (value.isNotEmpty()) {
+ return value
+ }
+ }
+ }
+ }
+
+ // Return placeholder if no valid key found
+ return "HERE_ACCESS_KEY_SECRET"
+}
android {
namespace = "com.mapconductor.here"
compileSdk = project.property("compileSdk").toString().toInt()
@@ -24,6 +134,10 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
+
+ // Set the HERE API keys from secrets.properties
+ manifestPlaceholders["HERE_ACCESS_KEY_ID"] = getHereAccessKeyId()
+ manifestPlaceholders["HERE_ACCESS_KEY_SECRET"] = getHereAccessKeySecret()
}
buildFeatures {
@@ -51,6 +165,11 @@ android {
)
}
}
+
+ // Run ensureSecretsFiles before processing manifests
+ tasks.matching { it.name.contains("process") && it.name.contains("Manifest") }.configureEach {
+ dependsOn("ensureSecretsFiles")
+ }
compileOptions {
sourceCompatibility = JavaVersion.toVersion(project.property("javaVersion").toString())
targetCompatibility = JavaVersion.toVersion(project.property("javaVersion").toString())
diff --git a/mapconductor-for-here/src/main/AndroidManifest.xml b/mapconductor-for-here/src/main/AndroidManifest.xml
index 78c3e858..da77d7df 100644
--- a/mapconductor-for-here/src/main/AndroidManifest.xml
+++ b/mapconductor-for-here/src/main/AndroidManifest.xml
@@ -1,2 +1,11 @@
-
+
+
+
+
+
+
diff --git a/mapconductor-for-mapbox/build.gradle.kts b/mapconductor-for-mapbox/build.gradle.kts
index 60b590ea..37edfe8b 100644
--- a/mapconductor-for-mapbox/build.gradle.kts
+++ b/mapconductor-for-mapbox/build.gradle.kts
@@ -15,6 +15,74 @@ ktlint {
}
}
+// Task to create secrets.properties in root project if it doesn't exist
+tasks.register("ensureSecretsFiles") {
+ doFirst {
+ val secretsFile = rootProject.file("secrets.properties")
+ val defaultsFile = rootProject.file("local.defaults.properties")
+
+ // Create secrets.properties if it doesn't exist
+ if (!secretsFile.exists()) {
+ secretsFile.createNewFile()
+ println("Created secrets.properties in root project")
+ }
+
+ // Create local.defaults.properties if it doesn't exist
+ if (!defaultsFile.exists()) {
+ defaultsFile.createNewFile()
+ println("Created local.defaults.properties in root project")
+ }
+
+ // Ensure MAPBOX_ACCESS_TOKEN exists in secrets.properties
+ val secretsContent = secretsFile.readText()
+ if (!secretsContent.contains("MAPBOX_ACCESS_TOKEN=")) {
+ secretsFile.appendText("MAPBOX_ACCESS_TOKEN=MAPBOX_ACCESS_TOKEN\n")
+ println("Added MAPBOX_ACCESS_TOKEN to secrets.properties")
+ }
+
+ // Ensure MAPBOX_ACCESS_TOKEN exists in local.defaults.properties
+ val defaultsContent = defaultsFile.readText()
+ if (!defaultsContent.contains("MAPBOX_ACCESS_TOKEN=")) {
+ defaultsFile.appendText("MAPBOX_ACCESS_TOKEN=MAPBOX_ACCESS_TOKEN\n")
+ println("Added MAPBOX_ACCESS_TOKEN to local.defaults.properties")
+ }
+ }
+}
+
+// Function to read API key from secrets.properties
+fun getMapboxAccessToken(): String {
+ val secretsFile = rootProject.file("secrets.properties")
+ val defaultsFile = rootProject.file("local.defaults.properties")
+
+ // Try to read from secrets.properties first
+ if (secretsFile.exists()) {
+ val content = secretsFile.readText()
+ content.lines().forEach { line ->
+ if (line.startsWith("MAPBOX_ACCESS_TOKEN=")) {
+ val value = line.substringAfter("=").trim()
+ if (value.isNotEmpty() && value != "MAPBOX_ACCESS_TOKEN") {
+ return value
+ }
+ }
+ }
+ }
+
+ // Fallback to local.defaults.properties
+ if (defaultsFile.exists()) {
+ val content = defaultsFile.readText()
+ content.lines().forEach { line ->
+ if (line.startsWith("MAPBOX_ACCESS_TOKEN=")) {
+ val value = line.substringAfter("=").trim()
+ if (value.isNotEmpty()) {
+ return value
+ }
+ }
+ }
+ }
+
+ // Return placeholder if no valid key found
+ return "MAPBOX_ACCESS_TOKEN"
+}
android {
namespace = "com.mapconductor.mapbox"
compileSdk = project.property("compileSdk").toString().toInt()
@@ -24,6 +92,9 @@ android {
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")
+
+ // Set the Mapbox access token from secrets.properties
+ manifestPlaceholders["MAPBOX_ACCESS_TOKEN"] = getMapboxAccessToken()
}
buildFeatures {
@@ -50,6 +121,11 @@ android {
)
}
}
+
+ // Run ensureSecretsFiles before processing manifests
+ tasks.matching { it.name.contains("process") && it.name.contains("Manifest") }.configureEach {
+ dependsOn("ensureSecretsFiles")
+ }
compileOptions {
sourceCompatibility = JavaVersion.toVersion(project.property("javaVersion").toString())
targetCompatibility = JavaVersion.toVersion(project.property("javaVersion").toString())
diff --git a/mapconductor-for-mapbox/src/main/AndroidManifest.xml b/mapconductor-for-mapbox/src/main/AndroidManifest.xml
index 78c3e858..ab85bb72 100644
--- a/mapconductor-for-mapbox/src/main/AndroidManifest.xml
+++ b/mapconductor-for-mapbox/src/main/AndroidManifest.xml
@@ -1,2 +1,8 @@
-
+
+
+
+
+