From cc57c1be2126771708fa41a24a3ec5c3baf4e5a7 Mon Sep 17 00:00:00 2001 From: Shawn Cicoria Date: Mon, 21 Aug 2023 07:55:31 -0400 Subject: [PATCH 1/4] externalize secrets use local.properties --- src/android/CommandSystem/build.gradle | 6 +++++- src/android/app/build.gradle | 9 +++++++++ .../com/microsoft/commandsystemsample/MainActivity.kt | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/android/CommandSystem/build.gradle b/src/android/CommandSystem/build.gradle index af7480c3..bdd558e6 100644 --- a/src/android/CommandSystem/build.gradle +++ b/src/android/CommandSystem/build.gradle @@ -4,7 +4,11 @@ plugins { id 'maven-publish' } // So far I'm unable to get this to be set dynamically ... -project.ext.GRADLE_DOTNET_VERSION = "7.0.9" +//project.ext.GRADLE_DOTNET_VERSION = "7.0.9" +def localProperties = new Properties() +localProperties.load(new FileInputStream(rootProject.file("local.properties"))) +project.ext.GRADLE_DOTNET_VERSION = localProperties.getProperty("dotnet.version") + apply from: 'copyDependentBinaries.gradle' android { diff --git a/src/android/app/build.gradle b/src/android/app/build.gradle index dbb78e31..e9674ac8 100644 --- a/src/android/app/build.gradle +++ b/src/android/app/build.gradle @@ -3,6 +3,9 @@ plugins { id 'org.jetbrains.kotlin.android' } +def localProperties = new Properties() +localProperties.load(new FileInputStream(rootProject.file("local.properties"))) + android { namespace 'com.microsoft.commandsystemsample' compileSdk 33 @@ -18,7 +21,13 @@ android { } buildTypes { + debug { + buildConfigField("String", "SPEECH_KEY", "\"" + localProperties['speech.key'] + "\"") + buildConfigField("String", "SPEECH_REGION", "\"" + localProperties['speech.region'] + "\"") + } release { + buildConfigField("String", "SPEECH_KEY", "\"" + localProperties['speech.key'] + "\"") + buildConfigField("String", "SPEECH_REGION", "\"" + localProperties['speech.region'] + "\"") minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } diff --git a/src/android/app/src/main/java/com/microsoft/commandsystemsample/MainActivity.kt b/src/android/app/src/main/java/com/microsoft/commandsystemsample/MainActivity.kt index 183cb0f8..688f04b4 100644 --- a/src/android/app/src/main/java/com/microsoft/commandsystemsample/MainActivity.kt +++ b/src/android/app/src/main/java/com/microsoft/commandsystemsample/MainActivity.kt @@ -189,8 +189,8 @@ class MainActivity : AppCompatActivity() { } .configureSecrets { secrets: ConfigureSecretBuilder -> secrets - .addSecret("SPEECH_KEY","YOUR_KEY") - .addSecret("SPEECH_REGION","westus") + .addSecret("SPEECH_KEY", BuildConfig.SPEECH_KEY) + .addSecret("SPEECH_REGION", BuildConfig.SPEECH_REGION) .addSecret("SPEECH_DEFAULT_LANGUAGE","en-us") .addSecret("SPEECH_CUSTOM_RECOGNITION_ENDPOINT_ID","") .addSecret("SPEECH_CUSTOM_SYNTHESIS_ENDPOINT_ID","") From 515e3731f3f1d6ced862b6fde6bb872dbe3227a5 Mon Sep 17 00:00:00 2001 From: Shawn Cicoria Date: Mon, 21 Aug 2023 08:02:04 -0400 Subject: [PATCH 2/4] add example local.properties --- src/android/local.properties.example | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/android/local.properties.example diff --git a/src/android/local.properties.example b/src/android/local.properties.example new file mode 100644 index 00000000..f824d2e4 --- /dev/null +++ b/src/android/local.properties.example @@ -0,0 +1,15 @@ +## This file must *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# Location of the SDK. This is only used by Gradle. +# For customization when using a Version Control System, please read the +# header note. +#Mon Aug 21 05:54:26 EDT 2023 + +# the line sdk.dir should ALREADY be in your local.properties file... +sdk.dir=C\:\\Users\\scicoria\\AppData\\Local\\Android\\Sdk +# this needs to be set to the version present in C:\Program Files\dotnet\templates\7.???? +dotnet.version=7.0.10 +# this is the Language Service Speech Key and region +speech.key=?????????? +speech.region=westus3 From d27afc0e09ddc67a31bc77dbe070fabfc8dd7f7e Mon Sep 17 00:00:00 2001 From: Shawn Cicoria Date: Mon, 21 Aug 2023 08:17:32 -0400 Subject: [PATCH 3/4] add the clue settings too --- src/android/app/build.gradle | 9 +++++++++ .../com/microsoft/commandsystemsample/MainActivity.kt | 8 ++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/android/app/build.gradle b/src/android/app/build.gradle index e9674ac8..34675eda 100644 --- a/src/android/app/build.gradle +++ b/src/android/app/build.gradle @@ -21,13 +21,22 @@ android { } buildTypes { + // TODO: there has to be a way to be dry with these settings see https://developer.android.com/build/gradle-tips#share-properties-with-the-manifest debug { buildConfigField("String", "SPEECH_KEY", "\"" + localProperties['speech.key'] + "\"") buildConfigField("String", "SPEECH_REGION", "\"" + localProperties['speech.region'] + "\"") + buildConfigField("String", "CLU_KEY", "\"" + localProperties['clu.key'] + "\"") + buildConfigField("String", "CLU_ENDPOINT", "\"" + localProperties['clu.endpoint'] + "\"") + buildConfigField("String", "CLU_PROJECT_NAME", "\"" + localProperties['clu.project.name'] + "\"") + buildConfigField("String", "CLU_DEPLOYMENT_NAME", "\"" + localProperties['clu.deployment.name'] + "\"") } release { buildConfigField("String", "SPEECH_KEY", "\"" + localProperties['speech.key'] + "\"") buildConfigField("String", "SPEECH_REGION", "\"" + localProperties['speech.region'] + "\"") + buildConfigField("String", "CLU_KEY", "\"" + localProperties['clu.key'] + "\"") + buildConfigField("String", "CLU_ENDPOINT", "\"" + localProperties['clu.endpoint'] + "\"") + buildConfigField("String", "CLU_PROJECT_NAME", "\"" + localProperties['clu.project.name'] + "\"") + buildConfigField("String", "CLU_DEPLOYMENT_NAME", "\"" + localProperties['clu.deployment.name'] + "\"") minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } diff --git a/src/android/app/src/main/java/com/microsoft/commandsystemsample/MainActivity.kt b/src/android/app/src/main/java/com/microsoft/commandsystemsample/MainActivity.kt index 688f04b4..b13cdffe 100644 --- a/src/android/app/src/main/java/com/microsoft/commandsystemsample/MainActivity.kt +++ b/src/android/app/src/main/java/com/microsoft/commandsystemsample/MainActivity.kt @@ -194,10 +194,10 @@ class MainActivity : AppCompatActivity() { .addSecret("SPEECH_DEFAULT_LANGUAGE","en-us") .addSecret("SPEECH_CUSTOM_RECOGNITION_ENDPOINT_ID","") .addSecret("SPEECH_CUSTOM_SYNTHESIS_ENDPOINT_ID","") - .addSecret("CLU_KEY","YOUR_KEY") - .addSecret("CLU_ENDPOINT","https://internal-gm-dev.cognitiveservices.azure.com") - .addSecret("CLU_PROJECT_NAME","GM-Orchestrator") - .addSecret("CLU_DEPLOYMENT_NAME","2023-02-06") + .addSecret("CLU_KEY", BuildConfig.CLU_KEY) + .addSecret("CLU_ENDPOINT", BuildConfig.CLU_ENDPOINT) + .addSecret("CLU_PROJECT_NAME", BuildConfig.CLU_PROJECT_NAME) + .addSecret("CLU_DEPLOYMENT_NAME", BuildConfig.CLU_DEPLOYMENT_NAME) .addSecret("OPEN_AI_DEPLOYMENT","robch-southcentral-oai-txtdav002") .addSecret("OPEN_AI_ENDPOINT","https://robch-openai.openai.azure.com/") .addSecret("OPEN_AI_KEY","YOUR_KEY") From f6c4a9e873993f76f0c39978b47c66ec44140b43 Mon Sep 17 00:00:00 2001 From: Shawn Cicoria Date: Mon, 21 Aug 2023 08:20:14 -0400 Subject: [PATCH 4/4] amend the sample --- src/android/local.properties.example | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/android/local.properties.example b/src/android/local.properties.example index f824d2e4..11425ad9 100644 --- a/src/android/local.properties.example +++ b/src/android/local.properties.example @@ -13,3 +13,7 @@ dotnet.version=7.0.10 # this is the Language Service Speech Key and region speech.key=?????????? speech.region=westus3 +clu.key=???? +clu.endpoint=https://???.cognitiveservices.azure.com +clu.project.name=???? +clu.deployment.name=2023-02-06