Skip to content

feat: add unitTesting gradle variable #46

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

Merged
merged 1 commit into from
May 11, 2021
Merged

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.

2 participants