@react-native/gradle-plugin 0.72.10 → 0.73.0-nightly-20230616-5f8bbf2bd

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/README.md CHANGED
@@ -14,3 +14,10 @@ yarn add @react-native/gradle-plugin
14
14
 
15
15
  [version-badge]: https://img.shields.io/npm/v/@react-native/gradle-plugin?style=flat-square
16
16
  [package]: https://www.npmjs.com/package/@react-native/gradle-plugin
17
+
18
+ ## Testing
19
+
20
+ To run the tests in this package, run the following commands from the React Native root folder:
21
+
22
+ 1. `yarn` to install the dependencies. You just need to run this once
23
+ 2. `yarn jest packages/react-native-gradle-plugin`.
package/build.gradle.kts CHANGED
@@ -11,7 +11,7 @@ import org.gradle.configurationcache.extensions.serviceOf
11
11
  import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
12
12
 
13
13
  plugins {
14
- kotlin("jvm") version "1.7.22"
14
+ kotlin("jvm") version "1.8.0"
15
15
  id("java-gradle-plugin")
16
16
  }
17
17
 
@@ -33,7 +33,12 @@ group = "com.facebook.react"
33
33
 
34
34
  dependencies {
35
35
  implementation(gradleApi())
36
+
37
+ // The KGP/AGP version is defined by React Native Gradle plugin.
38
+ // Therefore we specify an implementation dep rather than a compileOnly.
39
+ implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.0")
36
40
  implementation("com.android.tools.build:gradle:7.4.2")
41
+
37
42
  implementation("com.google.code.gson:gson:2.8.9")
38
43
  implementation("com.google.guava:guava:31.0.1-jre")
39
44
  implementation("com.squareup:javapoet:1.13.0")
@@ -54,6 +59,8 @@ java {
54
59
  targetCompatibility = JavaVersion.VERSION_11
55
60
  }
56
61
 
62
+ kotlin { jvmToolchain(11) }
63
+
57
64
  tasks.withType<KotlinCompile> {
58
65
  kotlinOptions {
59
66
  jvmTarget = JavaVersion.VERSION_11.majorVersion
Binary file
@@ -1,5 +1,6 @@
1
1
  distributionBase=GRADLE_USER_HOME
2
2
  distributionPath=wrapper/dists
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.1-all.zip
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-all.zip
4
+ networkTimeout=10000
4
5
  zipStoreBase=GRADLE_USER_HOME
5
6
  zipStorePath=wrapper/dists
package/gradlew CHANGED
@@ -55,7 +55,7 @@
55
55
  # Darwin, MinGW, and NonStop.
56
56
  #
57
57
  # (3) This script is generated from the Groovy template
58
- # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
58
+ # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59
59
  # within the Gradle project.
60
60
  #
61
61
  # You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,10 @@ do
80
80
  esac
81
81
  done
82
82
 
83
- APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84
-
85
- APP_NAME="Gradle"
83
+ # This is normally unused
84
+ # shellcheck disable=SC2034
86
85
  APP_BASE_NAME=${0##*/}
87
-
88
- # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89
- DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
86
+ APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
90
87
 
91
88
  # Use the maximum available, or set MAX_FD != -1 to use that value.
92
89
  MAX_FD=maximum
@@ -143,12 +140,16 @@ fi
143
140
  if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144
141
  case $MAX_FD in #(
145
142
  max*)
143
+ # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
144
+ # shellcheck disable=SC3045
146
145
  MAX_FD=$( ulimit -H -n ) ||
147
146
  warn "Could not query maximum file descriptor limit"
148
147
  esac
149
148
  case $MAX_FD in #(
150
149
  '' | soft) :;; #(
151
150
  *)
151
+ # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
152
+ # shellcheck disable=SC3045
152
153
  ulimit -n "$MAX_FD" ||
153
154
  warn "Could not set maximum file descriptor limit to $MAX_FD"
154
155
  esac
@@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
193
194
  done
194
195
  fi
195
196
 
197
+
198
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
199
+ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
200
+
196
201
  # Collect all arguments for the java command;
197
202
  # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198
203
  # shell script including quotes and variable substitutions, so put them in
package/gradlew.bat CHANGED
@@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
26
26
 
27
27
  set DIRNAME=%~dp0
28
28
  if "%DIRNAME%"=="" set DIRNAME=.
29
+ @rem This is normally unused
29
30
  set APP_BASE_NAME=%~n0
30
31
  set APP_HOME=%DIRNAME%
31
32
 
package/package.json CHANGED
@@ -1,19 +1,28 @@
1
1
  {
2
2
  "name": "@react-native/gradle-plugin",
3
- "version": "0.72.10",
4
- "description": "⚛️ Gradle Plugin for React Native",
5
- "homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/react-native-gradle-plugin",
3
+ "version": "0.73.0-nightly-20230616-5f8bbf2bd",
4
+ "description": "Gradle Plugin for React Native",
5
+ "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git@github.com:facebook/react-native.git",
8
+ "url": "https://github.com/facebook/react-native.git",
9
9
  "directory": "packages/react-native-gradle-plugin"
10
10
  },
11
+ "homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/react-native-gradle-plugin#readme",
12
+ "keywords": [
13
+ "gradle",
14
+ "plugin",
15
+ "react-native"
16
+ ],
17
+ "bugs": "https://github.com/facebook/react-native/issues",
18
+ "engines": {
19
+ "node": ">=16"
20
+ },
11
21
  "scripts": {
12
22
  "build": "./gradlew build",
13
23
  "clean": "./gradlew clean",
14
24
  "test": "./gradlew check"
15
25
  },
16
- "license": "MIT",
17
26
  "files": [
18
27
  "settings.gradle.kts",
19
28
  "build.gradle.kts",
@@ -80,7 +80,7 @@ class ReactPlugin : Plugin<Project> {
80
80
  configureCodegen(project, extension, rootExtension, isLibrary = true)
81
81
  }
82
82
 
83
- // App and Library Configurations
83
+ // Library and App Configurations
84
84
  configureJavaToolChains(project)
85
85
  }
86
86
 
@@ -61,23 +61,8 @@ internal object DependencyUtils {
61
61
  // This allows users to import libraries that are still using
62
62
  // implementation("com.facebook.react:react-native:+") and resolve the right dependency.
63
63
  configuration.resolutionStrategy.dependencySubstitution {
64
- it.substitute(it.module("com.facebook.react:react-native"))
65
- .using(it.module("${groupString}:react-android:${versionString}"))
66
- .because(
67
- "The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210.")
68
- it.substitute(it.module("com.facebook.react:hermes-engine"))
69
- .using(it.module("${groupString}:hermes-android:${versionString}"))
70
- .because(
71
- "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.")
72
- if (groupString != DEFAULT_GROUP_STRING) {
73
- it.substitute(it.module("com.facebook.react:react-android"))
74
- .using(it.module("${groupString}:react-android:${versionString}"))
75
- .because(
76
- "The react-android dependency was modified to use the correct Maven group.")
77
- it.substitute(it.module("com.facebook.react:hermes-android"))
78
- .using(it.module("${groupString}:hermes-android:${versionString}"))
79
- .because(
80
- "The hermes-android dependency was modified to use the correct Maven group.")
64
+ getDependencySubstitutions(versionString, groupString).forEach { (module, dest, reason) ->
65
+ it.substitute(it.module(module)).using(it.module(dest)).because(reason)
81
66
  }
82
67
  }
83
68
  configuration.resolutionStrategy.force(
@@ -88,13 +73,43 @@ internal object DependencyUtils {
88
73
  }
89
74
  }
90
75
 
76
+ internal fun getDependencySubstitutions(
77
+ versionString: String,
78
+ groupString: String = DEFAULT_GROUP_STRING
79
+ ): List<Triple<String, String, String>> {
80
+ val dependencySubstitution = mutableListOf<Triple<String, String, String>>()
81
+ dependencySubstitution.add(
82
+ Triple(
83
+ "com.facebook.react:react-native",
84
+ "${groupString}:react-android:${versionString}",
85
+ "The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210."))
86
+ dependencySubstitution.add(
87
+ Triple(
88
+ "com.facebook.react:hermes-engine",
89
+ "${groupString}:hermes-android:${versionString}",
90
+ "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210."))
91
+ if (groupString != DEFAULT_GROUP_STRING) {
92
+ dependencySubstitution.add(
93
+ Triple(
94
+ "com.facebook.react:react-android",
95
+ "${groupString}:react-android:${versionString}",
96
+ "The react-android dependency was modified to use the correct Maven group."))
97
+ dependencySubstitution.add(
98
+ Triple(
99
+ "com.facebook.react:hermes-android",
100
+ "${groupString}:hermes-android:${versionString}",
101
+ "The hermes-android dependency was modified to use the correct Maven group."))
102
+ }
103
+ return dependencySubstitution
104
+ }
105
+
91
106
  fun readVersionAndGroupStrings(propertiesFile: File): Pair<String, String> {
92
107
  val reactAndroidProperties = Properties()
93
108
  propertiesFile.inputStream().use { reactAndroidProperties.load(it) }
94
109
  val versionStringFromFile = reactAndroidProperties["VERSION_NAME"] as? String ?: ""
95
110
  // If on a nightly, we need to fetch the -SNAPSHOT artifact from Sonatype.
96
111
  val versionString =
97
- if (versionStringFromFile.startsWith("0.0.0")) {
112
+ if (versionStringFromFile.startsWith("0.0.0") || "-nightly-" in versionStringFromFile) {
98
113
  "$versionStringFromFile-SNAPSHOT"
99
114
  } else {
100
115
  versionStringFromFile
@@ -13,6 +13,7 @@ import org.gradle.api.Action
13
13
  import org.gradle.api.JavaVersion
14
14
  import org.gradle.api.Project
15
15
  import org.gradle.api.plugins.AppliedPlugin
16
+ import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension
16
17
 
17
18
  internal object JdkConfiguratorUtils {
18
19
  /**
@@ -27,14 +28,20 @@ internal object JdkConfiguratorUtils {
27
28
  input.rootProject.allprojects { project ->
28
29
  val action =
29
30
  Action<AppliedPlugin> {
30
- project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl {
31
- ext ->
31
+ project.extensions.getByType(AndroidComponentsExtension::class.java).finalizeDsl { ext
32
+ ->
32
33
  ext.compileOptions.sourceCompatibility = JavaVersion.VERSION_11
33
34
  ext.compileOptions.targetCompatibility = JavaVersion.VERSION_11
34
35
  }
35
36
  }
36
37
  project.pluginManager.withPlugin("com.android.application", action)
37
38
  project.pluginManager.withPlugin("com.android.library", action)
39
+ project.pluginManager.withPlugin("org.jetbrains.kotlin.android") {
40
+ project.extensions.getByType(KotlinTopLevelExtension::class.java).jvmToolchain(11)
41
+ }
42
+ project.pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
43
+ project.extensions.getByType(KotlinTopLevelExtension::class.java).jvmToolchain(11)
44
+ }
38
45
  }
39
46
  }
40
47
  }