Skip to content

Commit

Permalink
RNGP - Add autolinking fields to ReactExtensions (#44220)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #44220

This diff is part of RFC0759
react-native-community/discussions-and-proposals#759

Here we're looking into splitting the autolinking into a component that will live inside core (specifically inside the React Native Gradle Plugin - RNGP) and another component that will live inside the Community CLI.

Here I start by adding 2 fields to RNGP extension, that frameworks and templates can use to provide their autolinking config.

Changelog:
[Internal] [Changed] - RNGP - Add autolinking fields to ReactExtensions

Reviewed By: cipolleschi

Differential Revision: D55475597

fbshipit-source-id: 316d1919a113a94c57426710f487f334c6128345
  • Loading branch information
cortinico authored and facebook-github-bot committed Apr 26, 2024
1 parent b53c439 commit 2455eab
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.facebook.react.utils.projectPathToLibraryName
import javax.inject.Inject
import org.gradle.api.Project
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.FileCollection
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
Expand Down Expand Up @@ -147,4 +148,35 @@ abstract class ReactExtension @Inject constructor(project: Project) {
*/
val codegenJavaPackageName: Property<String> =
objects.property(String::class.java).convention("com.facebook.fbreact.specs")

/** Auto-linking Config */

/**
* Location of the JSON file used to configure autolinking. This file is the output of the
* `@react-native-community/cli` config command.
*
* If not specified, RNGP will just invoke whatever you pass as [autolinkConfigCommand].
*/
val autolinkConfigFile: RegularFileProperty = objects.fileProperty()

/**
* The command to invoke as source of truth for the autolinking configuration. Default is `["npx",
* "@react-native-community/cli", "config"]`.
*/
val autolinkConfigCommand: ListProperty<String> =
objects
.listProperty(String::class.java)
.convention(listOf("npx", "@react-native-community/cli", "config"))

/**
* Location of the lock files used to consider wether autolinking [autolinkConfigCommand] should
* re-execute or not. If file collection is unchanged, the autolinking command will not be
* re-executed.
*
* If not specified, RNGP will just look for both yarn.lock and package.lock in the [root] folder.
*/
val autolinkLockFiles: Property<FileCollection> =
objects
.property(FileCollection::class.java)
.convention(root.files("../yarn.lock", "../package-lock.json"))
}

0 comments on commit 2455eab

Please sign in to comment.