@dashx/react-native 1.0.6 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,200 @@
1
+ import FirebaseCore
2
+ import FirebaseMessaging
3
+ import Foundation
4
+ import UIKit
5
+ import DashX
6
+
7
+ @objc(DashXRCTAppDelegate)
8
+ open class DashXRCTAppDelegate: RCTAppDelegate, MessagingDelegate, UNUserNotificationCenterDelegate {
9
+ // MARK: Getters
10
+ private var app: UIApplication = .shared
11
+
12
+ // MARK: Init
13
+
14
+ public override init() {
15
+ super.init()
16
+
17
+ UNUserNotificationCenter.current().delegate = self
18
+
19
+ // Register to ensure device token can be fetched
20
+ app.registerForRemoteNotifications()
21
+ }
22
+
23
+ // MARK: MessagingDelegate
24
+
25
+ open override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
26
+ FirebaseApp.configure()
27
+ Messaging.messaging().delegate = self
28
+
29
+ // Requesting Push Notifications Permission
30
+ DashX.requestNotificationPermission { authorizationStatus in
31
+ switch authorizationStatus {
32
+ case .authorized:
33
+ DashXLog.d(tag: #function, "permission authorized to receive push notifications")
34
+ default:
35
+ DashXLog.d(tag: #function, "permission denied to receive push notifications")
36
+ }
37
+ }
38
+
39
+ return super.application(application, didFinishLaunchingWithOptions: launchOptions)
40
+ }
41
+
42
+ // MARK: - APNS Token Management
43
+
44
+ public override func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
45
+ DashXLog.d(tag: #function, "Unable to register for remote notifications: \(error.localizedDescription)")
46
+ }
47
+
48
+ public override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
49
+ Messaging.messaging().setAPNSToken(deviceToken, type: .unknown)
50
+ }
51
+
52
+ public func messaging(_ messaging: Messaging, didReceiveRegistrationToken fcmToken: String?) {
53
+ guard let token = fcmToken else {
54
+ DashXLog.d(tag: #function, "FCM Token is empty")
55
+ return
56
+ }
57
+
58
+ DashXLog.d(tag: #function, "FCM Token: \(token)")
59
+
60
+ DashX.setFCMToken(to: token)
61
+ }
62
+
63
+ // MARK: - Push Notifications
64
+
65
+ public func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
66
+ let message = notification.request.content.userInfo
67
+
68
+ // Pass notification reciept information to Firebase
69
+ Messaging.messaging().appDidReceiveMessage(message)
70
+
71
+ DashX.trackNotification(message: message, event: .delivered)
72
+
73
+ let presentationOptions = notificationDeliveredInForeground(message: message)
74
+
75
+ completionHandler(presentationOptions)
76
+ }
77
+
78
+ public func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
79
+ let message = response.notification.request.content.userInfo
80
+
81
+ // Pass notification reciept information to Firebase
82
+ Messaging.messaging().appDidReceiveMessage(message)
83
+
84
+ if response.actionIdentifier == UNNotificationDismissActionIdentifier {
85
+ DashX.trackNotification(message: message, event: .dismissed)
86
+ } else {
87
+ DashX.trackNotification(message: message, event: .clicked)
88
+
89
+ if let url = message.dashxNotificationUrl() {
90
+ handleLink(url: url)
91
+ } else {
92
+ notificationClicked(message: message, actionIdentifier: response.actionIdentifier)
93
+ }
94
+ }
95
+
96
+ completionHandler()
97
+ }
98
+
99
+ public override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable: Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
100
+ // Pass notification reciept information to Firebase
101
+ Messaging.messaging().appDidReceiveMessage(userInfo)
102
+
103
+ guard let dashxData = userInfo.dashxNotificationData() else {
104
+ DashXLog.d(tag: #function, "Unable to parse DashX notification data")
105
+ completionHandler(.failed)
106
+ return
107
+ }
108
+
109
+ let notificationContent = UNMutableNotificationContent()
110
+ notificationContent.sound = UNNotificationSound.default
111
+ notificationContent.title = dashxData.title
112
+ notificationContent.body = dashxData.body
113
+ notificationContent.userInfo = userInfo
114
+ notificationContent.categoryIdentifier = Constants.DASHX_NOTIFICATION_CATEGORY_IDENTIFIER
115
+
116
+ var notificationActions: [UNNotificationAction] = []
117
+
118
+ if let actionButtons = dashxData.actionButtons {
119
+ for button in actionButtons {
120
+ notificationActions.append(
121
+ UNNotificationAction(
122
+ identifier: button.identifier,
123
+ title: button.label,
124
+ options: [.foreground]
125
+ )
126
+ )
127
+ }
128
+ }
129
+
130
+ let notificationCategory = UNNotificationCategory(
131
+ identifier: Constants.DASHX_NOTIFICATION_CATEGORY_IDENTIFIER,
132
+ actions: notificationActions,
133
+ intentIdentifiers: [],
134
+ options: .customDismissAction
135
+ )
136
+
137
+ UNUserNotificationCenter.current().setNotificationCategories([notificationCategory])
138
+
139
+ if let imagePath = dashxData.image,
140
+ let imageURL = URL(string: imagePath)
141
+ {
142
+ createNotificationWithImage(id: dashxData.id, imageURL: imageURL, content: notificationContent)
143
+ } else {
144
+ createNotification(id: dashxData.id, content: notificationContent)
145
+ }
146
+
147
+ completionHandler(.newData)
148
+ }
149
+
150
+ // MARK: - Push Notifications handlers
151
+
152
+ open func notificationDeliveredInForeground(message: [AnyHashable: Any]) -> UNNotificationPresentationOptions { return [] }
153
+
154
+ open func notificationClicked(message: [AnyHashable: Any], actionIdentifier: String) {}
155
+
156
+ open func handleLink(url: URL) {}
157
+ }
158
+
159
+ extension DashXRCTAppDelegate {
160
+ private func createNotification(id: String, content: UNMutableNotificationContent) {
161
+ let request = UNNotificationRequest(identifier: id, content: content, trigger: nil)
162
+
163
+ UNUserNotificationCenter.current().add(request) { error in
164
+ if let error = error {
165
+ DashXLog.d(tag: #function, "Failed to schedule notification request: \(error.localizedDescription)")
166
+ } else {
167
+ DashXLog.d(tag: #function, "Notification request added successfully.")
168
+ }
169
+ }
170
+ }
171
+
172
+ private func createNotificationWithImage(id: String,
173
+ imageURL: URL,
174
+ content: UNMutableNotificationContent)
175
+ {
176
+ let task = URLSession.shared.downloadTask(with: imageURL) { location, _, error in
177
+ guard let location = location, error == nil else {
178
+ return
179
+ }
180
+
181
+ // Create a temporary file URL to save the downloaded image
182
+ let tmpDirectoryURL = FileManager.default.temporaryDirectory
183
+ let uuid = UUID().uuidString
184
+ let tmpFileURL = tmpDirectoryURL.appendingPathComponent(uuid + ".png")
185
+
186
+ do {
187
+ // Move the downloaded file to the temporary file URL
188
+ try FileManager.default.moveItem(at: location, to: tmpFileURL)
189
+
190
+ // Create the notification attachment from the temporary file URL
191
+ let attachment = try UNNotificationAttachment(identifier: "\(id)-attachment", url: tmpFileURL, options: nil)
192
+ content.attachments = [attachment]
193
+ self.createNotification(id: id, content: content)
194
+ } catch {
195
+ DashXLog.d(tag: #function, "Error moving file: \(error.localizedDescription)")
196
+ }
197
+ }
198
+ task.resume()
199
+ }
200
+ }
@@ -1,4 +1,3 @@
1
- //
2
- // Use this file to import your target's public headers that you would like to expose to Swift.
3
- //
4
-
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTEventEmitter.h>
3
+ #import <React/RCTViewManager.h>
@@ -0,0 +1,28 @@
1
+ #import <React/RCTBridgeModule.h>
2
+ #import <React/RCTEventEmitter.h>
3
+
4
+ @interface RCT_EXTERN_MODULE(DashXReactNative, RCTEventEmitter)
5
+
6
+ RCT_EXTERN_METHOD(configure:(NSDictionary *)options);
7
+
8
+ RCT_EXTERN_METHOD(identify:(NSDictionary *)options);
9
+
10
+ RCT_EXTERN_METHOD(setIdentity:(NSString *)uid token:(NSString *)token);
11
+
12
+ RCT_EXTERN_METHOD(track:(NSString *)event data:(NSDictionary * _Nullable)data);
13
+
14
+ RCT_EXTERN_METHOD(screen:(NSString *)screenName data:(NSDictionary * _Nullable)data);
15
+
16
+ RCT_EXTERN_METHOD(fetchStoredPreferences:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject);
17
+
18
+ RCT_EXTERN_METHOD(saveStoredPreferences:(NSDictionary *)preferenceData resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject);
19
+
20
+ RCT_EXTERN_METHOD(reset);
21
+
22
+ RCT_EXTERN_METHOD(subscribe);
23
+
24
+ RCT_EXTERN_METHOD(unsubscribe);
25
+
26
+ RCT_EXTERN_METHOD(setLogLevel:(int *)level);
27
+
28
+ @end
@@ -0,0 +1,105 @@
1
+ import Foundation
2
+ import DashX
3
+
4
+ typealias CBU = CallbackUtils
5
+
6
+ @objc(DashXReactNative)
7
+ class DashXReactNative: RCTEventEmitter {
8
+ override init() {
9
+ super.init()
10
+ DashXEventEmitter.instance.registerEventEmitter(eventEmitter: self)
11
+ }
12
+
13
+ override static func requiresMainQueueSetup() -> Bool {
14
+ return true
15
+ }
16
+
17
+ override func supportedEvents() -> [String] {
18
+ return ["messageReceived"]
19
+ }
20
+
21
+ @objc(configure:)
22
+ func configure(_ options: NSDictionary) {
23
+ let publicKey = options["publicKey"] as! String,
24
+ baseURI = options["baseURI"] as? String,
25
+ targetEnvironment = options["targetEnvironment"] as? String
26
+
27
+ DashX.configure(
28
+ withPublicKey: publicKey,
29
+ baseURI: baseURI,
30
+ targetEnvironment: targetEnvironment
31
+ )
32
+ }
33
+
34
+ @objc(identify:)
35
+ func identify(_ options: NSDictionary) {
36
+ try? DashX.identify(withOptions: options)
37
+ }
38
+
39
+ @objc(setIdentity:token:)
40
+ func setIdentity(_ uid: String, _ token: String) {
41
+ DashX.setIdentity(uid: uid, token: token)
42
+ }
43
+
44
+ @objc
45
+ func reset() {
46
+ DashX.reset()
47
+ }
48
+
49
+ @objc(track:data:)
50
+ func track(_ event: String, _ data: NSDictionary?) {
51
+ DashX.track(event, withData: data)
52
+ }
53
+
54
+ @objc(screen:data:)
55
+ func screen(_ screenName: String, _ data: NSDictionary?) {
56
+ DashX.screen(screenName, withData: data)
57
+ }
58
+
59
+ @objc(fetchStoredPreferences:rejecter:)
60
+ func fetchStoredPreferences(_ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
61
+ DashX.fetchStoredPreferences(
62
+ successCallback: CBU.resolveToSuccessCallback(resolve),
63
+ failureCallback: CBU.rejectToFailureCallback(reject)
64
+ )
65
+ }
66
+
67
+ @objc(saveStoredPreferences:resolve:rejecter:)
68
+ func saveStoredPreferences(_ preferenceData: NSDictionary, _ resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
69
+ DashX.saveStoredPreferences(
70
+ preferenceData: preferenceData,
71
+ successCallback: CBU.resolveToSuccessCallback(resolve),
72
+ failureCallback: CBU.rejectToFailureCallback(reject)
73
+ )
74
+ }
75
+
76
+ @objc
77
+ func subscribe() {
78
+ DashX.subscribe()
79
+ }
80
+
81
+ @objc
82
+ func unsubscribe() {
83
+ DashX.unsubscribe()
84
+ }
85
+
86
+ @objc(setLogLevel:)
87
+ func setLogLevel(_ level: Int) {
88
+ let logLevel = DashXLog.LogLevel(rawValue: level) ?? DashXLog.LogLevel.off
89
+ DashXLog.setLogLevel(to: logLevel)
90
+ }
91
+ }
92
+
93
+ class CallbackUtils {
94
+ static func resolveToSuccessCallback(_ resolve: @escaping RCTPromiseResolveBlock) -> SuccessCallback {
95
+ return resolve
96
+ }
97
+
98
+ static func rejectToFailureCallback(_ reject: @escaping RCTPromiseRejectBlock) -> FailureCallback {
99
+ let result: FailureCallback = { (error) in
100
+ reject("\((error as NSError).code)", error.localizedDescription, error)
101
+ }
102
+
103
+ return result
104
+ }
105
+ }
@@ -7,9 +7,9 @@
7
7
  objects = {
8
8
 
9
9
  /* Begin PBXBuildFile section */
10
- 7C3CFED5289B9C6E00D184AB /* DashX.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C3CFED3289B9C6E00D184AB /* DashX.swift */; };
11
- 7C3CFED6289B9C6E00D184AB /* DashXEventEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C3CFED4289B9C6E00D184AB /* DashXEventEmitter.swift */; };
12
- B3E7B58A1CC2AC0600A0062D /* DashXReactNative.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* DashXReactNative.m */; };
10
+ 5124AEE72A7A25120079E503 /* DashXReactNative.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* DashXReactNative.m */; };
11
+ 5124AEE82A7A25120079E503 /* DashX.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C3CFED3289B9C6E00D184AB /* DashX.swift */; };
12
+ 5124AEE92A7A25120079E503 /* DashXEventEmitter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C3CFED4289B9C6E00D184AB /* DashXEventEmitter.swift */; };
13
13
  /* End PBXBuildFile section */
