@react-native/gradle-plugin 0.80.0 → 0.80.2
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 +46 -3
package/package.json
CHANGED
package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt
CHANGED
|
@@ -8,12 +8,14 @@
|
|
|
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.INCLUDE_JITPACK_REPOSITORY
|
|
12
13
|
import com.facebook.react.utils.PropertyUtils.INCLUDE_JITPACK_REPOSITORY_DEFAULT
|
|
13
14
|
import com.facebook.react.utils.PropertyUtils.INTERNAL_PUBLISHING_GROUP
|
|
14
15
|
import com.facebook.react.utils.PropertyUtils.INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO
|
|
15
16
|
import com.facebook.react.utils.PropertyUtils.INTERNAL_USE_HERMES_NIGHTLY
|
|
16
17
|
import com.facebook.react.utils.PropertyUtils.INTERNAL_VERSION_NAME
|
|
18
|
+
import com.facebook.react.utils.PropertyUtils.SCOPED_EXCLUSIVE_ENTEPRISE_REPOSITORY
|
|
17
19
|
import com.facebook.react.utils.PropertyUtils.SCOPED_INCLUDE_JITPACK_REPOSITORY
|
|
18
20
|
import java.io.File
|
|
19
21
|
import java.net.URI
|
|
@@ -28,6 +30,12 @@ internal object DependencyUtils {
|
|
|
28
30
|
* party libraries which are auto-linked.
|
|
29
31
|
*/
|
|
30
32
|
fun configureRepositories(project: Project) {
|
|
33
|
+
val exclusiveEnterpriseRepository = project.rootProject.exclusiveEnterpriseRepository()
|
|
34
|
+
if (exclusiveEnterpriseRepository != null) {
|
|
35
|
+
project.logger.lifecycle(
|
|
36
|
+
"Replacing ALL Maven Repositories with: $exclusiveEnterpriseRepository")
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
project.rootProject.allprojects { eachProject ->
|
|
32
40
|
with(eachProject) {
|
|
33
41
|
if (hasProperty(INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO)) {
|
|
@@ -36,8 +44,18 @@ internal object DependencyUtils {
|
|
|
36
44
|
repo.content { it.excludeGroup("org.webkit") }
|
|
37
45
|
}
|
|
38
46
|
}
|
|
47
|
+
|
|
48
|
+
if (exclusiveEnterpriseRepository != null) {
|
|
49
|
+
// We remove all previously set repositories and only configure the proxy provided by the
|
|
50
|
+
// user.
|
|
51
|
+
rootProject.repositories.clear()
|
|
52
|
+
mavenRepoFromUrl(exclusiveEnterpriseRepository)
|
|
53
|
+
// We return here as we don't want to configure other repositories as well.
|
|
54
|
+
return@allprojects
|
|
55
|
+
}
|
|
56
|
+
|
|
39
57
|
// We add the snapshot for users on nightlies.
|
|
40
|
-
mavenRepoFromUrl("https://
|
|
58
|
+
mavenRepoFromUrl("https://central.sonatype.com/repository/maven-snapshots/") { repo ->
|
|
41
59
|
repo.content { it.excludeGroup("org.webkit") }
|
|
42
60
|
}
|
|
43
61
|
repositories.mavenCentral { repo ->
|
|
@@ -181,4 +199,13 @@ internal object DependencyUtils {
|
|
|
181
199
|
property(INCLUDE_JITPACK_REPOSITORY).toString().toBoolean()
|
|
182
200
|
else -> INCLUDE_JITPACK_REPOSITORY_DEFAULT
|
|
183
201
|
}
|
|
202
|
+
|
|
203
|
+
internal fun Project.exclusiveEnterpriseRepository() =
|
|
204
|
+
when {
|
|
205
|
+
hasProperty(SCOPED_EXCLUSIVE_ENTEPRISE_REPOSITORY) ->
|
|
206
|
+
property(SCOPED_EXCLUSIVE_ENTEPRISE_REPOSITORY).toString()
|
|
207
|
+
hasProperty(EXCLUSIVE_ENTEPRISE_REPOSITORY) ->
|
|
208
|
+
property(EXCLUSIVE_ENTEPRISE_REPOSITORY).toString()
|
|
209
|
+
else -> null
|
|
210
|
+
}
|
|
184
211
|
}
|
package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt
CHANGED
|
@@ -30,6 +30,12 @@ object PropertyUtils {
|
|
|
30
30
|
const val INCLUDE_JITPACK_REPOSITORY = "includeJitpackRepository"
|
|
31
31
|
const val SCOPED_INCLUDE_JITPACK_REPOSITORY = "react.includeJitpackRepository"
|
|
32
32
|
|
|
33
|
+
/**
|
|
34
|
+
* Public property that allows to configure an enterprise repository proxy as exclusive repository
|
|
35
|
+
*/
|
|
36
|
+
const val EXCLUSIVE_ENTEPRISE_REPOSITORY = "exclusiveEnterpriseRepository"
|
|
37
|
+
const val SCOPED_EXCLUSIVE_ENTEPRISE_REPOSITORY = "react.exclusiveEnterpriseRepository"
|
|
38
|
+
|
|
33
39
|
/** By default we include JitPack to avoid breaking user builds */
|
|
34
40
|
internal const val INCLUDE_JITPACK_REPOSITORY_DEFAULT = true
|
|
35
41
|
|
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
|
|
@@ -45,7 +46,7 @@ class DependencyUtilsTest {
|
|
|
45
46
|
|
|
46
47
|
@Test
|
|
47
48
|
fun configureRepositories_containsSnapshotRepo() {
|
|
48
|
-
val repositoryURI = URI.create("https://
|
|
49
|
+
val repositoryURI = URI.create("https://central.sonatype.com/repository/maven-snapshots/")
|
|
49
50
|
val project = createProject()
|
|
50
51
|
|
|
51
52
|
configureRepositories(project)
|
|
@@ -99,6 +100,24 @@ class DependencyUtilsTest {
|
|
|
99
100
|
.isNotNull()
|
|
100
101
|
}
|
|
101
102
|
|
|
103
|
+
@Test
|
|
104
|
+
fun configureRepositories_withExclusiveEnterpriseRepository_replacesAllRepositories() {
|
|
105
|
+
val repositoryURI = URI.create("https://maven.myfabolousorganization.it")
|
|
106
|
+
|
|
107
|
+
val project = createProject()
|
|
108
|
+
project.rootProject.extensions.extraProperties.set(
|
|
109
|
+
"exclusiveEnterpriseRepository", repositoryURI.toString())
|
|
110
|
+
|
|
111
|
+
configureRepositories(project)
|
|
112
|
+
|
|
113
|
+
assertThat(project.repositories).hasSize(1)
|
|
114
|
+
assertThat(
|
|
115
|
+
project.repositories.firstOrNull {
|
|
116
|
+
it is MavenArtifactRepository && it.url == repositoryURI
|
|
117
|
+
})
|
|
118
|
+
.isNotNull()
|
|
119
|
+
}
|
|
120
|
+
|
|
102
121
|
@Test
|
|
103
122
|
fun configureRepositories_withIncludeJitpackRepositoryFalse_doesNotContainJitPack() {
|
|
104
123
|
val repositoryURI = URI.create("https://www.jitpack.io")
|
|
@@ -176,7 +195,7 @@ class DependencyUtilsTest {
|
|
|
176
195
|
|
|
177
196
|
@Test
|
|
178
197
|
fun configureRepositories_snapshotRepoHasHigherPriorityThanMavenCentral() {
|
|
179
|
-
val repositoryURI = URI.create("https://
|
|
198
|
+
val repositoryURI = URI.create("https://central.sonatype.com/repository/maven-snapshots/")
|
|
180
199
|
val mavenCentralURI = URI.create("https://repo.maven.apache.org/maven2/")
|
|
181
200
|
val project = createProject()
|
|
182
201
|
|
|
@@ -470,7 +489,7 @@ class DependencyUtilsTest {
|
|
|
470
489
|
@Test
|
|
471
490
|
fun shouldAddJitPack_withUnscopedProperty() {
|
|
472
491
|
val project = createProject(tempFolder.root)
|
|
473
|
-
project.extensions.extraProperties.set("
|
|
492
|
+
project.extensions.extraProperties.set("includeJitpackRepository", "false")
|
|
474
493
|
assertThat(project.shouldAddJitPack()).isFalse()
|
|
475
494
|
}
|
|
476
495
|
|
|
@@ -479,4 +498,28 @@ class DependencyUtilsTest {
|
|
|
479
498
|
val project = createProject(tempFolder.root)
|
|
480
499
|
assertThat(project.shouldAddJitPack()).isTrue()
|
|
481
500
|
}
|
|
501
|
+
|
|
502
|
+
@Test
|
|
503
|
+
fun exclusiveEnterpriseRepository_withScopedProperty() {
|
|
504
|
+
val project = createProject(tempFolder.root)
|
|
505
|
+
project.extensions.extraProperties.set(
|
|
506
|
+
"react.exclusiveEnterpriseRepository", "https://maven.myfabolousorganization.it")
|
|
507
|
+
assertThat(project.exclusiveEnterpriseRepository())
|
|
508
|
+
.isEqualTo("https://maven.myfabolousorganization.it")
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
@Test
|
|
512
|
+
fun exclusiveEnterpriseRepository_withUnscopedProperty() {
|
|
513
|
+
val project = createProject(tempFolder.root)
|
|
514
|
+
project.extensions.extraProperties.set(
|
|
515
|
+
"exclusiveEnterpriseRepository", "https://maven.myfabolousorganization.it")
|
|
516
|
+
assertThat(project.exclusiveEnterpriseRepository())
|
|
517
|
+
.isEqualTo("https://maven.myfabolousorganization.it")
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
@Test
|
|
521
|
+
fun exclusiveEnterpriseRepository_defaultIsTrue() {
|
|
522
|
+
val project = createProject(tempFolder.root)
|
|
523
|
+
assertThat(project.exclusiveEnterpriseRepository()).isNull()
|
|
524
|
+
}
|
|
482
525
|
}
|