Skip to content

Commit 20d70f9

Browse files
committed
publish new version with fixed breaking changes
1 parent b0a9a3c commit 20d70f9

22 files changed

+463
-218
lines changed

android/build.gradle

Lines changed: 116 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,154 +1,139 @@
1-
// android/build.gradle
2-
3-
// based on:
4-
//
5-
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle
6-
// original location:
7-
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/build.gradle
8-
//
9-
// * https://github.com/facebook/react-native/blob/0.60-stable/template/android/app/build.gradle
10-
// original location:
11-
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
12-
13-
def DEFAULT_COMPILE_SDK_VERSION = 28
14-
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
15-
def DEFAULT_MIN_SDK_VERSION = 16
16-
def DEFAULT_TARGET_SDK_VERSION = 28
17-
18-
def safeExtGet(prop, fallback) {
19-
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
1+
buildscript {
2+
repositories {
3+
google()
4+
mavenCentral()
5+
}
6+
7+
dependencies {
8+
classpath 'com.android.tools.build:gradle:3.5.3'
9+
}
2010
}
2111

22-
apply plugin: 'com.android.library'
23-
apply plugin: 'maven'
24-
25-
buildscript {
26-
// The Android Gradle plugin is only required when opening the android folder stand-alone.
27-
// This avoids unnecessary downloads and potential conflicts when the library is included as a
28-
// module dependency in an application project.
29-
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
30-
if (project == rootProject) {
31-
repositories {
32-
google()
33-
jcenter()
34-
}
35-
dependencies {
36-
classpath 'com.android.tools.build:gradle:3.4.1'
37-
}
38-
}
12+
def isNewArchitectureEnabled() {
13+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
3914
}
4015

4116
apply plugin: 'com.android.library'
42-
apply plugin: 'maven'
4317

44-
android {
45-
compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
46-
buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
47-
defaultConfig {
48-
minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
49-
targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
50-
versionCode 1
51-
versionName "1.0"
52-
}
53-
lintOptions {
54-
abortOnError false
55-
}
56-
compileOptions {
57-
sourceCompatibility = 1.8
58-
targetCompatibility = 1.8
59-
}
18+
if (isNewArchitectureEnabled()) {
19+
apply plugin: 'com.facebook.react'
6020
}
6121

62-
repositories {
63-
// ref: https://www.baeldung.com/maven-local-repository
64-
mavenLocal()
65-
maven {
66-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
67-
url "$rootDir/../node_modules/react-native/android"
68-
}
69-
maven {
70-
// Android JSC is installed from npm
71-
url "$rootDir/../node_modules/jsc-android/dist"
72-
}
73-
google()
74-
jcenter()
22+
def getExtOrDefault(name) {
23+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RnInAppUpdate_' + name]
7524
}
7625

77-
dependencies {
78-
//noinspection GradleDynamicVersion
79-
implementation 'com.facebook.react:react-native:+' // From node_modules
80-
implementation 'com.google.android.play:core:1.7.3'
26+
def getExtOrIntegerDefault(name) {
27+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['RnInAppUpdate_' + name]).toInteger()
8128
}
8229

83-
def configureReactNativePom(def pom) {
84-
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
85-
86-
pom.project {
87-
name packageJson.title
88-
artifactId packageJson.name
89-
version = packageJson.version
90-
group = "com.reactlibrary.inappupdate"
91-
description packageJson.description
92-
url packageJson.repository.baseUrl
93-
94-
licenses {
95-
license {
96-
name packageJson.license
97-
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
98-
distribution 'repo'
99-
}
100-
}
101-
102-
developers {
103-
developer {
104-
id packageJson.author.username
105-
name packageJson.author.name
106-
}
107-
}
30+
android {
31+
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
32+
33+
defaultConfig {
34+
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
35+
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
36+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
37+
}
38+
buildTypes {
39+
release {
40+
minifyEnabled false
10841
}
109-
}
42+
}
11043

111-
afterEvaluate { project ->
112-
// some Gradle build hooks ref:
113-
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
114-
task androidJavadoc(type: Javadoc) {
115-
source = android.sourceSets.main.java.srcDirs
116-
classpath += files(android.bootClasspath)
117-
classpath += files(project.getConfigurations().getByName('compile').asList())
118-
include '**/*.java'
119-
}
44+
lintOptions {
45+
disable 'GradleCompatible'
46+
}
12047

121-
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
122-
classifier = 'javadoc'
123-
from androidJavadoc.destinationDir
124-
}
48+
compileOptions {
49+
sourceCompatibility JavaVersion.VERSION_1_8
50+
targetCompatibility JavaVersion.VERSION_1_8
51+
}
52+
}
12553

126-
task androidSourcesJar(type: Jar) {
127-
classifier = 'sources'
128-
from android.sourceSets.main.java.srcDirs
129-
include '**/*.java'
54+
repositories {
55+
mavenCentral()
56+
google()
57+
58+
def found = false
59+
def defaultDir = null
60+
def androidSourcesName = 'React Native sources'
61+
62+
if (rootProject.ext.has('reactNativeAndroidRoot')) {
63+
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
64+
} else {
65+
defaultDir = new File(
66+
projectDir,
67+
'/../../../node_modules/react-native/android'
68+
)
69+
}
70+
71+
if (defaultDir.exists()) {
72+
maven {
73+
url defaultDir.toString()
74+
name androidSourcesName
13075
}
13176

132-
android.libraryVariants.all { variant ->
133-
def name = variant.name.capitalize()
134-
def javaCompileTask = variant.javaCompileProvider.get()
77+
logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
78+
found = true
79+
} else {
80+
def parentDir = rootProject.projectDir
81+
82+
1.upto(5, {
83+
if (found) return true
84+
parentDir = parentDir.parentFile
85+
86+
def androidSourcesDir = new File(
87+
parentDir,
88+
'node_modules/react-native'
89+
)
90+
91+
def androidPrebuiltBinaryDir = new File(
92+
parentDir,
93+
'node_modules/react-native/android'
94+
)
95+
96+
if (androidPrebuiltBinaryDir.exists()) {
97+
maven {
98+
url androidPrebuiltBinaryDir.toString()
99+
name androidSourcesName
100+
}
135101

136-
task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
137-
from javaCompileTask.destinationDir
102+
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
103+
found = true
104+
} else if (androidSourcesDir.exists()) {
105+
maven {
106+
url androidSourcesDir.toString()
107+
name androidSourcesName
138108
}
139-
}
140109

141-
artifacts {
142-
archives androidSourcesJar
143-
archives androidJavadocJar
144-
}
110+
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
111+
found = true
112+
}
113+
})
114+
}
115+
116+
if (!found) {
117+
throw new GradleException(
118+
"${project.name}: unable to locate React Native android sources. " +
119+
"Ensure you have you installed React Native as a dependency in your project and try again."
120+
)
121+
}
122+
}
145123

146-
task installArchives(type: Upload) {
147-
configuration = configurations.archives
148-
repositories.mavenDeployer {
149-
// Deploy to react-native-event-bridge/maven, ready to publish to npm
150-
repository url: "file://${projectDir}/../android/maven"
151-
configureReactNativePom pom
152-
}
153-
}
124+
125+
dependencies {
126+
//noinspection GradleDynamicVersion
127+
implementation "com.facebook.react:react-native:+"
128+
// implementation 'com.google.android.play:app-update:2.0.0'
129+
// From node_modules
130+
implementation 'com.google.android.play:core:1.10.3'
131+
}
132+
133+
if (isNewArchitectureEnabled()) {
134+
react {
135+
jsRootDir = file("../src/")
136+
libraryName = "RnInAppUpdate"
137+
codegenJavaPackageName = "com.logicwind.inappupdate"
138+
}
154139
}

android/gradle.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
RnInAppUpdate_kotlinVersion=1.7.0
2+
RnInAppUpdate_minSdkVersion=21
3+
RnInAppUpdate_targetSdkVersion=31
4+
RnInAppUpdate_compileSdkVersion=31
5+
RnInAppUpdate_ndkversion=21.4.7075529
5.08 KB
Binary file not shown.
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#Sat Jun 27 19:12:06 IST 2020
21
distributionBase=GRADLE_USER_HOME
32
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

android/gradlew

100644100755
Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
#!/usr/bin/env sh
22

3+
#
4+
# Copyright 2015 the original author or authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# https://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
319
##############################################################################
420
##
521
## Gradle start up script for UN*X
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
2844
APP_BASE_NAME=`basename "$0"`
2945

3046
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31-
DEFAULT_JVM_OPTS=""
47+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
3248

3349
# Use the maximum available, or set MAX_FD != -1 to use that value.
3450
MAX_FD="maximum"
@@ -56,7 +72,7 @@ case "`uname`" in
5672
Darwin* )
5773
darwin=true
5874
;;
59-
MINGW* )
75+
MSYS* | MINGW* )
6076
msys=true
6177
;;
6278
NONSTOP* )
@@ -66,6 +82,7 @@ esac
6682

6783
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
6884

85+
6986
# Determine the Java command to use to start the JVM.
7087
if [ -n "$JAVA_HOME" ] ; then
7188
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
@@ -109,10 +126,11 @@ if $darwin; then
109126
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110127
fi
111128

112-
# For Cygwin, switch paths to Windows format before running java
113-
if $cygwin ; then
129+
# For Cygwin or MSYS, switch paths to Windows format before running java
130+
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
114131
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115132
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133+
116134
JAVACMD=`cygpath --unix "$JAVACMD"`
117135

118136
# We build the pattern for arguments to be converted via cygpath
@@ -138,19 +156,19 @@ if $cygwin ; then
138156
else
139157
eval `echo args$i`="\"$arg\""
140158
fi
141-
i=$((i+1))
159+
i=`expr $i + 1`
142160
done
143161
case $i in
144-
(0) set -- ;;
145-
(1) set -- "$args0" ;;
146-
(2) set -- "$args0" "$args1" ;;
147-
(3) set -- "$args0" "$args1" "$args2" ;;
148-
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149-
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150-
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151-
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152-
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153-
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
162+
0) set -- ;;
163+
1) set -- "$args0" ;;
164+
2) set -- "$args0" "$args1" ;;
165+
3) set -- "$args0" "$args1" "$args2" ;;
166+
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
167+
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
168+
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
169+
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
170+
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
171+
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154172
esac
155173
fi
156174

@@ -159,14 +177,9 @@ save () {
159177
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160178
echo " "
161179
}
162-
APP_ARGS=$(save "$@")
180+
APP_ARGS=`save "$@"`
163181

164182
# Collect all arguments for the java command, following the shell quoting and substitution rules
165183
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166184

167-
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168-
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169-
cd "$(dirname "$0")"
170-
fi
171-
172185
exec "$JAVACMD" "$@"

0 commit comments

Comments
 (0)