Skip to content

Commit d08fab0

Browse files
authored
Remove multiple instances check when building (#2569)
## Description Removes the code responsible for checking whether more than one instance of Gesture Handler is installed. While the idea is good, there are some problems with the approach - mainly symlinks. We should consider doing the same thing as Reanimared - comparing the version of native code against JS. ## Test plan Check example apps
1 parent 703fd3a commit d08fab0

File tree

3 files changed

+0
-84
lines changed

3 files changed

+0
-84
lines changed

RNGestureHandler.podspec

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,6 @@ require "json"
22

33
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
44

5-
isUserApp = File.exist?(File.join(__dir__, "..", "..", "node_modules", "react-native", "package.json"))
6-
if isUserApp
7-
libInstances = %x[find ../../ -name "package.json" | grep "/react-native-gesture-handler/package.json" | grep -v "/.yarn/"]
8-
libInstancesArray = libInstances.split("\n")
9-
if libInstancesArray.length() > 1
10-
parsedLocation = ''
11-
for location in libInstancesArray
12-
location['../../'] = '- '
13-
location['/package.json'] = ''
14-
parsedLocation += location + "\n"
15-
end
16-
raise "[Gesture Handler] Multiple versions of Gesture Handler were detected. Only one instance of react-native-gesture-handler can be installed in a project. You need to resolve the conflict manually. Check out the documentation: https://docs.swmansion.com/react-native-gesture-handler/docs/troubleshooting#multiple-versions-of-reanimated-were-detected \n\nConflict between: \n" + parsedLocation
17-
end
18-
end
19-
205
Pod::Spec.new do |s|
216
# NPM package specification
227
package = JSON.parse(File.read(File.join(File.dirname(__FILE__), "package.json")))

android/build.gradle

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,6 @@ if (project == rootProject) {
6868
apply from: "spotless.gradle"
6969
}
7070

71-
def shouldAssertNoMultipleInstances() {
72-
if (rootProject.hasProperty("disableMultipleInstancesCheck")) {
73-
return rootProject.property("disableMultipleInstancesCheck") != "true"
74-
} else {
75-
return true
76-
}
77-
}
78-
7971
// Check whether Reanimated 2.3 or higher is installed alongside Gesture Handler
8072
def shouldUseCommonInterfaceFromReanimated() {
8173
def reanimated = rootProject.subprojects.find { it.name == 'react-native-reanimated' }
@@ -103,65 +95,6 @@ file("$REACT_NATIVE_DIR/ReactAndroid/gradle.properties").withInputStream { react
10395
def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
10496
def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
10597

106-
107-
abstract class NoMultipleInstancesAssertionTask extends DefaultTask {
108-
@Inject abstract ObjectFactory getObjectFactory()
109-
110-
@Input abstract Property<File> getProjectDirFile()
111-
@Input abstract Property<File> getRootDirFile()
112-
@Input abstract Property<Boolean> getShouldCheck()
113-
114-
def findGestureHandlerInstancesForPath(String path) {
115-
return objectFactory.fileTree().from(path)
116-
.include("**/react-native-gesture-handler/package.json")
117-
.exclude("**/.yarn/**")
118-
.exclude({ Files.isSymbolicLink(it.getFile().toPath()) })
119-
.findAll()
120-
}
121-
122-
@TaskAction
123-
def check() {
124-
if (shouldCheck.get()) {
125-
// Assert there are no multiple installations of Gesture Handler
126-
Set<File> files
127-
128-
if (projectDirFile.get().parent.contains(rootDirFile.get().parent)) {
129-
// standard app
130-
files = findGestureHandlerInstancesForPath(rootDirFile.get().parent + "/node_modules")
131-
} else {
132-
// monorepo
133-
files = findGestureHandlerInstancesForPath(rootDirFile.get().parent + "/node_modules")
134-
files.addAll(
135-
findGestureHandlerInstancesForPath(projectDirFile.get().parentFile.parent)
136-
)
137-
}
138-
139-
if (files.size() > 1) {
140-
String parsedLocation = files.stream().map({
141-
File file -> "- " + file.toString().replace("/package.json", "")
142-
}).collect().join("\n")
143-
String exceptionMessage = "\n[react-native-gesture-handler] Multiple versions of Gesture Handler " +
144-
"were detected. Only one instance of react-native-gesture-handler can be installed in a " +
145-
"project. You need to resolve the conflict manually. Check out the documentation: " +
146-
"https://docs.swmansion.com/react-native-gesture-handler/docs/troubleshooting" +
147-
"#multiple-instances-of-gesture-handler-were-detected \n\nConflict between: \n" +
148-
parsedLocation + "\n"
149-
throw new GradleException(exceptionMessage)
150-
}
151-
}
152-
}
153-
}
154-
155-
tasks.register('assertNoMultipleInstances', NoMultipleInstancesAssertionTask) {
156-
shouldCheck = shouldAssertNoMultipleInstances()
157-
rootDirFile = rootDir
158-
projectDirFile = projectDir
159-
}
160-
161-
tasks.preBuild {
162-
dependsOn assertNoMultipleInstances
163-
}
164-
16598
repositories {
16699
mavenCentral()
167100
}

example/android/gradle.properties

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,3 @@ newArchEnabled=false
4141
# Use this property to enable or disable the Hermes JS engine.
4242
# If set to false, you will be using JSC instead.
4343
hermesEnabled=true
44-
45-
disableMultipleInstancesCheck=false

0 commit comments

Comments
 (0)