diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactRootProjectPlugin.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactRootProjectPlugin.kt index e818a1ed339..18f09958dcf 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactRootProjectPlugin.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactRootProjectPlugin.kt @@ -67,18 +67,18 @@ class ReactRootProjectPlugin : Plugin { ) { project.logger.error( """ - ******************************************************************************** + ******************************************************************************** - WARNING: Setting `newArchEnabled=false` in your `gradle.properties` file is not - supported anymore since React Native 0.82. - - You can remove the line from your `gradle.properties` file. - - The application will run with the New Architecture enabled by default. + WARNING: Setting `newArchEnabled=false` in your `gradle.properties` file is not + supported anymore since React Native 0.82. - ******************************************************************************** + You can remove the line from your `gradle.properties` file. - """ + The application will run with the New Architecture enabled by default. + + ******************************************************************************** + + """ .trimIndent() ) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTask.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTask.kt index 2d618b0b779..4c36c8a39fb 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTask.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTask.kt @@ -168,13 +168,13 @@ abstract class GenerateAutolinkingNewArchitecturesFileTask : DefaultTask() { # This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin) cmake_minimum_required(VERSION 3.13) set(CMAKE_VERBOSE_MAKEFILE on) - + # We set REACTNATIVE_MERGED_SO so libraries/apps can selectively decide to depend on either libreactnative.so # or link against a old prefab target (this is needed for React Native 0.76 on). set(REACTNATIVE_MERGED_SO true) - + {{ libraryIncludes }} - + set(AUTOLINKED_LIBRARIES {{ libraryModules }} ) @@ -191,28 +191,28 @@ abstract class GenerateAutolinkingNewArchitecturesFileTask : DefaultTask() { * once the code is regenerated. * */ - + #include "autolinking.h" {{ autolinkingCppIncludes }} - + namespace facebook { namespace react { - + std::shared_ptr autolinking_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms) { {{ autolinkingCppTurboModuleJavaProviders }} return nullptr; } - + std::shared_ptr autolinking_cxxModuleProvider(const std::string moduleName, const std::shared_ptr& jsInvoker) { {{ autolinkingCppTurboModuleCxxProviders }} return nullptr; } - + void autolinking_registerProviders(std::shared_ptr providerRegistry) { {{ autolinkingCppComponentDescriptors }} return; } - + } // namespace react } // namespace facebook """ @@ -228,22 +228,22 @@ abstract class GenerateAutolinkingNewArchitecturesFileTask : DefaultTask() { * once the code is regenerated. * */ - + #pragma once - + #include #include #include #include #include - + namespace facebook { namespace react { - + std::shared_ptr autolinking_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms); std::shared_ptr autolinking_cxxModuleProvider(const std::string moduleName, const std::shared_ptr& jsInvoker); void autolinking_registerProviders(std::shared_ptr providerRegistry); - + } // namespace react } // namespace facebook """ diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateEntryPointTask.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateEntryPointTask.kt index 12733547226..e62b7be075c 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateEntryPointTask.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateEntryPointTask.kt @@ -65,19 +65,19 @@ abstract class GenerateEntryPointTask : DefaultTask() { val generatedFileContentsTemplate = """ package com.facebook.react; - + import android.app.Application; import android.content.Context; import android.content.res.Resources; - + import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger; import com.facebook.react.views.view.WindowUtilKt; import com.facebook.react.soloader.OpenSourceMergedSoMapping; import com.facebook.soloader.SoLoader; - + import java.io.IOException; - + /** * This class is the entry point for loading React Native using the configuration * that the users specifies in their .gradle files. @@ -102,7 +102,7 @@ abstract class GenerateEntryPointTask : DefaultTask() { } } } - """ + """ .trimIndent() } } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GeneratePackageListTask.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GeneratePackageListTask.kt index 5dfcb441a79..c3f260a02d0 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GeneratePackageListTask.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GeneratePackageListTask.kt @@ -137,61 +137,61 @@ abstract class GeneratePackageListTask : DefaultTask() { val generatedFileContentsTemplate = """ package com.facebook.react; - + import android.app.Application; import android.content.Context; import android.content.res.Resources; - + import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainPackageConfig; import com.facebook.react.shell.MainReactPackage; import java.util.Arrays; import java.util.ArrayList; - + {{ packageImports }} - + @SuppressWarnings("deprecation") public class PackageList { private Application application; private ReactNativeHost reactNativeHost; private MainPackageConfig mConfig; - + public PackageList(ReactNativeHost reactNativeHost) { this(reactNativeHost, null); } - + public PackageList(Application application) { this(application, null); } - + public PackageList(ReactNativeHost reactNativeHost, MainPackageConfig config) { this.reactNativeHost = reactNativeHost; mConfig = config; } - + public PackageList(Application application, MainPackageConfig config) { this.reactNativeHost = null; this.application = application; mConfig = config; } - + private ReactNativeHost getReactNativeHost() { return this.reactNativeHost; } - + private Resources getResources() { return this.getApplication().getResources(); } - + private Application getApplication() { if (this.reactNativeHost == null) return this.application; return this.reactNativeHost.getApplication(); } - + private Context getApplicationContext() { return this.getApplication().getApplicationContext(); } - + public ArrayList getPackages() { return new ArrayList<>(Arrays.asList( new MainReactPackage(mConfig){{ packageClassInstances }} diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/BackwardCompatUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/BackwardCompatUtils.kt index cd4bdadec34..8225f40e637 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/BackwardCompatUtils.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/BackwardCompatUtils.kt @@ -21,24 +21,24 @@ internal object BackwardCompatUtils { if (reactMap.isNotEmpty()) { project.logger.error( """ - ******************************************************************************** - - ERROR: Using old project.ext.react configuration. - We identified that your project is using a old configuration block as: - - project.ext.react = [ - // ... - ] - - You should migrate to the new configuration: - - react { - // ... - } - You can find documentation inside `android/app/build.gradle` on how to use it. - - ******************************************************************************** - """ + ******************************************************************************** + + ERROR: Using old project.ext.react configuration. + We identified that your project is using a old configuration block as: + + project.ext.react = [ + // ... + ] + + You should migrate to the new configuration: + + react { + // ... + } + You can find documentation inside `android/app/build.gradle` on how to use it. + + ******************************************************************************** + """ .trimIndent() ) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt index 2f1b60b422c..a69de8b3752 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt @@ -105,11 +105,11 @@ private fun detectCliFile(reactNativeRoot: File, preconfiguredCliFile: File?): F error( """ - Couldn't determine CLI location! + Couldn't determine CLI location! - Please set `react { cliFile = file(...) }` inside your - build.gradle to the path of the react-native cli.js file. - This file typically resides in `node_modules/react-native/cli.js` + Please set `react { cliFile = file(...) }` inside your + build.gradle to the path of the react-native cli.js file. + This file typically resides in `node_modules/react-native/cli.js` """ .trimIndent() ) diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTaskTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTaskTest.kt index 6698555eb3b..2b3f17d5ea2 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTaskTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateAutolinkingNewArchitecturesFileTaskTest.kt @@ -120,20 +120,20 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest { assertThat(output) .isEqualTo( """ - # This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin) - cmake_minimum_required(VERSION 3.13) - set(CMAKE_VERBOSE_MAKEFILE on) - - # We set REACTNATIVE_MERGED_SO so libraries/apps can selectively decide to depend on either libreactnative.so - # or link against a old prefab target (this is needed for React Native 0.76 on). - set(REACTNATIVE_MERGED_SO true) - - - - set(AUTOLINKED_LIBRARIES - - ) - """ + # This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin) + cmake_minimum_required(VERSION 3.13) + set(CMAKE_VERBOSE_MAKEFILE on) + + # We set REACTNATIVE_MERGED_SO so libraries/apps can selectively decide to depend on either libreactnative.so + # or link against a old prefab target (this is needed for React Native 0.76 on). + set(REACTNATIVE_MERGED_SO true) + + + + set(AUTOLINKED_LIBRARIES + + ) + """ .trimIndent() ) } @@ -147,24 +147,24 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest { assertThat(output) .isEqualTo( """ - # This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin) - cmake_minimum_required(VERSION 3.13) - set(CMAKE_VERBOSE_MAKEFILE on) - - # We set REACTNATIVE_MERGED_SO so libraries/apps can selectively decide to depend on either libreactnative.so - # or link against a old prefab target (this is needed for React Native 0.76 on). - set(REACTNATIVE_MERGED_SO true) - - add_subdirectory("./a/directory/" aPackage_autolinked_build) - add_subdirectory("./another/directory/with\ spaces/" anotherPackage_autolinked_build) - add_subdirectory("./another/directory/cxx/" anotherPackage_cxxmodule_autolinked_build) - - set(AUTOLINKED_LIBRARIES - react_codegen_aPackage - react_codegen_anotherPackage - another_cxxModule - ) - """ + # This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin) + cmake_minimum_required(VERSION 3.13) + set(CMAKE_VERBOSE_MAKEFILE on) + + # We set REACTNATIVE_MERGED_SO so libraries/apps can selectively decide to depend on either libreactnative.so + # or link against a old prefab target (this is needed for React Native 0.76 on). + set(REACTNATIVE_MERGED_SO true) + + add_subdirectory("./a/directory/" aPackage_autolinked_build) + add_subdirectory("./another/directory/with\ spaces/" anotherPackage_autolinked_build) + add_subdirectory("./another/directory/cxx/" anotherPackage_cxxmodule_autolinked_build) + + set(AUTOLINKED_LIBRARIES + react_codegen_aPackage + react_codegen_anotherPackage + another_cxxModule + ) + """ .trimIndent() ) } @@ -178,38 +178,38 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest { assertThat(output) .isEqualTo( """ - /** - * This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin). - * - * Do not edit this file as changes may cause incorrect behavior and will be lost - * once the code is regenerated. - * - */ + /** + * This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + */ - #include "autolinking.h" + #include "autolinking.h" - namespace facebook { - namespace react { + namespace facebook { + namespace react { - std::shared_ptr autolinking_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms) { + std::shared_ptr autolinking_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms) { - return nullptr; - } + return nullptr; + } - std::shared_ptr autolinking_cxxModuleProvider(const std::string moduleName, const std::shared_ptr& jsInvoker) { + std::shared_ptr autolinking_cxxModuleProvider(const std::string moduleName, const std::shared_ptr& jsInvoker) { - return nullptr; - } + return nullptr; + } - void autolinking_registerProviders(std::shared_ptr providerRegistry) { + void autolinking_registerProviders(std::shared_ptr providerRegistry) { - return; - } + return; + } - } // namespace react - } // namespace facebook - """ + } // namespace react + } // namespace facebook + """ .trimIndent() ) } @@ -223,50 +223,50 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest { assertThat(output) .isEqualTo( """ - /** - * This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin). - * - * Do not edit this file as changes may cause incorrect behavior and will be lost - * once the code is regenerated. - * - */ + /** + * This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin). + * + * Do not edit this file as changes may cause incorrect behavior and will be lost + * once the code is regenerated. + * + */ - #include "autolinking.h" - #include - #include - #include - #include + #include "autolinking.h" + #include + #include + #include + #include - namespace facebook { - namespace react { + namespace facebook { + namespace react { - std::shared_ptr autolinking_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms) { - auto module_aPackage = aPackage_ModuleProvider(moduleName, params); - if (module_aPackage != nullptr) { - return module_aPackage; - } - auto module_anotherPackage = anotherPackage_ModuleProvider(moduleName, params); - if (module_anotherPackage != nullptr) { - return module_anotherPackage; - } - return nullptr; - } + std::shared_ptr autolinking_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams ¶ms) { + auto module_aPackage = aPackage_ModuleProvider(moduleName, params); + if (module_aPackage != nullptr) { + return module_aPackage; + } + auto module_anotherPackage = anotherPackage_ModuleProvider(moduleName, params); + if (module_anotherPackage != nullptr) { + return module_anotherPackage; + } + return nullptr; + } - std::shared_ptr autolinking_cxxModuleProvider(const std::string moduleName, const std::shared_ptr& jsInvoker) { - if (moduleName == AnotherCxxModule::kModuleName) { - return std::make_shared(jsInvoker); - } - return nullptr; - } + std::shared_ptr autolinking_cxxModuleProvider(const std::string moduleName, const std::shared_ptr& jsInvoker) { + if (moduleName == AnotherCxxModule::kModuleName) { + return std::make_shared(jsInvoker); + } + return nullptr; + } - void autolinking_registerProviders(std::shared_ptr providerRegistry) { - providerRegistry->add(concreteComponentDescriptorProvider()); - return; - } + void autolinking_registerProviders(std::shared_ptr providerRegistry) { + providerRegistry->add(concreteComponentDescriptorProvider()); + return; + } - } // namespace react - } // namespace facebook - """ + } // namespace react + } // namespace facebook + """ .trimIndent() ) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTaskTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTaskTest.kt index 3c150785610..d2d2a611f50 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTaskTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateCodegenArtifactsTaskTest.kt @@ -138,16 +138,16 @@ class GenerateCodegenArtifactsTaskTest { // language=JSON writeText( """ - { - "name": "@a/library", - "codegenConfig": { - "name": "an-awesome-library", - "android": { - "javaPackageName": "com.awesome.package" - } - } - } - """ + { + "name": "@a/library", + "codegenConfig": { + "name": "an-awesome-library", + "android": { + "javaPackageName": "com.awesome.package" + } + } + } + """ .trimIndent() ) } @@ -172,12 +172,12 @@ class GenerateCodegenArtifactsTaskTest { // language=JSON writeText( """ - { - "name": "@a/library", - "codegenConfig": { - } - } - """ + { + "name": "@a/library", + "codegenConfig": { + } + } + """ .trimIndent() ) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateEntryPointTaskTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateEntryPointTaskTest.kt index 91d57a3844a..dfeca885421 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateEntryPointTaskTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GenerateEntryPointTaskTest.kt @@ -47,45 +47,45 @@ class GenerateEntryPointTaskTest { assertThat(result) .isEqualTo( """ - package com.facebook.react; - - import android.app.Application; - import android.content.Context; - import android.content.res.Resources; - - import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; - import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger; - import com.facebook.react.views.view.WindowUtilKt; - import com.facebook.react.soloader.OpenSourceMergedSoMapping; - import com.facebook.soloader.SoLoader; - - import java.io.IOException; - - /** - * This class is the entry point for loading React Native using the configuration - * that the users specifies in their .gradle files. - * - * The `loadReactNative(this)` method invocation should be called inside the - * application onCreate otherwise the app won't load correctly. - */ - public class ReactNativeApplicationEntryPoint { - public static void loadReactNative(Context context) { - try { - SoLoader.init(context, OpenSourceMergedSoMapping.INSTANCE); - } catch (IOException error) { - throw new RuntimeException(error); + package com.facebook.react; + + import android.app.Application; + import android.content.Context; + import android.content.res.Resources; + + import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint; + import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger; + import com.facebook.react.views.view.WindowUtilKt; + import com.facebook.react.soloader.OpenSourceMergedSoMapping; + import com.facebook.soloader.SoLoader; + + import java.io.IOException; + + /** + * This class is the entry point for loading React Native using the configuration + * that the users specifies in their .gradle files. + * + * The `loadReactNative(this)` method invocation should be called inside the + * application onCreate otherwise the app won't load correctly. + */ + public class ReactNativeApplicationEntryPoint { + public static void loadReactNative(Context context) { + try { + SoLoader.init(context, OpenSourceMergedSoMapping.INSTANCE); + } catch (IOException error) { + throw new RuntimeException(error); + } + + if (com.facebook.react.BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { + DefaultNewArchitectureEntryPoint.load(); + } + + if (com.facebook.react.BuildConfig.IS_EDGE_TO_EDGE_ENABLED) { + WindowUtilKt.setEdgeToEdgeFeatureFlagOn(); + } + } } - - if (com.facebook.react.BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) { - DefaultNewArchitectureEntryPoint.load(); - } - - if (com.facebook.react.BuildConfig.IS_EDGE_TO_EDGE_ENABLED) { - WindowUtilKt.setEdgeToEdgeFeatureFlagOn(); - } - } - } - """ + """ .trimIndent() ) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GeneratePackageListTaskTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GeneratePackageListTaskTest.kt index dffce2b0535..2cbf96febbf 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GeneratePackageListTaskTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/GeneratePackageListTaskTest.kt @@ -59,11 +59,11 @@ class GeneratePackageListTaskTest { assertThat(result) .isEqualTo( """ - // @react-native/a-package - import com.facebook.react.aPackage; - // @react-native/another-package - import com.facebook.react.anotherPackage; - """ + // @react-native/a-package + import com.facebook.react.aPackage; + // @react-native/another-package + import com.facebook.react.anotherPackage; + """ .trimIndent() ) } @@ -85,10 +85,10 @@ class GeneratePackageListTaskTest { assertThat(result) .isEqualTo( """ - , - new APackage(), - new AnotherPackage() - """ + , + new APackage(), + new AnotherPackage() + """ .trimIndent() ) } @@ -234,69 +234,69 @@ class GeneratePackageListTaskTest { assertThat(result) .isEqualTo( """ - package com.facebook.react; + package com.facebook.react; - import android.app.Application; - import android.content.Context; - import android.content.res.Resources; + import android.app.Application; + import android.content.Context; + import android.content.res.Resources; - import com.facebook.react.ReactPackage; - import com.facebook.react.shell.MainPackageConfig; - import com.facebook.react.shell.MainReactPackage; - import java.util.Arrays; - import java.util.ArrayList; + import com.facebook.react.ReactPackage; + import com.facebook.react.shell.MainPackageConfig; + import com.facebook.react.shell.MainReactPackage; + import java.util.Arrays; + import java.util.ArrayList; - @SuppressWarnings("deprecation") - public class PackageList { - private Application application; - private ReactNativeHost reactNativeHost; - private MainPackageConfig mConfig; + @SuppressWarnings("deprecation") + public class PackageList { + private Application application; + private ReactNativeHost reactNativeHost; + private MainPackageConfig mConfig; - public PackageList(ReactNativeHost reactNativeHost) { - this(reactNativeHost, null); - } + public PackageList(ReactNativeHost reactNativeHost) { + this(reactNativeHost, null); + } - public PackageList(Application application) { - this(application, null); - } + public PackageList(Application application) { + this(application, null); + } - public PackageList(ReactNativeHost reactNativeHost, MainPackageConfig config) { - this.reactNativeHost = reactNativeHost; - mConfig = config; - } + public PackageList(ReactNativeHost reactNativeHost, MainPackageConfig config) { + this.reactNativeHost = reactNativeHost; + mConfig = config; + } - public PackageList(Application application, MainPackageConfig config) { - this.reactNativeHost = null; - this.application = application; - mConfig = config; - } + public PackageList(Application application, MainPackageConfig config) { + this.reactNativeHost = null; + this.application = application; + mConfig = config; + } - private ReactNativeHost getReactNativeHost() { - return this.reactNativeHost; - } + private ReactNativeHost getReactNativeHost() { + return this.reactNativeHost; + } - private Resources getResources() { - return this.getApplication().getResources(); - } + private Resources getResources() { + return this.getApplication().getResources(); + } - private Application getApplication() { - if (this.reactNativeHost == null) return this.application; - return this.reactNativeHost.getApplication(); - } + private Application getApplication() { + if (this.reactNativeHost == null) return this.application; + return this.reactNativeHost.getApplication(); + } - private Context getApplicationContext() { - return this.getApplication().getApplicationContext(); - } + private Context getApplicationContext() { + return this.getApplication().getApplicationContext(); + } - public ArrayList getPackages() { - return new ArrayList<>(Arrays.asList( - new MainReactPackage(mConfig) - )); - } - } - """ + public ArrayList getPackages() { + return new ArrayList<>(Arrays.asList( + new MainReactPackage(mConfig) + )); + } + } + """ .trimIndent() ) } @@ -312,74 +312,74 @@ class GeneratePackageListTaskTest { assertThat(result) .isEqualTo( """ - package com.facebook.react; + package com.facebook.react; - import android.app.Application; - import android.content.Context; - import android.content.res.Resources; + import android.app.Application; + import android.content.Context; + import android.content.res.Resources; - import com.facebook.react.ReactPackage; - import com.facebook.react.shell.MainPackageConfig; - import com.facebook.react.shell.MainReactPackage; - import java.util.Arrays; - import java.util.ArrayList; + import com.facebook.react.ReactPackage; + import com.facebook.react.shell.MainPackageConfig; + import com.facebook.react.shell.MainReactPackage; + import java.util.Arrays; + import java.util.ArrayList; - // @react-native/a-package - import com.facebook.react.aPackage; - // @react-native/another-package - import com.facebook.react.anotherPackage; - - @SuppressWarnings("deprecation") - public class PackageList { - private Application application; - private ReactNativeHost reactNativeHost; - private MainPackageConfig mConfig; + // @react-native/a-package + import com.facebook.react.aPackage; + // @react-native/another-package + import com.facebook.react.anotherPackage; - public PackageList(ReactNativeHost reactNativeHost) { - this(reactNativeHost, null); - } + @SuppressWarnings("deprecation") + public class PackageList { + private Application application; + private ReactNativeHost reactNativeHost; + private MainPackageConfig mConfig; - public PackageList(Application application) { - this(application, null); - } + public PackageList(ReactNativeHost reactNativeHost) { + this(reactNativeHost, null); + } - public PackageList(ReactNativeHost reactNativeHost, MainPackageConfig config) { - this.reactNativeHost = reactNativeHost; - mConfig = config; - } + public PackageList(Application application) { + this(application, null); + } - public PackageList(Application application, MainPackageConfig config) { - this.reactNativeHost = null; - this.application = application; - mConfig = config; - } + public PackageList(ReactNativeHost reactNativeHost, MainPackageConfig config) { + this.reactNativeHost = reactNativeHost; + mConfig = config; + } - private ReactNativeHost getReactNativeHost() { - return this.reactNativeHost; - } + public PackageList(Application application, MainPackageConfig config) { + this.reactNativeHost = null; + this.application = application; + mConfig = config; + } - private Resources getResources() { - return this.getApplication().getResources(); - } + private ReactNativeHost getReactNativeHost() { + return this.reactNativeHost; + } - private Application getApplication() { - if (this.reactNativeHost == null) return this.application; - return this.reactNativeHost.getApplication(); - } + private Resources getResources() { + return this.getApplication().getResources(); + } - private Context getApplicationContext() { - return this.getApplication().getApplicationContext(); - } + private Application getApplication() { + if (this.reactNativeHost == null) return this.application; + return this.reactNativeHost.getApplication(); + } - public ArrayList getPackages() { - return new ArrayList<>(Arrays.asList( - new MainReactPackage(mConfig), - new APackage(), - new AnotherPackage() - )); - } - } - """ + private Context getApplicationContext() { + return this.getApplication().getApplicationContext(); + } + + public ArrayList getPackages() { + return new ArrayList<>(Arrays.asList( + new MainReactPackage(mConfig), + new APackage(), + new AnotherPackage() + )); + } + } + """ .trimIndent() ) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/AgpConfiguratorUtilsTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/AgpConfiguratorUtilsTest.kt index a05a2f71815..d2ed87bf093 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/AgpConfiguratorUtilsTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/AgpConfiguratorUtilsTest.kt @@ -34,9 +34,9 @@ class AgpConfiguratorUtilsTest { writeText( // language=xml """ - - - """ + + + """ .trimIndent() ) } @@ -53,9 +53,9 @@ class AgpConfiguratorUtilsTest { writeText( // language=xml """ - - - """ + + + """ .trimIndent() ) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt index a1007b708b0..43b6c946ba5 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt @@ -549,9 +549,9 @@ class DependencyUtilsTest { tempFolder.newFile("gradle.properties").apply { writeText( """ - VERSION_NAME=1000.0.0 - ANOTHER_PROPERTY=true - """ + VERSION_NAME=1000.0.0 + ANOTHER_PROPERTY=true + """ .trimIndent() ) } @@ -560,9 +560,9 @@ class DependencyUtilsTest { tempFolder.newFile("version.properties").apply { writeText( """ - HERMES_V1_VERSION_NAME=1000.0.0 - ANOTHER_PROPERTY=true - """ + HERMES_V1_VERSION_NAME=1000.0.0 + ANOTHER_PROPERTY=true + """ .trimIndent() ) } @@ -583,11 +583,11 @@ class DependencyUtilsTest { tempFolder.newFile("gradle.properties").apply { writeText( """ - VERSION_NAME=0.0.0-20221101-2019-cfe811ab1 - HERMES_VERSION_NAME=0.12.0-commitly-20221101-2019-cfe811ab1 - HERMES_V1_VERSION_NAME=250829098.0.0-stable - ANOTHER_PROPERTY=true - """ + VERSION_NAME=0.0.0-20221101-2019-cfe811ab1 + HERMES_VERSION_NAME=0.12.0-commitly-20221101-2019-cfe811ab1 + HERMES_V1_VERSION_NAME=250829098.0.0-stable + ANOTHER_PROPERTY=true + """ .trimIndent() ) } @@ -596,9 +596,9 @@ class DependencyUtilsTest { tempFolder.newFile("version.properties").apply { writeText( """ - HERMES_V1_VERSION_NAME=250829098.0.0-stable - ANOTHER_PROPERTY=true - """ + HERMES_V1_VERSION_NAME=250829098.0.0-stable + ANOTHER_PROPERTY=true + """ .trimIndent() ) } @@ -619,8 +619,8 @@ class DependencyUtilsTest { tempFolder.newFile("gradle.properties").apply { writeText( """ - ANOTHER_PROPERTY=true - """ + ANOTHER_PROPERTY=true + """ .trimIndent() ) } @@ -629,8 +629,8 @@ class DependencyUtilsTest { tempFolder.newFile("version.properties").apply { writeText( """ - ANOTHER_PROPERTY=true - """ + ANOTHER_PROPERTY=true + """ .trimIndent() ) } @@ -650,9 +650,9 @@ class DependencyUtilsTest { tempFolder.newFile("gradle.properties").apply { writeText( """ - VERSION_NAME= - ANOTHER_PROPERTY=true - """ + VERSION_NAME= + ANOTHER_PROPERTY=true + """ .trimIndent() ) } @@ -661,9 +661,9 @@ class DependencyUtilsTest { tempFolder.newFile("version.properties").apply { writeText( """ - HERMES_V1_VERSION_NAME= - ANOTHER_PROPERTY=true - """ + HERMES_V1_VERSION_NAME= + ANOTHER_PROPERTY=true + """ .trimIndent() ) } @@ -683,10 +683,10 @@ class DependencyUtilsTest { tempFolder.newFile("gradle.properties").apply { writeText( """ - react.internal.publishingGroup=io.github.test - react.internal.hermesPublishingGroup=io.github.test - ANOTHER_PROPERTY=true - """ + react.internal.publishingGroup=io.github.test + react.internal.hermesPublishingGroup=io.github.test + ANOTHER_PROPERTY=true + """ .trimIndent() ) } @@ -695,9 +695,9 @@ class DependencyUtilsTest { tempFolder.newFile("version.properties").apply { writeText( """ - HERMES_V1_VERSION_NAME= - ANOTHER_PROPERTY=true - """ + HERMES_V1_VERSION_NAME= + ANOTHER_PROPERTY=true + """ .trimIndent() ) } @@ -716,8 +716,8 @@ class DependencyUtilsTest { tempFolder.newFile("gradle.properties").apply { writeText( """ - ANOTHER_PROPERTY=true - """ + ANOTHER_PROPERTY=true + """ .trimIndent() ) } @@ -726,9 +726,9 @@ class DependencyUtilsTest { tempFolder.newFile("version.properties").apply { writeText( """ - HERMES_V1_VERSION_NAME= - ANOTHER_PROPERTY=true - """ + HERMES_V1_VERSION_NAME= + ANOTHER_PROPERTY=true + """ .trimIndent() ) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt index a4d233cc721..d8690b83ab5 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt @@ -320,11 +320,11 @@ class PathUtilsTest { writeText( // language=json """ - { - "name": "a-library", - "codegenConfig": {} - } - """ + { + "name": "a-library", + "codegenConfig": {} + } + """ .trimIndent() ) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt index 2e1e3590fe1..a22933e6aac 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt @@ -150,11 +150,11 @@ class ProjectUtilsTest { writeText( // language=json """ - { - "name": "a-library", - "codegenConfig": {} - } - """ + { + "name": "a-library", + "codegenConfig": {} + } + """ .trimIndent() ) } @@ -170,10 +170,10 @@ class ProjectUtilsTest { writeText( // language=json """ - { - "name": "a-library" - } - """ + { + "name": "a-library" + } + """ .trimIndent() ) } diff --git a/packages/gradle-plugin/settings-plugin/src/test/kotlin/com/facebook/react/ReactSettingsExtensionTest.kt b/packages/gradle-plugin/settings-plugin/src/test/kotlin/com/facebook/react/ReactSettingsExtensionTest.kt index ee0e9eae45e..ffb38a362fc 100644 --- a/packages/gradle-plugin/settings-plugin/src/test/kotlin/com/facebook/react/ReactSettingsExtensionTest.kt +++ b/packages/gradle-plugin/settings-plugin/src/test/kotlin/com/facebook/react/ReactSettingsExtensionTest.kt @@ -238,30 +238,30 @@ class ReactSettingsExtensionTest { File(generatedFolder, "autolinking.json").apply { writeText( """ - { - "root": "/", - "reactNativePath": "/node_modules/react-native", - "reactNativeVersion": "0.75", - "dependencies": {}, - "healthChecks": [], - "platforms": { - "ios": {}, - "android": {} - }, - "assets": [], - "project": { - "ios": {}, - "android": { - "sourceDir": "/", - "appName": "app", - "packageName": "com.TestApp", - "applicationId": "com.TestApp", - "mainActivity": ".MainActivity", - "assets": [] - } - } - } - """ + { + "root": "/", + "reactNativePath": "/node_modules/react-native", + "reactNativeVersion": "0.75", + "dependencies": {}, + "healthChecks": [], + "platforms": { + "ios": {}, + "android": {} + }, + "assets": [], + "project": { + "ios": {}, + "android": { + "sourceDir": "/", + "appName": "app", + "packageName": "com.TestApp", + "applicationId": "com.TestApp", + "mainActivity": ".MainActivity", + "assets": [] + } + } + } + """ .trimIndent() ) } @@ -309,13 +309,13 @@ class ReactSettingsExtensionTest { File(generatedFolder, "autolinking.json").apply { writeText( """ - { - "project": { - "ios": {}, - "android": {} - } - } - """ + { + "project": { + "ios": {}, + "android": {} + } + } + """ .trimIndent() ) } diff --git a/packages/gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt b/packages/gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt index d741ac1812f..0544a877547 100644 --- a/packages/gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt +++ b/packages/gradle-plugin/shared/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt @@ -197,10 +197,10 @@ class JsonUtilsTest { val validJson = createJsonFile( """ - + > AwesomeProject@0.0.1 npx > rnc-cli config - + { "reactNativeVersion": "1000.0.0", "project": { diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/util/JSStackTraceTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/util/JSStackTraceTest.kt index b837e81924a..6bd08bb3927 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/util/JSStackTraceTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/util/JSStackTraceTest.kt @@ -101,7 +101,7 @@ class JSStackTraceTest { method_from_segment_with_address@seg-1.js:9:18 method_from_ram_segment@seg-3_198.js:10:20 method_from_ram_segment_with_address@seg-3_198.js:10:20 - + """ .trimIndent() )