14
14
 
15
15
  /* Begin PBXCopyFilesBuildPhase section */
@@ -122,9 +122,9 @@
122
122
  isa = PBXSourcesBuildPhase;
123
123
  buildActionMask = 2147483647;
124
124
  files = (
125
- 7C3CFED5289B9C6E00D184AB /* DashX.swift in Sources */,
126
- 7C3CFED6289B9C6E00D184AB /* DashXEventEmitter.swift in Sources */,
127
- B3E7B58A1CC2AC0600A0062D /* DashXReactNative.m in Sources */,
125
+ 5124AEE72A7A25120079E503 /* DashXReactNative.m in Sources */,
126
+ 5124AEE82A7A25120079E503 /* DashX.swift in Sources */,
127
+ 5124AEE92A7A25120079E503 /* DashXEventEmitter.swift in Sources */,
128
128
  );
129
129
  runOnlyForDeploymentPostprocessing = 0;
130
130
  };
package/package.json CHANGED
@@ -1,17 +1,30 @@
1
1
  {
2
2
  "name": "@dashx/react-native",
3
3
  "title": "DashX React Native",
4
- "version": "1.0.6",
4
+ "version": "1.0.8",
5
5
  "description": "DashX SDK for React Native",
6
6
  "main": "index.js",
7
7
  "files": [
8
- "README.md",
8
+ "!**/__fixtures__",
9
+ "!**/__mocks__",
10
+ "!**/__tests__",
11
+ "!**/.*",
12
+ "!android/build",
13
+ "!android/gradle",
14
+ "!android/gradlew.bat",
15
+ "!android/gradlew",
16
+ "!android/local.properties",
17
+ "!ios/build",
18
+ "!lib/typescript/example",
19
+ "*.podspec",
9
20
  "android",
10
- "index.js",
11
21
  "ContentOptionsBuilder.js",
12
- "utils.js",
22
+ "cpp",
23
+ "DashXReactNative.podspec",
24
+ "index.js",
13
25
  "ios",
14
- "DashXReactNative.podspec"
26
+ "README.md",
27
+ "utils.js"
15
28
  ],
16
29
  "scripts": {
17
30
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -21,7 +34,9 @@
21
34
  "url": "https://github.com/dashxhq/dashx-react-native"
22
35
  },
23
36
  "keywords": [
24
- "react-native"
37
+ "react-native",
38
+ "ios",
39
+ "android"
25
40
  ],
26
41
  "author": {
27
42
  "name": "DashXDev",
@@ -29,14 +44,62 @@
29
44
  },
30
45
  "license": "MIT",
31
46
  "licenseFilename": "LICENSE",
47
+ "homepage": "https://github.com/dashxhq/dashx-react-native#readme",
48
+ "publishConfig": {
49
+ "registry": "https://registry.npmjs.org/"
50
+ },
32
51
  "peerDependencies": {
33
- "react-native": "^0.41.2"
52
+ "react": "*",
53
+ "react-native": "*"
34
54
  },
35
55
  "devDependencies": {
36
- "eslint": "^8.21.0",
37
- "eslint-plugin-react": "^7.30.1"
56
+ "@commitlint/config-conventional": "^17.0.2",
57
+ "@react-native/eslint-config": "^0.72.2",
58
+ "del-cli": "^5.0.0",
59
+ "eslint": "^8.4.1",
60
+ "eslint-config-prettier": "^8.5.0",
61
+ "eslint-plugin-prettier": "^4.0.0",
62
+ "jest": "^28.1.1",
63
+ "pod-install": "^0.1.0",
64
+ "prettier": "^2.0.5",
65
+ "react": "18.2.0",
66
+ "react-native": "0.72.3",
67
+ "react-native-builder-bob": "^0.21.3",
68
+ "turbo": "^1.10.7"
69
+ },
70
+ "engines": {
71
+ "node": ">= 16.0.0"
38
72
  },
73
+ "packageManager": "^yarn@1.22.15",
39
74
  "dependencies": {
40
75
  "react-native-get-real-path": "github:Wraptime/react-native-get-real-path"
76
+ },
77
+ "eslintConfig": {
78
+ "root": true,
79
+ "extends": [
80
+ "@react-native",
81
+ "prettier"
82
+ ],
83
+ "rules": {
84
+ "prettier/prettier": [
85
+ "error",
86
+ {
87
+ "quoteProps": "consistent",
88
+ "singleQuote": true,
89
+ "tabWidth": 2,
90
+ "trailingComma": "es5",
91
+ "useTabs": false
92
+ }
93
+ ]
94
+ }
95
+ },
96
+ "eslintIgnore": [
97
+ "node_modules/",
98
+ "lib/"
99
+ ],
100
+ "prettier": {
101
+ "quoteProps": "consistent",
102
+ "singleQuote": true,
103
+ "trailingComma": "es5"
41
104
  }
42
105
  }
