Skip to content

Commit 5ac9483

Browse files
committed
rework signingConfig.release to be configured inline
instead of after … some other configuration is completed. Somehow configuring it here works, while doing the post-configuration version fails when you actually have a signing file. And– it fails – by way of saying "project.hasProperty – could not find .hasProperty" i mean, really, gradle really do you gotta do that
1 parent d1c461c commit 5ac9483

File tree

1 file changed

+26
-37
lines changed

1 file changed

+26
-37
lines changed

android/app/build.gradle

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,32 @@ android {
122122
}
123123

124124
signingConfigs {
125-
// the signingConfig is configured below
126-
release
125+
String filePath = System.getenv("KEYSTORE_FILE")
126+
127+
if (filePath == null) {
128+
logger.warn "env['KEYSTORE_FILE'] not set"
129+
release
130+
return
131+
} else {
132+
logger.warn "env['KEYSTORE_FILE'] = ${filePath}"
133+
}
134+
135+
def propFile = new File(filePath)
136+
if (!propFile.canRead()) {
137+
logger.warn "${filePath} is not readable"
138+
release
139+
return
140+
}
141+
142+
def props = new Properties()
143+
props.load(new FileInputStream(propFile))
144+
145+
release {
146+
storeFile file(props['STORE_FILE'])
147+
storePassword props['STORE_PASSWORD']
148+
keyAlias props['KEY_ALIAS']
149+
keyPassword props['KEY_PASSWORD']
150+
}
127151
}
128152

129153
splits {
@@ -186,41 +210,6 @@ android {
186210
}
187211
}
188212

189-
// borrowed from https://gist.github.com/gabrielemariotti/6856974
190-
def propFile = new File('android/app/signing.properties')
191-
if (propFile.canRead()) {
192-
Properties props = new Properties()
193-
props.load(new FileInputStream(propFile))
194-
195-
bool hasFile = props != null && props.containsKey('STORE_FILE');
196-
bool hasPassword = props != null && props.containsKey('STORE_PASSWORD');
197-
bool hasAlias = props != null && props.containsKey('KEY_ALIAS');
198-
bool hasKeyPass = props != null && props.containsKey('KEY_PASSWORD');
199-
200-
if (hasFile && hasPassword && hasAlias && hasKeyPass) {
201-
logger.info 'android/app/signing.properties is fully functional.'
202-
android.signingConfigs.release.storeFile = file(props['STORE_FILE'])
203-
android.signingConfigs.release.storePassword = props['STORE_PASSWORD']
204-
android.signingConfigs.release.keyAlias = props['KEY_ALIAS']
205-
android.signingConfigs.release.keyPassword = props['KEY_PASSWORD']
206-
} else {
207-
println 'android/app/signing.properties found, but some entries are missing.'
208-
if (props == null) {
209-
logger.warn '`props` was null'
210-
} else {
211-
logger.warn "has STORE_FILE [y/n]: ${props.containsKey('STORE_FILE')}"
212-
logger.warn "has STORE_PASSWORD [y/n]: ${props.containsKey('STORE_PASSWORD')}"
213-
logger.warn "has KEY_ALIAS [y/n]: ${props.containsKey('KEY_ALIAS')}"
214-
logger.warn "has KEY_PASSWORD [y/n]: ${props.containsKey('KEY_PASSWORD')}"
215-
}
216-
android.buildTypes.release.signingConfig = null
217-
}
218-
} else {
219-
logger.warn 'android/app/signing.properties not found.'
220-
logger.warn "cwd: ${new File(".").absolutePath}"
221-
android.buildTypes.release.signingConfig = null
222-
}
223-
224213
dependencies {
225214
// please keep this list sorted
226215
implementation project(':bugsnag-react-native')

0 commit comments

Comments
 (0)