0

I am using Azure AD B2C and need a different configuration file for each environment. I expect to have multiple B2C Tenants for my app. One for each environment. That means I need to alter my calls to reference different files. Currently I am calling:

PublicClientApplication.createMultipleAccountPublicClientApplication

Where the second parameter is an:

int configFileResourceId

I have been using:

R.raw.auth_config_multiple_account

But now I need to fold in additional environments. I handle most/all of my environment changes in the build.gradle like this:

    buildTypes {
        release { 
            buildConfigField "String", "SERVER_URL", '"xxx.xxxx.com"'
        }
        debug { 
            buildConfigField "String", "SERVER_URL", '"yyyy.yyy.com"'
        }
   }

But how do I do this while referencing the file itself? I can use the R.raw.auth_config_multiple_account from anywhere, but cannot from the build.gradle. How are others doing this? It's also very convenient to reference it from anywhere.

lcj
  • 1,355
  • 16
  • 37
  • I should have done a follow up. I figured out how to do it, which involved creating a different debug folder under src with another res/raw/auth_config_multiple_account – lcj Dec 21 '21 at 12:37

1 Answers1

0

• I would suggest you to reference the build.gradle file for any environment changes by calling the System.env(“variable name”) which works in gradle to get the path of any variable. Thus, this should get you the actual path of the folder which contains this file.

• So, to reference the build.gradle file in the variable, it needs to be exported to a location like as below shown as an example: -

home = System.getenv(‘HOME’) OR "${System.env.HOME}/something/plugins"

• Once it is exported and called as above, you can edit it for adding or modifying any of your environment changes in the build.gradle file.

Please find the below links for more information: -

how to use Environment Variables in Gradle build files?

Kartik Bhiwapurkar
  • 4,550
  • 2
  • 4
  • 9