Skip to content

Commit f197b94

Browse files
committed
Move manifest generation to build.gradle
1 parent df8d577 commit f197b94

File tree

6 files changed

+28
-41
lines changed

6 files changed

+28
-41
lines changed

sample/android/app/build.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,21 @@ apply from: file("../../node_modules/react-native-vector-icons/fonts.gradle")
146146
apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
147147

148148
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
149+
150+
def properties = loadProperties()
151+
def storefrontDomain = properties.getProperty("STOREFRONT_DOMAIN")
152+
153+
if (!storefrontDomain) {
154+
println("**** Please add a .env file with STOREFRONT_DOMAIN set *****")
155+
}
156+
157+
task generateAndroidManifestFromTemplate {
158+
doLast {
159+
def templateFile = file('src/main/AndroidManifest.template.xml')
160+
def outputFile = file('src/main/AndroidManifest.xml')
161+
def content = templateFile.getText('UTF-8').replace('{{STOREFRONT_DOMAIN}}', "$storefrontDomain")
162+
outputFile.write(content, 'UTF-8')
163+
}
164+
}
165+
166+
preBuild.dependsOn(generateAndroidManifestFromTemplate)

sample/android/app/src/main/AndroidManifest.template.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
<category android:name="android.intent.category.BROWSABLE" />
3434

3535
<!-- Note: the host here will be replaced on application start -->
36-
<data android:scheme="https" android:host="{STOREFRONT_DOMAIN}" />
36+
<data android:scheme="https" android:host={{STOREFRONT_DOMAIN}} />
3737
</intent-filter>
3838
</activity>
3939
</application>

sample/android/build.gradle

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,12 @@ buildscript {
2020
}
2121
}
2222

23+
def loadProperties() {
24+
def props = new Properties()
25+
file('../.env').withInputStream {
26+
props.load(it)
27+
}
28+
return props
29+
}
30+
2331
apply plugin: "com.facebook.react.rootproject"

sample/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"build:ios": "sh ./scripts/build_ios",
1212
"lint": "yarn typecheck && eslint .",
1313
"ios": "react-native run-ios --simulator 'iPhone 15 Pro'",
14-
"start": "./scripts/prestart && react-native start -- --simulator 'iPhone 15 Pro' --reset-cache",
14+
"start": "react-native start -- --simulator 'iPhone 15 Pro' --reset-cache",
1515
"typecheck": "tsc --noEmit",
1616
"test:ios": "sh ./scripts/test_ios",
1717
"test:android": "sh ./scripts/test_android"

sample/scripts/generate_manifest

Lines changed: 0 additions & 34 deletions
This file was deleted.

sample/scripts/prestart

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)