mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-05 22:56:11 +00:00
Added CI workflow and local pre-commit hook for formatting and linting the newly added JS, iOS and Android code.
136 lines
4.6 KiB
Groovy
136 lines
4.6 KiB
Groovy
buildscript {
|
|
// The Android Gradle plugin is only required when opening the android folder stand-alone.
|
|
// This avoids unnecessary downloads and potential conflicts when the library is included as a
|
|
// module dependency in an application project.
|
|
if (project == rootProject) {
|
|
repositories {
|
|
mavenCentral()
|
|
google()
|
|
}
|
|
|
|
dependencies {
|
|
classpath("com.android.tools.build:gradle:3.6.1")
|
|
classpath "com.diffplug.spotless:spotless-plugin-gradle:5.15.0"
|
|
}
|
|
}
|
|
}
|
|
|
|
def isNewArchitectureEnabled() {
|
|
// To opt-in for the New Architecture, you can either:
|
|
// - Set `newArchEnabled` to true inside the `gradle.properties` file
|
|
// - Invoke gradle with `-newArchEnabled=true`
|
|
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
|
|
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
|
|
}
|
|
|
|
if (isNewArchitectureEnabled()) {
|
|
apply plugin: "com.facebook.react"
|
|
}
|
|
|
|
if (project == rootProject) {
|
|
apply from: 'spotless.gradle'
|
|
}
|
|
|
|
apply plugin: 'com.android.library'
|
|
|
|
def safeExtGet(prop, fallback) {
|
|
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
}
|
|
|
|
android {
|
|
compileSdkVersion safeExtGet('compileSdkVersion', 28)
|
|
|
|
// Used to override the NDK path/version on internal CI or by allowing
|
|
// users to customize the NDK path/version from their root project (e.g. for M1 support)
|
|
if (rootProject.hasProperty("ndkPath")) {
|
|
ndkPath rootProject.ext.ndkPath
|
|
}
|
|
if (rootProject.hasProperty("ndkVersion")) {
|
|
ndkVersion rootProject.ext.ndkVersion
|
|
}
|
|
|
|
defaultConfig {
|
|
minSdkVersion safeExtGet('minSdkVersion', 16)
|
|
//noinspection OldTargetApi
|
|
targetSdkVersion safeExtGet('targetSdkVersion', 28)
|
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
if (isNewArchitectureEnabled()) {
|
|
var appProject = rootProject.allprojects.find {it.plugins.hasPlugin('com.android.application')}
|
|
externalNativeBuild {
|
|
ndkBuild {
|
|
arguments "APP_PLATFORM=android-21",
|
|
"APP_STL=c++_shared",
|
|
"NDK_TOOLCHAIN_VERSION=clang",
|
|
"GENERATED_SRC_DIR=${appProject.buildDir}/generated/source",
|
|
"PROJECT_BUILD_DIR=${appProject.buildDir}",
|
|
"REACT_ANDROID_DIR=${appProject.rootDir}/../node_modules/react-native/ReactAndroid",
|
|
"REACT_ANDROID_BUILD_DIR=${appProject.rootDir}/../node_modules/react-native/ReactAndroid/build"
|
|
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
|
|
cppFlags "-std=c++17"
|
|
targets "rnsvg_modules"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
lintOptions {
|
|
abortOnError false
|
|
}
|
|
|
|
if (isNewArchitectureEnabled()) {
|
|
externalNativeBuild {
|
|
ndkBuild {
|
|
path "src/main/jni/Android.mk"
|
|
}
|
|
}
|
|
}
|
|
packagingOptions {
|
|
// For some reason gradle only complains about the duplicated version of libreact_render libraries
|
|
// while there are more libraries copied in intermediates folder of the lib build directory, we exlude
|
|
// only the ones that make the build fail (ideally we should only include librnscreens_modules but we
|
|
// are only allowed to specify exlude patterns)
|
|
exclude "**/libreact_render*.so"
|
|
}
|
|
|
|
sourceSets.main {
|
|
java {
|
|
if (isNewArchitectureEnabled()) {
|
|
srcDirs += [
|
|
"src/fabric/java",
|
|
]
|
|
} else {
|
|
srcDirs += [
|
|
"src/paper/java",
|
|
"build/generated/source/codegen/java"
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
mavenLocal()
|
|
google()
|
|
maven {
|
|
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
|
|
url "$rootDir/../node_modules/react-native/android"
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
if (isNewArchitectureEnabled()) {
|
|
implementation project(":ReactAndroid")
|
|
} else {
|
|
implementation 'com.facebook.react:react-native:+'
|
|
}
|
|
}
|
|
|
|
if (isNewArchitectureEnabled()) {
|
|
react {
|
|
reactRoot = rootProject.file("../node_modules/react-native/")
|
|
jsRootDir = file("../src/fabric/")
|
|
codegenDir = rootProject.file("../node_modules/react-native-codegen/")
|
|
libraryName = "rnsvg"
|
|
codegenJavaPackageName = "com.horcrux.rnsvg"
|
|
}
|
|
} |