Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support Secrets Gradle plugin #2093

Merged
merged 4 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ mifosng-android/src/main/assets/crashlytics-build.properties
android-client.iml
mifosng-android/mifosng-android.iml
*.hprof
android-client.iml
android-client.iml
/secrets.properties
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ plugins {
alias(libs.plugins.hilt) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.androidx.navigation) apply false
alias(libs.plugins.secrets) apply false
}
9 changes: 9 additions & 0 deletions core/common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.secrets)
}

android {
Expand Down Expand Up @@ -32,6 +33,14 @@ android {
kotlinOptions {
jvmTarget = "17"
}

buildFeatures {
buildConfig = true
}
}

secrets {
defaultPropertiesFileName = "secrets.defaults.properties"
}

dependencies {
Expand Down
14 changes: 9 additions & 5 deletions core/common/src/main/java/com/mifos/core/common/utils/BaseUrl.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
package com.mifos.core.common.utils

import com.mifos.core.common.BuildConfig

object BaseUrl {

private val configs = BuildConfig.DEMO_SERVER_CONFIG.split(",")

// "/" in the last of the base url always

const val PROTOCOL_HTTPS = "https://"
val PROTOCOL_HTTPS = configs[0]

const val API_ENDPOINT = "demo.mifos.community"
val API_ENDPOINT = configs[1]

const val API_PATH = "/fineract-provider/api/v1/"
val API_PATH = configs[2]

const val PORT = "80"
val PORT = configs[3]

const val TENANT = "default"
val TENANT = configs[4]
}
21 changes: 21 additions & 0 deletions core/network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@ plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.hilt)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.secrets)
id(libs.plugins.kotlin.parcelize.get().pluginId)
id(libs.plugins.kotlin.kapt.get().pluginId)
}

val protocol = project.properties["PROTOCOL_HTTPS"].toString()
Copy link
Member

@therajanmaurya therajanmaurya May 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove these Build config fields

val apiEndpoint = project.properties["API_ENDPOINT"].toString()
val apiPath = project.properties["API_PATH"].toString()
val port = project.properties["PORT"].toString()
val tenant = project.properties["TENANT"].toString()

val serverConfig = "$protocol,$apiEndpoint,$apiPath,$port,$tenant"

android {
namespace = "com.mifos.core.network"
compileSdk = 34
Expand All @@ -16,6 +25,8 @@ android {

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles("consumer-rules.pro")

buildConfigField("String", "SERVER_CONFIG", "\"$serverConfig\"")
}

buildTypes {
Expand All @@ -27,13 +38,23 @@ android {
)
}
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlinOptions {
jvmTarget = "17"
}

buildFeatures {
buildConfig = true
}
}

secrets {
defaultPropertiesFileName = "secrets.defaults.properties"
}

dependencies {
Expand Down
11 changes: 7 additions & 4 deletions core/network/src/main/java/com/mifos/core/network/BaseUrl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ package com.mifos.core.network
* @author fomenkoo
*/
class BaseUrl {

// "/" in the last of the base url always
companion object {
const val PROTOCOL_HTTPS = "https://"
const val API_ENDPOINT = "demo.mifos.community"
const val API_PATH = "/fineract-provider/api/v1/"
const val PORT = "80"
private val configs = BuildConfig.SERVER_CONFIG.split(",")

val PROTOCOL_HTTPS = configs[0]
val API_ENDPOINT = configs[1]
val API_PATH = configs[2]
val PORT = configs[3]
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx6g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:MaxMetaspaceSize=1g

# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
Expand Down
5 changes: 5 additions & 0 deletions mifosng-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ plugins {
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.hilt)
alias(libs.plugins.secrets)
id(libs.plugins.kotlin.parcelize.get().pluginId)
id(libs.plugins.kotlin.kapt.get().pluginId)
}
Expand Down Expand Up @@ -118,6 +119,10 @@ android {
}
}

secrets {
defaultPropertiesFileName = "secrets.defaults.properties"
}

dependencies {

implementation(project(":feature:auth"))
Expand Down
2 changes: 1 addition & 1 deletion mifosng-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

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

<activity
android:name=".activity.splashscreen.SplashScreenActivity"
Expand Down
30 changes: 30 additions & 0 deletions secrets.defaults.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

# Default values for the Mifos API
# You can override these values by creating secrets.properties file in the root directory of the project

PROTOCOL_HTTPS = https://
therajanmaurya marked this conversation as resolved.
Show resolved Hide resolved

API_ENDPOINT = demo.mifos.community

API_PATH = /fineract-provider/api/v1/

PORT = 80

TENANT = default

# Provide GEO API Key
GEO_API_KEY = AIzaSyAZTZqvDGyyw21z2Ee7N-dE_WuZQwKL0bs

DEMO_SERVER_CONFIG = "https://,demo.mifos.community,/fineract-provider/api/v1/,80,default"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is right way, we are going to keep this only, remove rest of it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also add a comment to DEMO_SERVER_CONFIG

#Update DEMO_SERVER_CONFIG according below mentioned your server config
#PROTOCOL_HTTPS = https://
#API_ENDPOINT = demo.mifos.community
#API_PATH = /fineract-provider/api/v1/
#PORT = 80
#TENANT = default


#SERVER_CONFIG = "${PROTOCOL_HTTPS}"
#
#SERVER_CONFIGs = '${PROTOCOL_HTTPS}'
#
#SERVER_CONFIGt = '\PROTOCOL_HTTPS\'
#
#SERVER_CONFIGD = \${PROTOCOL_HTTPS}
#
#SERVER_CONFIGe = $PROTOCOL_HTTPS

#SERVER_CONFIGf = "\"{$PROTOCOL_HTTPS}\""
Loading