package/android/gradlew DELETED
@@ -1,185 +0,0 @@
1
- #!/usr/bin/env sh
2
-
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
-
19
- ##############################################################################
20
- ##
21
- ## Gradle start up script for UN*X
22
- ##
23
- ##############################################################################
24
-
25
- # Attempt to set APP_HOME
26
- # Resolve links: $0 may be a link
27
- PRG="$0"
28
- # Need this for relative symlinks.
29
- while [ -h "$PRG" ] ; do
30
- ls=`ls -ld "$PRG"`
31
- link=`expr "$ls" : '.*-> \(.*\)$'`
32
- if expr "$link" : '/.*' > /dev/null; then
33
- PRG="$link"
34
- else
35
- PRG=`dirname "$PRG"`"/$link"
36
- fi
37
- done
38
- SAVED="`pwd`"
39
- cd "`dirname \"$PRG\"`/" >/dev/null
40
- APP_HOME="`pwd -P`"
41
- cd "$SAVED" >/dev/null
42
-
43
- APP_NAME="Gradle"
44
- APP_BASE_NAME=`basename "$0"`
45
-
46
- # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47
- DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48
-
49
- # Use the maximum available, or set MAX_FD != -1 to use that value.
50
- MAX_FD="maximum"
51
-
52
- warn () {
53
- echo "$*"
54
- }
55
-
56
- die () {
57
- echo
58
- echo "$*"
59
- echo
60
- exit 1
61
- }
62
-
63
- # OS specific support (must be 'true' or 'false').
64
- cygwin=false
65
- msys=false
66
- darwin=false
67
- nonstop=false
68
- case "`uname`" in
69
- CYGWIN* )
70
- cygwin=true
71
- ;;
72
- Darwin* )
73
- darwin=true
74
- ;;
75
- MSYS* | MINGW* )
76
- msys=true
77
- ;;
78
- NONSTOP* )
79
- nonstop=true
80
- ;;
81
- esac
82
-
83
- CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84
-
85
-
86
- # Determine the Java command to use to start the JVM.
87
- if [ -n "$JAVA_HOME" ] ; then
88
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
89
- # IBM's JDK on AIX uses strange locations for the executables
90
- JAVACMD="$JAVA_HOME/jre/sh/java"
91
- else
92
- JAVACMD="$JAVA_HOME/bin/java"
93
- fi
94
- if [ ! -x "$JAVACMD" ] ; then
95
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
96
-
97
- Please set the JAVA_HOME variable in your environment to match the
98
- location of your Java installation."
99
- fi
100
- else
101
- JAVACMD="java"
102
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
103
-
104
- Please set the JAVA_HOME variable in your environment to match the
105
- location of your Java installation."
106
- fi
107
-
108
- # Increase the maximum file descriptors if we can.
109
- if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
110
- MAX_FD_LIMIT=`ulimit -H -n`
111
- if [ $? -eq 0 ] ; then
112
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
113
- MAX_FD="$MAX_FD_LIMIT"
114
- fi
115
- ulimit -n $MAX_FD
116
- if [ $? -ne 0 ] ; then
117
- warn "Could not set maximum file descriptor limit: $MAX_FD"
118
- fi
119
- else
120
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
121
- fi
122
- fi
123
-
124
- # For Darwin, add options to specify how the application appears in the dock
125
- if $darwin; then
126
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
127
- fi
128
-
129
- # For Cygwin or MSYS, switch paths to Windows format before running java
130
- if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
131
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
132
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
133
-
134
- JAVACMD=`cygpath --unix "$JAVACMD"`
135
-
136
- # We build the pattern for arguments to be converted via cygpath
137
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
138
- SEP=""
139
- for dir in $ROOTDIRSRAW ; do
140
- ROOTDIRS="$ROOTDIRS$SEP$dir"
141
- SEP="|"
142
- done
143
- OURCYGPATTERN="(^($ROOTDIRS))"
144
- # Add a user-defined pattern to the cygpath arguments
145
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
146
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
147
- fi
148
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
149
- i=0
150
- for arg in "$@" ; do
151
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
152
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
153
-
154
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
155
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
156
- else
157
- eval `echo args$i`="\"$arg\""
158
- fi
159
- i=`expr $i + 1`
160
- done
161
- case $i in
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" ;;
172
- esac
173
- fi
174
-
175
- # Escape application args
176
- save () {
177
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
178
- echo " "
179
- }
180
- APP_ARGS=`save "$@"`
181
-
182
- # Collect all arguments for the java command, following the shell quoting and substitution rules
183
- eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
184
-
185
- exec "$JAVACMD" "$@"