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
3 changes: 0 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ buildscript {
google()
mavenCentral()
}
dependencies {
classpath(libs.secrets.gradle.plugin)
}
}

val localPropertiesFile = rootProject.file("local.properties")
Expand Down
39 changes: 0 additions & 39 deletions example-app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
18 changes: 0 additions & 18 deletions example-app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,6 @@
android:theme="@style/Theme.OverlayTest"
tools:targetApi="35">

<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${GOOGLE_MAPS_API_KEY}" />

<meta-data
android:name="ARCGIS_API_KEY"
android:value="${ARCGIS_API_KEY}" />

<meta-data
android:name="MAPBOX_ACCESS_TOKEN"
android:value="${MAPBOX_ACCESS_TOKEN}" />

<meta-data
android:name="HERE_ACCESS_KEY_ID"
android:value="${HERE_ACCESS_KEY_ID}" />
<meta-data
android:name="HERE_ACCESS_KEY_SECRET"
android:value="${HERE_ACCESS_KEY_SECRET}" />

<activity
android:name=".MainActivity"
Expand Down
3 changes: 0 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ runner = "1.6.2"
mapboxAndroid = "11.14.3"
playServicesMaps = "19.2.0"

secretsGradlePlugin = "2.0.1"

arcgisMapsKotlin = "200.7.0"
vectordrawable = "1.2.0"
firebaseBom = "34.2.0"
Expand Down Expand Up @@ -76,7 +74,6 @@ arcgis-maps-kotlin-toolkit-authentication = { group = "com.esri", name = "arcgis
junit = { group = "junit", name = "junit", version.ref = "junit" }
androidx-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
androidx-espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
secrets-gradle-plugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "secretsGradlePlugin" }
androidx-vectordrawable = { group = "androidx.vectordrawable", name = "vectordrawable", version.ref = "vectordrawable" }

# Firebase
Expand Down
76 changes: 76 additions & 0 deletions mapconductor-for-arcgis/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ARCGIS_API_KEY exists in secrets.properties
val secretsContent = secretsFile.readText()
if (!secretsContent.contains("ARCGIS_API_KEY=")) {
secretsFile.appendText("ARCGIS_API_KEY=ARCGIS_API_KEY\n")
println("Added ARCGIS_API_KEY to secrets.properties")
}

// Ensure ARCGIS_API_KEY exists in local.defaults.properties
val defaultsContent = defaultsFile.readText()
if (!defaultsContent.contains("ARCGIS_API_KEY=")) {
defaultsFile.appendText("ARCGIS_API_KEY=ARCGIS_API_KEY\n")
println("Added ARCGIS_API_KEY to local.defaults.properties")
}
}
}

// Function to read API key from secrets.properties
fun getArcgisApiKey(): 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("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()
Expand All @@ -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 {
Expand Down Expand Up @@ -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())
Expand Down
10 changes: 9 additions & 1 deletion mapconductor-for-arcgis/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest></manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<meta-data
android:name="ARCGIS_API_KEY"
android:value="${ARCGIS_API_KEY}" />

</application>
</manifest>
77 changes: 77 additions & 0 deletions mapconductor-for-googlemaps/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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 {
Expand Down Expand Up @@ -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())
Expand Down
9 changes: 7 additions & 2 deletions mapconductor-for-googlemaps/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
<application>
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="${GOOGLE_MAPS_API_KEY}" />
</application>
</manifest>
Loading