Skip to content

Commit 15084dc

Browse files
authored
Merge pull request #25 from bugfender/feature/update_module
Feature/update module
2 parents 0a5a786 + 848b68d commit 15084dc

13 files changed

Lines changed: 254 additions & 218 deletions

File tree

.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# node.js
6+
#
7+
node_modules/
8+
npm-debug.log
9+
yarn-error.log
10+
11+
# Xcode
12+
#
13+
build/
14+
*.pbxuser
15+
!default.pbxuser
16+
*.mode1v3
17+
!default.mode1v3
18+
*.mode2v3
19+
!default.mode2v3
20+
*.perspectivev3
21+
!default.perspectivev3
22+
xcuserdata
23+
*.xccheckout
24+
*.moved-aside
25+
DerivedData
26+
*.hmap
27+
*.ipa
28+
*.xcuserstate
29+
project.xcworkspace
30+
31+
# Android/IntelliJ
32+
#
33+
build/
34+
.idea
35+
.gradle
36+
local.properties
37+
*.iml
38+
39+
# BUCK
40+
buck-out/
41+
\.buckd/
42+
*.keystore

README.md

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,7 @@ Add the bugfender plugin from npm
2828
`$ npm install @bugfender/rn-bugfender --save`
2929

3030
### Android
31-
If you are using react-native 0.60 or above, you are done!
32-
33-
**If using an older version of react-native** you still need to link the module to your project:
34-
```
35-
// Add the classes of the plugin to your android and iOS projects
36-
$ npx react-native link @bugfender/rn-bugfender`
37-
```
31+
You are done!
3832

3933
### iOS
4034
You can finish the installation manually or via CocoaPods (recommended)
@@ -46,33 +40,16 @@ You can finish the installation manually or via CocoaPods (recommended)
4640
$ cd path_to_your_project/ios
4741
$ pod init
4842
```
49-
50-
2. Link your project (**only on react-native versions prior 0.60**):
51-
```
52-
// Add the classes of the plugin to your android and iOS projects
53-
$ npx react-native link @bugfender/rn-bugfender`
54-
```
55-
5643
Make sure you're targeting at least iOS platform version 10 (specify `platform :ios, '10.0'`).
5744

58-
A new line should have been added automatically to your Podfile:
59-
60-
`pod 'RNBugfender', :path => '../node_modules/@bugfender/rn-bugfender'`
61-
62-
3. After configuring the podfile you can now go to the console and run
45+
2. After configuring the podfile you can now go to the console and run
6346

6447
`$ pod install`
6548

6649
When the installation has finished you should be able to run your project in iOS and Android.
6750

6851
**Remember that you should be using the Xcode workspace instead of the xcodeproj file from now on.**
6952

70-
**Important**: the *podspec* of RNBugfender declares React as a dependency. Your Podfile must explicitly override that React dependency. Like this:
71-
72-
`pod 'React', path: '../node_modules/react-native'`
73-
74-
If you created your project with the react-native cli from React Native 0.60 or newer your podfile should be already prepared. For older versions of react-native you must ensure to override it. Otherwise, CocoaPods will download and install a new version in your iOS folder and you will end up with all the React libraries duplicated.
75-
7653
*At the end of this document you can find a **[recommended podfile](#recommended-podfile)**. You can use it as an example*.
7754

7855
If you have any problems compiling or executing, try our [Troubleshooting section](#cocoapods-troubleshooting) at the end of this document.

RNBugfender.podspec

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
require 'json'
1+
# @bugfender/rn-bugfender.podspec
22

3-
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
3+
require "json"
4+
5+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
46

57
Pod::Spec.new do |s|
68
s.name = "RNBugfender"
@@ -11,14 +13,15 @@ Pod::Spec.new do |s|
1113
s.author = package['author']
1214
s.homepage = package['homepage']
1315

14-
s.platform = :ios, "10.0"
16+
s.platforms = { :ios => "10.0" }
1517
s.requires_arc = true
1618
s.static_framework = true
1719

1820
s.source = { :git => "https://github.com/bugfender/BugfenderSDK-iOS", :tag => "master" }
1921
s.source_files = 'ios/*.{h,m}'
2022

21-
s.dependency 'React'
23+
s.dependency "React"
2224
s.dependency 'BugfenderSDK', '~> 1.10.3'
2325

2426
end
27+

android/build.gradle

Lines changed: 133 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,103 +1,150 @@
1-
buildscript {
2-
repositories {
3-
jcenter()
4-
maven { url 'https://maven.google.com' }
5-
}
6-
7-
dependencies {
8-
classpath 'com.android.tools.build:gradle:3.2.1'
9-
}
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+
// previous 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+
// previous location:
11+
// - https://github.com/facebook/react-native/blob/0.58-stable/local-cli/templates/HelloWorld/android/app/build.gradle
12+
13+
// These defaults should reflect the SDK versions used by
14+
// the minimum React Native version supported.
15+
def DEFAULT_COMPILE_SDK_VERSION = 28
16+
def DEFAULT_BUILD_TOOLS_VERSION = '28.0.3'
17+
def DEFAULT_MIN_SDK_VERSION = 16
18+
def DEFAULT_TARGET_SDK_VERSION = 28
19+
20+
def safeExtGet(prop, fallback) {
21+
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
1022
}
1123

1224
apply plugin: 'com.android.library'
25+
apply plugin: 'maven'
26+
27+
buildscript {
28+
// The Android Gradle plugin is only required when opening the android folder stand-alone.
29+
// This avoids unnecessary downloads and potential conflicts when the library is included as a
30+
// module dependency in an application project.
31+
// ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
32+
if (project == rootProject) {
33+
repositories {
34+
google()
35+
}
36+
dependencies {
37+
// This should reflect the Gradle plugin version used by
38+
// the minimum React Native version supported.
39+
classpath 'com.android.tools.build:gradle:3.4.1'
40+
}
41+
}
42+
}
1343

1444
android {
15-
compileSdkVersion 28
16-
buildToolsVersion '28.0.3'
17-
18-
defaultConfig {
19-
minSdkVersion 16
20-
targetSdkVersion 28
21-
versionCode 1
22-
versionName "1.0"
23-
}
24-
25-
lintOptions {
26-
abortOnError false
27-
}
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+
}
2856
}
2957

3058
repositories {
31-
jcenter()
32-
google()
33-
34-
def found = false
35-
def defaultDir = null
36-
def androidSourcesName = 'React Native sources'
37-
38-
if (rootProject.ext.has('reactNativeAndroidRoot')) {
39-
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
40-
} else {
41-
defaultDir = new File(
42-
projectDir,
43-
'/../../../node_modules/react-native/android'
44-
)
45-
}
46-
47-
if (defaultDir.exists()) {
59+
// ref: https://www.baeldung.com/maven-local-repository
60+
mavenLocal()
61+
maven {
62+
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
63+
url "$rootDir/../node_modules/react-native/android"
64+
}
4865
maven {
49-
url defaultDir.toString()
50-
name androidSourcesName
66+
// Android JSC is installed from npm
67+
url "$rootDir/../node_modules/jsc-android/dist"
5168
}
69+
google()
70+
}
5271

53-
logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
54-
found = true
55-
} else {
56-
def parentDir = rootProject.projectDir
57-
58-
1.upto(5, {
59-
if (found) return true
60-
parentDir = parentDir.parentFile
61-
62-
def androidSourcesDir = new File(
63-
parentDir,
64-
'node_modules/react-native'
65-
)
66-
67-
def androidPrebuiltBinaryDir = new File(
68-
parentDir,
69-
'node_modules/react-native/android'
70-
)
71-
72-
if (androidPrebuiltBinaryDir.exists()) {
73-
maven {
74-
url androidPrebuiltBinaryDir.toString()
75-
name androidSourcesName
76-
}
72+
dependencies {
73+
//noinspection GradleDynamicVersion
74+
implementation 'com.facebook.react:react-native:+'
75+
//noinspection GradleDynamicVersion
76+
implementation 'com.bugfender.sdk:android:3.+'
77+
}
7778

78-
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
79-
found = true
80-
} else if (androidSourcesDir.exists()) {
81-
maven {
82-
url androidSourcesDir.toString()
83-
name androidSourcesName
79+
def configureReactNativePom(def pom) {
80+
def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)
81+
82+
pom.project {
83+
name packageJson.title
84+
artifactId packageJson.name
85+
version = packageJson.version
86+
group = "com.reactlibrary"
87+
description packageJson.description
88+
url packageJson.repository.baseUrl
89+
90+
licenses {
91+
license {
92+
name packageJson.license
93+
url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
94+
distribution 'repo'
95+
}
8496
}
8597

86-
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
87-
found = true
88-
}
89-
})
90-
}
91-
92-
if (!found) {
93-
throw new GradleException(
94-
"${project.name}: unable to locate React Native android sources. " +
95-
"Ensure you have you installed React Native as a dependency in your project and try again."
96-
)
97-
}
98+
developers {
99+
developer {
100+
id packageJson.author.username
101+
name packageJson.author.name
102+
}
103+
}
104+
}
98105
}
99106

100-
dependencies {
101-
implementation 'com.facebook.react:react-native:+'
102-
implementation 'com.bugfender.sdk:android:3.+'
107+
afterEvaluate { project ->
108+
// some Gradle build hooks ref:
109+
// https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
110+
task androidJavadoc(type: Javadoc) {
111+
source = android.sourceSets.main.java.srcDirs
112+
classpath += files(android.bootClasspath)
113+
classpath += files(project.getConfigurations().getByName('compile').asList())
114+
include '**/*.java'
115+
}
116+
117+
task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
118+
classifier = 'javadoc'
119+
from androidJavadoc.destinationDir
120+
}
121+
122+
task androidSourcesJar(type: Jar) {
123+
classifier = 'sources'
124+
from android.sourceSets.main.java.srcDirs
125+
include '**/*.java'
126+
}
127+
128+
android.libraryVariants.all { variant ->
129+
def name = variant.name.capitalize()
130+
def javaCompileTask = variant.javaCompileProvider.get()
131+
132+
task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
133+
from javaCompileTask.destinationDir
134+
}
135+
}
136+
137+
artifacts {
138+
archives androidSourcesJar
139+
archives androidJavadocJar
140+
}
141+
142+
task installArchives(type: Upload) {
143+
configuration = configurations.archives
144+
repositories.mavenDeployer {
145+
// Deploy to react-native-event-bridge/maven, ready to publish to npm
146+
repository url: "file://${projectDir}/../android/maven"
147+
configureReactNativePom pom
148+
}
149+
}
103150
}

example/.babelrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

example/.gitignore

Lines changed: 0 additions & 17 deletions
This file was deleted.

example/.watchmanconfig

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)