@react-native/gradle-plugin 0.80.1 → 0.80.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/gradle-plugin",
3
- "version": "0.80.1",
3
+ "version": "0.80.3",
4
4
  "description": "Gradle Plugin for React Native",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -26,5 +26,21 @@ class ReactRootProjectPlugin : Plugin<Project> {
26
26
  it.evaluationDependsOn(":app")
27
27
  }
28
28
  }
29
+ // We need to make sure that `:app:preBuild` task depends on all other subprojects' preBuild
30
+ // tasks. This is necessary in order to have all the codegen generated code before the CMake
31
+ // configuration build kicks in.
32
+ project.gradle.projectsEvaluated {
33
+ val appProject = project.rootProject.subprojects.find { it.name == "app" }
34
+ val appPreBuild = appProject?.tasks?.findByName("preBuild")
35
+ if (appPreBuild != null) {
36
+ // Find all other subprojects' preBuild tasks
37
+ val otherPreBuildTasks =
38
+ project.rootProject.subprojects
39
+ .filter { it != appProject }
40
+ .mapNotNull { it.tasks.findByName("preBuild") }
41
+ // Make :app:preBuild depend on all others
42
+ appPreBuild.dependsOn(otherPreBuildTasks)
43
+ }
44
+ }
29
45
  }
30
46
  }
@@ -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,6 +44,16 @@ 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
58
  mavenRepoFromUrl("https://central.sonatype.com/repository/maven-snapshots/") { repo ->
41
59
  repo.content { it.excludeGroup("org.webkit") }
@@ -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
  }
@@ -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
 
@@ -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
@@ -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")
@@ -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("react.includeJitpackRepository", "false")
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
  }