Skip to content

Conversation

@edusperoni
Copy link
Contributor

@edusperoni edusperoni commented May 11, 2021

this adds the unitTesting gradle variable at build time.

Users can then do:

// app.gradle
android {
  defaultConfig {
    manifestPlaceholders = [isUnitTesting:"${unitTesting}"]
  }
}

// AndroidManifest.xml
	<application
                ....
		android:usesCleartextTraffic="${isUnitTesting}"
        >

More advanced users that are using things like android:networkSecurityConfig="@xml/network_security_config" can do:

def securityConfig = "@xml/network_security_config";
if(unitTesting.toBoolean()) { // toBoolean() is important!
  securityConfig = "@xml/my_insecure_security_config";
}
// app.gradle
android {
  defaultConfig {
    manifestPlaceholders = [securityConfig :"${securityConfig}"]
  }
}

// AndroidManifest.xml
	<application
                ....
		android:networkSecurityConfig="${securityConfig}"
        >

@cla-bot cla-bot bot added the cla: yes label May 11, 2021
@NathanWalker NathanWalker merged commit e80dd39 into master May 11, 2021
@NathanWalker NathanWalker deleted the feat/gradle-variable branch May 11, 2021 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants