@react-native/gradle-plugin 0.77.1 → 0.77.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +28 -1
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt +6 -0
- package/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt +44 -2
package/package.json
CHANGED
package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt
CHANGED
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
package com.facebook.react.utils
|
|
9
9
|
|
|
10
10
|
import com.facebook.react.utils.PropertyUtils.DEFAULT_INTERNAL_PUBLISHING_GROUP
|
|
11
|
+
import com.facebook.react.utils.PropertyUtils.EXCLUSIVE_ENTEPRISE_REPOSITORY
|
|
11
12
|
import com.facebook.react.utils.PropertyUtils.INTERNAL_PUBLISHING_GROUP
|
|
12
13
|
import com.facebook.react.utils.PropertyUtils.INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO
|
|
13
14
|
import com.facebook.react.utils.PropertyUtils.INTERNAL_USE_HERMES_NIGHTLY
|
|
14
15
|
import com.facebook.react.utils.PropertyUtils.INTERNAL_VERSION_NAME
|
|
16
|
+
import com.facebook.react.utils.PropertyUtils.SCOPED_EXCLUSIVE_ENTEPRISE_REPOSITORY
|
|
15
17
|
import java.io.File
|
|
16
18
|
import java.net.URI
|
|
17
19
|
import java.util.*
|
|
@@ -25,6 +27,12 @@ internal object DependencyUtils {
|
|
|
25
27
|
* party libraries which are auto-linked.
|
|
26
28
|
*/
|
|
27
29
|
fun configureRepositories(project: Project, reactNativeDir: File) {
|
|
30
|
+
val exclusiveEnterpriseRepository = project.rootProject.exclusiveEnterpriseRepository()
|
|
31
|
+
if (exclusiveEnterpriseRepository != null) {
|
|
32
|
+
project.logger.lifecycle(
|
|
33
|
+
"Replacing ALL Maven Repositories with: $exclusiveEnterpriseRepository")
|
|
34
|
+
}
|
|
35
|
+
|
|
28
36
|
project.rootProject.allprojects { eachProject ->
|
|
29
37
|
with(eachProject) {
|
|
30
38
|
if (hasProperty(INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO)) {
|
|
@@ -33,8 +41,18 @@ internal object DependencyUtils {
|
|
|
33
41
|
repo.content { it.excludeGroup("org.webkit") }
|
|
34
42
|
}
|
|
35
43
|
}
|
|
44
|
+
|
|
45
|
+
if (exclusiveEnterpriseRepository != null) {
|
|
46
|
+
// We remove all previously set repositories and only configure the proxy provided by the
|
|
47
|
+
// user.
|
|
48
|
+
rootProject.repositories.clear()
|
|
49
|
+
mavenRepoFromUrl(exclusiveEnterpriseRepository)
|
|
50
|
+
// We return here as we don't want to configure other repositories as well.
|
|
51
|
+
return@allprojects
|
|
52
|
+
}
|
|
53
|
+
|
|
36
54
|
// We add the snapshot for users on nightlies.
|
|
37
|
-
mavenRepoFromUrl("https://
|
|
55
|
+
mavenRepoFromUrl("https://central.sonatype.com/repository/maven-snapshots/") { repo ->
|
|
38
56
|
repo.content { it.excludeGroup("org.webkit") }
|
|
39
57
|
}
|
|
40
58
|
repositories.mavenCentral { repo ->
|
|
@@ -169,4 +187,13 @@ internal object DependencyUtils {
|
|
|
169
187
|
it.url = uri
|
|
170
188
|
action(it)
|
|
171
189
|
}
|
|
190
|
+
|
|
191
|
+
internal fun Project.exclusiveEnterpriseRepository() =
|
|
192
|
+
when {
|
|
193
|
+
hasProperty(SCOPED_EXCLUSIVE_ENTEPRISE_REPOSITORY) ->
|
|
194
|
+
property(SCOPED_EXCLUSIVE_ENTEPRISE_REPOSITORY).toString()
|
|
195
|
+
hasProperty(EXCLUSIVE_ENTEPRISE_REPOSITORY) ->
|
|
196
|
+
property(EXCLUSIVE_ENTEPRISE_REPOSITORY).toString()
|
|
197
|
+
else -> null
|
|
198
|
+
}
|
|
172
199
|
}
|
package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt
CHANGED
|
@@ -22,6 +22,12 @@ object PropertyUtils {
|
|
|
22
22
|
const val REACT_NATIVE_ARCHITECTURES = "reactNativeArchitectures"
|
|
23
23
|
const val SCOPED_REACT_NATIVE_ARCHITECTURES = "react.nativeArchitectures"
|
|
24
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Public property that allows to configure an enterprise repository proxy as exclusive repository
|
|
27
|
+
*/
|
|
28
|
+
const val EXCLUSIVE_ENTEPRISE_REPOSITORY = "exclusiveEnterpriseRepository"
|
|
29
|
+
const val SCOPED_EXCLUSIVE_ENTEPRISE_REPOSITORY = "react.exclusiveEnterpriseRepository"
|
|
30
|
+
|
|
25
31
|
/**
|
|
26
32
|
* Internal Property that acts as a killswitch to configure the JDK version and align it for app
|
|
27
33
|
* and all the libraries.
|
package/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt
CHANGED
|
@@ -10,6 +10,7 @@ package com.facebook.react.utils
|
|
|
10
10
|
import com.facebook.react.tests.createProject
|
|
11
11
|
import com.facebook.react.utils.DependencyUtils.configureDependencies
|
|
12
12
|
import com.facebook.react.utils.DependencyUtils.configureRepositories
|
|
13
|
+
import com.facebook.react.utils.DependencyUtils.exclusiveEnterpriseRepository
|
|
13
14
|
import com.facebook.react.utils.DependencyUtils.getDependencySubstitutions
|
|
14
15
|
import com.facebook.react.utils.DependencyUtils.mavenRepoFromURI
|
|
15
16
|
import com.facebook.react.utils.DependencyUtils.mavenRepoFromUrl
|
|
@@ -44,7 +45,7 @@ class DependencyUtilsTest {
|
|
|
44
45
|
|
|
45
46
|
@Test
|
|
46
47
|
fun configureRepositories_containsSnapshotRepo() {
|
|
47
|
-
val repositoryURI = URI.create("https://
|
|
48
|
+
val repositoryURI = URI.create("https://central.sonatype.com/repository/maven-snapshots/")
|
|
48
49
|
val project = createProject()
|
|
49
50
|
|
|
50
51
|
configureRepositories(project, tempFolder.root)
|
|
@@ -107,7 +108,24 @@ class DependencyUtilsTest {
|
|
|
107
108
|
val project = createProject()
|
|
108
109
|
|
|
109
110
|
configureRepositories(project, tempFolder.root)
|
|
111
|
+
assertThat(
|
|
112
|
+
project.repositories.firstOrNull {
|
|
113
|
+
it is MavenArtifactRepository && it.url == repositoryURI
|
|
114
|
+
})
|
|
115
|
+
.isNotNull()
|
|
116
|
+
}
|
|
110
117
|
|
|
118
|
+
@Test
|
|
119
|
+
fun configureRepositories_withExclusiveEnterpriseRepository_replacesAllRepositories() {
|
|
120
|
+
val repositoryURI = URI.create("https://maven.myfabolousorganization.it")
|
|
121
|
+
|
|
122
|
+
val project = createProject()
|
|
123
|
+
project.rootProject.extensions.extraProperties.set(
|
|
124
|
+
"exclusiveEnterpriseRepository", repositoryURI.toString())
|
|
125
|
+
|
|
126
|
+
configureRepositories(project, tempFolder.root)
|
|
127
|
+
|
|
128
|
+
assertThat(project.repositories).hasSize(1)
|
|
111
129
|
assertThat(
|
|
112
130
|
project.repositories.firstOrNull {
|
|
113
131
|
it is MavenArtifactRepository && it.url == repositoryURI
|
|
@@ -138,7 +156,7 @@ class DependencyUtilsTest {
|
|
|
138
156
|
|
|
139
157
|
@Test
|
|
140
158
|
fun configureRepositories_snapshotRepoHasHigherPriorityThanMavenCentral() {
|
|
141
|
-
val repositoryURI = URI.create("https://
|
|
159
|
+
val repositoryURI = URI.create("https://central.sonatype.com/repository/maven-snapshots/")
|
|
142
160
|
val mavenCentralURI = URI.create("https://repo.maven.apache.org/maven2/")
|
|
143
161
|
val project = createProject()
|
|
144
162
|
|
|
@@ -421,4 +439,28 @@ class DependencyUtilsTest {
|
|
|
421
439
|
|
|
422
440
|
assertThat(mavenRepo.url).isEqualTo(repoFolder.toURI())
|
|
423
441
|
}
|
|
442
|
+
|
|
443
|
+
@Test
|
|
444
|
+
fun exclusiveEnterpriseRepository_withScopedProperty() {
|
|
445
|
+
val project = createProject(tempFolder.root)
|
|
446
|
+
project.extensions.extraProperties.set(
|
|
447
|
+
"react.exclusiveEnterpriseRepository", "https://maven.myfabolousorganization.it")
|
|
448
|
+
assertThat(project.exclusiveEnterpriseRepository())
|
|
449
|
+
.isEqualTo("https://maven.myfabolousorganization.it")
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
@Test
|
|
453
|
+
fun exclusiveEnterpriseRepository_withUnscopedProperty() {
|
|
454
|
+
val project = createProject(tempFolder.root)
|
|
455
|
+
project.extensions.extraProperties.set(
|
|
456
|
+
"exclusiveEnterpriseRepository", "https://maven.myfabolousorganization.it")
|
|
457
|
+
assertThat(project.exclusiveEnterpriseRepository())
|
|
458
|
+
.isEqualTo("https://maven.myfabolousorganization.it")
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
@Test
|
|
462
|
+
fun exclusiveEnterpriseRepository_defaultIsTrue() {
|
|
463
|
+
val project = createProject(tempFolder.root)
|
|
464
|
+
assertThat(project.exclusiveEnterpriseRepository()).isNull()
|
|
465
|
+
}
|
|
424
466
|
}
|