Skip to content

Commit b5405b2

Browse files
cortinicofacebook-github-bot
authored andcommitted
Make sure nightly versions are using the -SNAPSHOT artifacts (facebook#35178)
Summary: Pull Request resolved: facebook#35178 I forgot to add the logic to fetch the -SNAPSHOT version when on nightlies. This code takes care of it. Changelog: [Internal] [Changed] - Make sure nightly versions are using the -SNAPSHOT artifacts Reviewed By: cipolleschi Differential Revision: D40939367 fbshipit-source-id: 29d60cf281d30b3dbd05d7ea1c766541a8fab90a
1 parent b5ea5a2 commit b5405b2

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ internal object DependencyUtils {
4545
fun readVersionString(propertiesFile: File): String {
4646
val reactAndroidProperties = Properties()
4747
propertiesFile.inputStream().use { reactAndroidProperties.load(it) }
48-
return reactAndroidProperties["VERSION_NAME"] as? String ?: ""
48+
val versionString = reactAndroidProperties["VERSION_NAME"] as? String ?: ""
49+
// If on a nightly, we need to fetch the -SNAPSHOT artifact from Sonatype.
50+
return if (versionString.startsWith("0.0.0")) {
51+
"$versionString-SNAPSHOT"
52+
} else {
53+
versionString
54+
}
4955
}
5056

5157
fun Project.mavenRepoFromUrl(url: String): MavenArtifactRepository =

packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,23 @@ class DependencyUtilsTest {
198198
assertEquals("1000.0.0", versionString)
199199
}
200200

201+
@Test
202+
fun readVersionString_withNightlyVersionString_returnsSnapshotVersion() {
203+
val propertiesFile =
204+
tempFolder.newFile("gradle.properties").apply {
205+
writeText(
206+
"""
207+
VERSION_NAME=0.0.0-20221101-2019-cfe811ab1
208+
ANOTHER_PROPERTY=true
209+
"""
210+
.trimIndent())
211+
}
212+
213+
val versionString = readVersionString(propertiesFile)
214+
215+
assertEquals("0.0.0-20221101-2019-cfe811ab1-SNAPSHOT", versionString)
216+
}
217+
201218
@Test
202219
fun readVersionString_withMissingVersionString_returnsEmpty() {
203220
val propertiesFile =

0 commit comments

Comments
 (0)