Skip to content

Commit

Permalink
chore: move api keys and client url's to new apikeys.properties to …
Browse files Browse the repository at this point in the history
…respect best practices

Moved API keys for Supabase and client URLs for Supabase and PowerSync to a new file called `apikeys.properties` instead of having them in `local.properties`.
This respects the Gradle properties files recommendations [here](https://developer.android.com/build#properties-files), saying:

> Caution: The local.properties file is reserved for properties specific to the Android Gradle plugin. Putting your own values in this file can cause problems. If you need to define your own local properties, create a separate properties file and manually load it.

!! This `apikeys.properties` should never be uploaded to VCS !!
  • Loading branch information
charliemangano committed Nov 9, 2024
1 parent 037741f commit 87f6c52
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.DS_Store
.gradle
/local.properties
/apikeys.properties
/build
/captures
.externalNativeBuild
Expand Down
12 changes: 6 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ android {
namespace = "com.android.periodpals"
compileSdk = 34

// Load the API key from local.properties
val localProperties = Properties()
val localPropertiesFile = rootProject.file("local.properties")
// Load the API key from apikeys.properties
val apikeysProperties = Properties()
val localPropertiesFile = rootProject.file("apikeys.properties")
if (localPropertiesFile.exists()) {
localProperties.load(FileInputStream(localPropertiesFile))
apikeysProperties.load(FileInputStream(localPropertiesFile))
}
val supabaseUrl = localProperties.getProperty("SUPABASE_URL")
val supabaseKey = localProperties.getProperty("SUPABASE_KEY")
val supabaseUrl = apikeysProperties.getProperty("SUPABASE_URL") ?: ""
val supabaseKey = apikeysProperties.getProperty("SUPABASE_KEY") ?: ""

defaultConfig {
applicationId = "com.android.periodpals"
Expand Down

0 comments on commit 87f6c52

Please sign in to comment.