Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 35 additions & 41 deletions packages/react-native-gesture-handler/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ buildscript {

dependencies {
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
classpath("com.android.tools.build:gradle:7.2.1")
classpath("com.diffplug.spotless:spotless-plugin-gradle:7.0.3")
classpath("com.android.tools.build:gradle:8.10.1")
classpath("com.diffplug.spotless:spotless-plugin-gradle:7.0.4")
}
}

Expand Down Expand Up @@ -45,6 +45,7 @@ def resolveReactNativeDirectory() {
commandLine("node", "--print", "require.resolve('react-native/package.json')")
}.standardOutput.asText.get().trim()
)

if (reactNativePackage.exists()) {
return reactNativePackage.parentFile
}
Expand All @@ -59,41 +60,53 @@ def resolveReactNativeDirectory() {
if (isNewArchitectureEnabled()) {
apply plugin: 'com.facebook.react'
}

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

if (project == rootProject) {
apply from: "spotless.gradle"
}

def getExternalLibVersion(project){
def inputFile = new File(project.projectDir, "../package.json")
def json = new JsonSlurper().parseText(inputFile.text)
def libVerision = json.version as String
def (major, minor, patch) = libVerision.tokenize('.')

// Handle cases where version is a pre-release one, e.g. "2.3.0-alpha.1"
def patchVersion = patch.find(/(\d+)/) ? patch.find(/(\d+)/) : "0"

return [Integer.parseInt(major), Integer.parseInt(minor), Integer.parseInt(patchVersion)]
}

// Check whether Reanimated 2.3 or higher is installed alongside Gesture Handler
def shouldUseCommonInterfaceFromReanimated() {
def reanimated = rootProject.subprojects.find { it.name == 'react-native-reanimated' }
if (reanimated != null) {
def inputFile = new File(reanimated.projectDir, '../package.json')
def json = new JsonSlurper().parseText(inputFile.text)
def reanimatedVersion = json.version as String
def (major, minor, patch) = reanimatedVersion.tokenize('.')
return (Integer.parseInt(major) == 2 && Integer.parseInt(minor) >= 3) || Integer.parseInt(major) >= 3
} else {

if (reanimated == null) {
return false
}

def (major, minor, patch) = getExternalLibVersion(reanimated)

return (major == 2 && minor >= 3) || major >= 3
}

def shouldUseCommonInterfaceFromRNSVG() {
// common interface compatible with react-native-svg >= 15.11.2
def rnsvg = rootProject.subprojects.find { it.name == 'react-native-svg' }

if (rnsvg == null) {
return false
}

def inputFile = new File(rnsvg.projectDir, '../package.json')
def json = new JsonSlurper().parseText(inputFile.text)
def rnsvgVersion = json.version as String
def (major, minor, patch) = rnsvgVersion.tokenize('.')
return (Integer.parseInt(major) == 15 && Integer.parseInt(minor) == 11 && Integer.parseInt(patch) >= 2) ||
(Integer.parseInt(major) == 15 && Integer.parseInt(minor) > 11) ||
Integer.parseInt(major) > 15
def (major, minor, patch) = getExternalLibVersion(rnsvg)


return (major == 15 && minor == 11 && patch >= 2) ||
(major == 15 && minor > 11) ||
major > 15
}

def reactNativeArchitectures() {
Expand All @@ -107,7 +120,7 @@ def reactProperties = new Properties()
file("$REACT_NATIVE_DIR/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }

def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger()
def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.split("\\.")[1].toInteger()

repositories {
mavenCentral()
Expand All @@ -116,7 +129,7 @@ repositories {
android {
compileSdkVersion safeExtGet("compileSdkVersion", 33)

namespace "com.swmansion.gesturehandler"
namespace = "com.swmansion.gesturehandler"
buildFeatures {
buildConfig = true
prefab = true
Expand All @@ -132,10 +145,8 @@ android {
}

defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 21)
minSdkVersion safeExtGet('minSdkVersion', 24)
targetSdkVersion safeExtGet('targetSdkVersion', 33)
versionCode 1
versionName "1.0"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
buildConfigField "int", "REACT_NATIVE_MINOR_VERSION", REACT_NATIVE_MINOR_VERSION.toString()

Expand Down Expand Up @@ -180,12 +191,9 @@ android {

sourceSets.main {
java {
// Include "common/" only when it's not provided by Reanimated to mitigate
// multiple definitions of the same class preventing build
if (shouldUseCommonInterfaceFromReanimated()) {
srcDirs += 'reanimated/src/main/java'
} else {
srcDirs += 'common/src/main/java'
srcDirs += 'noreanimated/src/main/java'
}

Expand All @@ -200,21 +208,7 @@ android {
} else {
// 'paper/src/main/java' includes files from codegen so the library can compile with
// codegen turned off

if (REACT_NATIVE_MINOR_VERSION > 77) {
srcDirs += 'paper/src/main/java'
} else {
srcDirs += 'paper77/src/main/java'
}
}

if (REACT_NATIVE_MINOR_VERSION >= 77) {
// With RN 0.77, ViewManager related functions in the package has different signatures as they
// are no longer nullable
srcDirs += 'package77/src/main/java'
} else {
// It's safe to delete this block once we drop support for RN 0.76
srcDirs += 'packageDeprecated/src/main/java'
srcDirs += 'paper/src/main/java'
}
}
}
Expand Down Expand Up @@ -252,7 +246,7 @@ dependencies {
implementation rootProject.subprojects.find { it.name == 'react-native-svg' }
}

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation "androidx.core:core-ktx:1.6.0"
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation "androidx.core:core-ktx:1.16.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemor
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
RNGH_kotlinVersion=1.6.21
RNGH_kotlinVersion=2.0.21
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 6 additions & 0 deletions packages/react-native-gesture-handler/android/gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions packages/react-native-gesture-handler/android/gradlew.bat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

Loading