capacitor-native-google-one-tap-signin 0.0.1

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.
Files changed (67) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +273 -0
  3. package/android/.gradle/4.10.1/fileChanges/last-build.bin +0 -0
  4. package/android/.gradle/4.10.1/fileHashes/fileHashes.bin +0 -0
  5. package/android/.gradle/4.10.1/fileHashes/fileHashes.lock +0 -0
  6. package/android/.gradle/4.10.1/gc.properties +0 -0
  7. package/android/.gradle/7.3.3/checksums/checksums.lock +0 -0
  8. package/android/.gradle/7.3.3/checksums/md5-checksums.bin +0 -0
  9. package/android/.gradle/7.3.3/checksums/sha1-checksums.bin +0 -0
  10. package/android/.gradle/7.3.3/dependencies-accessors/dependencies-accessors.lock +0 -0
  11. package/android/.gradle/7.3.3/dependencies-accessors/gc.properties +0 -0
  12. package/android/.gradle/7.3.3/executionHistory/executionHistory.bin +0 -0
  13. package/android/.gradle/7.3.3/executionHistory/executionHistory.lock +0 -0
  14. package/android/.gradle/7.3.3/fileChanges/last-build.bin +0 -0
  15. package/android/.gradle/7.3.3/fileHashes/fileHashes.bin +0 -0
  16. package/android/.gradle/7.3.3/fileHashes/fileHashes.lock +0 -0
  17. package/android/.gradle/7.3.3/fileHashes/resourceHashesCache.bin +0 -0
  18. package/android/.gradle/7.3.3/gc.properties +0 -0
  19. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  20. package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  21. package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  22. package/android/.gradle/file-system.probe +0 -0
  23. package/android/.gradle/vcs-1/gc.properties +0 -0
  24. package/android/.idea/compiler.xml +6 -0
  25. package/android/.idea/gradle.xml +18 -0
  26. package/android/.idea/jarRepositories.xml +30 -0
  27. package/android/.idea/misc.xml +10 -0
  28. package/android/.idea/vcs.xml +6 -0
  29. package/android/build.gradle +54 -0
  30. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  31. package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  32. package/android/gradle.properties +16 -0
  33. package/android/gradlew +160 -0
  34. package/android/gradlew.bat +90 -0
  35. package/android/local.properties +8 -0
  36. package/android/proguard-rules.pro +21 -0
  37. package/android/settings.gradle +2 -0
  38. package/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +26 -0
  39. package/android/src/main/AndroidManifest.xml +7 -0
  40. package/android/src/main/java/com/codetrixstudio/capacitor/GoogleAuth/GoogleAuth.java +209 -0
  41. package/android/src/main/res/layout/bridge_layout_main.xml +15 -0
  42. package/android/src/main/res/values/colors.xml +3 -0
  43. package/android/src/main/res/values/strings.xml +3 -0
  44. package/android/src/main/res/values/styles.xml +3 -0
  45. package/android/src/test/java/com/getcapacitor/ExampleUnitTest.java +17 -0
  46. package/dist/esm/definitions.d.ts +80 -0
  47. package/dist/esm/definitions.js +3 -0
  48. package/dist/esm/definitions.js.map +1 -0
  49. package/dist/esm/index.d.ts +4 -0
  50. package/dist/esm/index.js +7 -0
  51. package/dist/esm/index.js.map +1 -0
  52. package/dist/esm/web.d.ts +19 -0
  53. package/dist/esm/web.js +127 -0
  54. package/dist/esm/web.js.map +1 -0
  55. package/ios/Plugin/Info.plist +24 -0
  56. package/ios/Plugin/Plugin.h +10 -0
  57. package/ios/Plugin/Plugin.m +11 -0
  58. package/ios/Plugin/Plugin.swift +173 -0
  59. package/ios/Plugin.xcodeproj/project.pbxproj +565 -0
  60. package/ios/Plugin.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  61. package/ios/Plugin.xcworkspace/contents.xcworkspacedata +10 -0
  62. package/ios/Plugin.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  63. package/ios/PluginTests/Info.plist +22 -0
  64. package/ios/PluginTests/PluginTests.swift +35 -0
  65. package/ios/Podfile +23 -0
  66. package/ios/Podfile.lock +47 -0
  67. package/package.json +64 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 David Neuy, Codetrix Studio, Apptailor
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,273 @@
1
+ # CapacitorGoogleAuth
2
+
3
+ [![npm](https://img.shields.io/npm/v/@codetrix-studio/capacitor-google-auth)](https://www.npmjs.com/package/@codetrix-studio/capacitor-google-auth)
4
+ ![npm](https://img.shields.io/npm/dt/@codetrix-studio/capacitor-google-auth)
5
+ ![npm](https://img.shields.io/npm/dw/@codetrix-studio/capacitor-google-auth)
6
+ ![Dependents (via libraries.io)](https://img.shields.io/librariesio/dependents/npm/@codetrix-studio/capacitor-google-auth)
7
+ [![install size](https://packagephobia.com/badge?p=@codetrix-studio/capacitor-google-auth)](https://packagephobia.com/result?p=@codetrix-studio/capacitor-google-auth)
8
+
9
+ Capacitor plugin for Google Auth.
10
+
11
+ ## Contributions
12
+
13
+ PRs are welcome and much appreciated that keeps this plugin up to date with Capacitor and official Google Auth platform library feature parity.
14
+
15
+ Try to follow good code practices. You can even help keeping the included demo updated.
16
+
17
+ PRs for features that are not aligned with the official Google Auth library are discouraged.
18
+
19
+ (We are beginner-friendly here)
20
+
21
+ ## Install
22
+
23
+ #### 1. Install package
24
+
25
+ ```sh
26
+ npm i --save @codetrix-studio/capacitor-google-auth
27
+ ```
28
+
29
+ #### 2. Update capacitor deps
30
+
31
+ ```sh
32
+ npx cap update
33
+ ```
34
+
35
+ ## Updating
36
+
37
+ If need migrate to different Capacitor versions [see instruction for migrate plugin to new version](#migration-guide).
38
+
39
+ ## Usage
40
+
41
+ ### WEB
42
+
43
+ Register plugin and manually initialize
44
+
45
+ ```ts
46
+ import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
47
+
48
+ // use hook after platform dom ready
49
+ GoogleAuth.initialize({
50
+ clientId: 'CLIENT_ID.apps.googleusercontent.com',
51
+ scopes: ['profile', 'email'],
52
+ grantOfflineAccess: true,
53
+ });
54
+ ```
55
+
56
+ or if need use meta tags (Optional):
57
+
58
+ ```html
59
+ <meta name="google-signin-client_id" content="{your client id here}" />
60
+ <meta name="google-signin-scope" content="profile email" />
61
+ ```
62
+
63
+ #### Options
64
+
65
+ - `clientId` - The app's client ID, found and created in the Google Developers Console.
66
+ - `scopes` – same as [Configure](#Configure) scopes
67
+ - `grantOfflineAccess` – boolean, default `false`, Set if your application needs to refresh access tokens when the user is not present at the browser.
68
+
69
+ Use it
70
+
71
+ ```ts
72
+ GoogleAuth.signIn();
73
+ ```
74
+
75
+ #### AngularFire2
76
+
77
+ init hook
78
+
79
+ ```ts
80
+ // app.component.ts
81
+ constructor() {
82
+ this.initializeApp();
83
+ }
84
+
85
+ initializeApp() {
86
+ this.platform.ready().then(() => {
87
+ GoogleAuth.initialize()
88
+ })
89
+ }
90
+ ```
91
+
92
+ sign in function
93
+
94
+ ```ts
95
+ async googleSignIn() {
96
+ let googleUser = await GoogleAuth.signIn();
97
+ const credential = auth.GoogleAuthProvider.credential(googleUser.authentication.idToken);
98
+ return this.afAuth.auth.signInAndRetrieveDataWithCredential(credential);
99
+ }
100
+ ```
101
+
102
+ #### Vue 3
103
+
104
+ ```ts
105
+ // App.vue
106
+ import { defineComponent, onMounted } from 'vue';
107
+ import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth';
108
+
109
+ export default defineComponent({
110
+ setup() {
111
+ onMounted(() => {
112
+ GoogleAuth.initialize();
113
+ });
114
+
115
+ const logIn = async () => {
116
+ const response = await GoogleAuth.signIn();
117
+ console.log(response);
118
+ };
119
+
120
+ return {
121
+ logIn,
122
+ };
123
+ },
124
+ });
125
+ ```
126
+
127
+ or see more [CapacitorGoogleAuth-Vue3-example](https://github.com/reslear/CapacitorGoogleAuth-Vue3-example)
128
+
129
+ ### iOS
130
+
131
+ 1. Create in Google cloud console credential **Client ID for iOS** and get **Client ID** and **iOS URL scheme**
132
+
133
+ 2. Add **identifier** `REVERSED_CLIENT_ID` as **URL schemes** to `Info.plist` from **iOS URL scheme**<br>
134
+ (Xcode: App - Targets/App - Info - URL Types, click plus icon)
135
+
136
+ 3. Set **Client ID** one of the ways:
137
+ 1. Set in `capacitor.config.json`
138
+ - `iosClientId` - specific key for iOS
139
+ - `clientId` - or common key for Android and iOS
140
+ 2. Download `GoogleService-Info.plist` file with `CLIENT_ID` and copy to **ios/App/App** necessarily through Xcode for indexing.
141
+
142
+ plugin first use `iosClientId` if not found use `clientId` if not found use value `CLIENT_ID` from file `GoogleService-Info.plist`
143
+
144
+ ### Android
145
+
146
+ Set **Client ID** :
147
+
148
+ 1. In `capacitor.config.json`
149
+
150
+ - `androidClientId` - specific key for Android
151
+ - `clientId` - or common key for Android and iOS
152
+
153
+ 2. or set inside your `strings.xml`
154
+
155
+ plugin first use `androidClientId` if not found use `clientId` if not found use value `server_client_id` from file `strings.xml`
156
+
157
+ ```xml
158
+ <resources>
159
+ <string name="server_client_id">Your Web Client Key</string>
160
+ </resources>
161
+ ```
162
+
163
+ Import package inside your `MainActivity`
164
+
165
+ ```java
166
+ import com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth;
167
+ ```
168
+
169
+ Register plugin inside your `MainActivity.onCreate`
170
+
171
+ ```java
172
+ this.init(savedInstanceState, new ArrayList<Class<? extends Plugin>>() {{
173
+ add(GoogleAuth.class);
174
+ }});
175
+ ```
176
+
177
+ ## Configure
178
+
179
+ | Name | Type | Description |
180
+ | ------------------------ | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
181
+ | clientId | string | The app's client ID, found and created in the Google Developers Console. |
182
+ | iosClientId | string | Specific client ID key for iOS |
183
+ | androidClientId | string | Specific client ID key for Android |
184
+ | scopes | string[] | Scopes that you might need to request to access Google APIs<br>https://developers.google.com/identity/protocols/oauth2/scopes |
185
+ | serverClientId | string | This ClientId used for offline access and server side handling |
186
+ | forceCodeForRefreshToken | boolean | Force user to select email address to regenerate AuthCode <br>used to get a valid refreshtoken (work on iOS and Android) |
187
+
188
+ Provide configuration in root `capacitor.config.json`
189
+
190
+ ```json
191
+ {
192
+ "plugins": {
193
+ "GoogleAuth": {
194
+ "scopes": ["profile", "email"],
195
+ "serverClientId": "xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com",
196
+ "forceCodeForRefreshToken": true
197
+ }
198
+ }
199
+ }
200
+ ```
201
+
202
+ or in `capacitor.config.ts`
203
+
204
+ ```ts
205
+ /// <reference types="'@codetrix-studio/capacitor-google-auth'" />
206
+
207
+ const config: CapacitorConfig = {
208
+ plugins: {
209
+ GoogleAuth: {
210
+ scopes: ['profile', 'email'],
211
+ serverClientId: 'xxxxxx-xxxxxxxxxxxxxxxxxx.apps.googleusercontent.com',
212
+ forceCodeForRefreshToken: true,
213
+ },
214
+ },
215
+ };
216
+
217
+ export default config;
218
+ ```
219
+
220
+ ## Migration guide
221
+
222
+ #### Migrate from 3.1.x to 3.2.x
223
+
224
+ Install version 3.2.x:
225
+
226
+ ```sh
227
+ npm i --save @codetrix-studio/capacitor-google-auth
228
+ ```
229
+
230
+ Follow instruction for you project [Updating from Capacitor 3 to Capacitor 4](https://capacitorjs.com/docs/updating/4-0).
231
+
232
+ #### Migrate from 3.0.2 to 3.1.0
233
+
234
+ ```diff
235
+ - GoogleAuth.init()
236
+ + GoogleAuth.initialize()
237
+ ```
238
+
239
+ #### Migrate from 2 to 3
240
+
241
+ Install version 3.x.x:
242
+
243
+ ```sh
244
+ npm i --save @codetrix-studio/capacitor-google-auth@3
245
+ ```
246
+
247
+ After [migrate to Capcitor 3](https://capacitorjs.com/docs/updating/3-0) updating you projects, see diff:
248
+
249
+ ##### WEB
250
+
251
+ ```diff
252
+ - import "@codetrix-studio/capacitor-google-auth";
253
+ - import { Plugins } from '@capacitor/core';
254
+ + import { GoogleAuth } from '@codetrix-studio/capacitor-google-auth'
255
+
256
+ - Plugins.GoogleAuth.signIn();
257
+ + GoogleAuth.init()
258
+ + GoogleAuth.signIn()
259
+ ```
260
+
261
+ #### Migrate from 1 to 2
262
+
263
+ Install version 2.x.x:
264
+
265
+ ```sh
266
+ npm i --save @codetrix-studio/capacitor-google-auth@2
267
+ ```
268
+
269
+ for capacitor 2.x.x use [instruction](https://github.com/CodetrixStudio/CapacitorGoogleAuth/blob/79129ab37288f5f5d0bb9a568a95890e852cebc2/README.md)
270
+
271
+ ## License
272
+
273
+ [MIT](./LICENSE)
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ #Fri Jan 27 18:42:37 CET 2023
2
+ gradle.version=7.3.3
File without changes
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="CompilerConfiguration">
4
+ <bytecodeTargetLevel target="11" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="GradleSettings">
4
+ <option name="linkedExternalProjectsSettings">
5
+ <GradleProjectSettings>
6
+ <option name="testRunner" value="GRADLE" />
7
+ <option name="distributionType" value="DEFAULT_WRAPPED" />
8
+ <option name="externalProjectPath" value="$PROJECT_DIR$" />
9
+ <option name="modules">
10
+ <set>
11
+ <option value="$PROJECT_DIR$" />
12
+ <option value="$PROJECT_DIR$/../node_modules/@capacitor/android/capacitor" />
13
+ </set>
14
+ </option>
15
+ </GradleProjectSettings>
16
+ </option>
17
+ </component>
18
+ </project>
@@ -0,0 +1,30 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="RemoteRepositoriesConfiguration">
4
+ <remote-repository>
5
+ <option name="id" value="central" />
6
+ <option name="name" value="Maven Central repository" />
7
+ <option name="url" value="https://repo1.maven.org/maven2" />
8
+ </remote-repository>
9
+ <remote-repository>
10
+ <option name="id" value="jboss.community" />
11
+ <option name="name" value="JBoss Community repository" />
12
+ <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
13
+ </remote-repository>
14
+ <remote-repository>
15
+ <option name="id" value="MavenRepo" />
16
+ <option name="name" value="MavenRepo" />
17
+ <option name="url" value="https://repo.maven.apache.org/maven2/" />
18
+ </remote-repository>
19
+ <remote-repository>
20
+ <option name="id" value="BintrayJCenter" />
21
+ <option name="name" value="BintrayJCenter" />
22
+ <option name="url" value="https://jcenter.bintray.com/" />
23
+ </remote-repository>
24
+ <remote-repository>
25
+ <option name="id" value="Google" />
26
+ <option name="name" value="Google" />
27
+ <option name="url" value="https://dl.google.com/dl/android/maven2/" />
28
+ </remote-repository>
29
+ </component>
30
+ </project>
@@ -0,0 +1,10 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ExternalStorageConfigurationManager" enabled="true" />
4
+ <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
5
+ <output url="file://$PROJECT_DIR$/build/classes" />
6
+ </component>
7
+ <component name="ProjectType">
8
+ <option name="id" value="Android" />
9
+ </component>
10
+ </project>
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
5
+ </component>
6
+ </project>
@@ -0,0 +1,54 @@
1
+ buildscript {
2
+ repositories {
3
+ jcenter()
4
+ google()
5
+ }
6
+ dependencies {
7
+ classpath 'com.android.tools.build:gradle:7.2.1'
8
+ classpath 'com.google.gms:google-services:4.3.13'
9
+ }
10
+ }
11
+
12
+ apply plugin: 'com.android.library'
13
+
14
+ android {
15
+ compileSdkVersion 32
16
+ defaultConfig {
17
+ minSdkVersion 22
18
+ targetSdkVersion 32
19
+ versionCode 1
20
+ versionName "1.0"
21
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
22
+ }
23
+ buildTypes {
24
+ release {
25
+ minifyEnabled false
26
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
27
+ }
28
+ }
29
+ lintOptions {
30
+ abortOnError false
31
+ }
32
+ compileOptions {
33
+ targetCompatibility JavaVersion.VERSION_11
34
+ sourceCompatibility JavaVersion.VERSION_11
35
+ }
36
+ }
37
+
38
+ repositories {
39
+ google()
40
+ jcenter()
41
+ mavenCentral()
42
+ }
43
+
44
+
45
+ dependencies {
46
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
47
+ implementation project(':capacitor-android')
48
+ implementation 'androidx.appcompat:appcompat:1.2.0'
49
+ testImplementation 'junit:junit:4.13'
50
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
51
+ androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
52
+ implementation 'com.google.android.gms:play-services-auth:18.+'
53
+ }
54
+
@@ -0,0 +1,6 @@
1
+ #Fri Jan 27 18:42:30 CET 2023
2
+ distributionBase=GRADLE_USER_HOME
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
4
+ distributionPath=wrapper/dists
5
+ zipStorePath=wrapper/dists
6
+ zipStoreBase=GRADLE_USER_HOME
@@ -0,0 +1,16 @@
1
+ ## For more details on how to configure your build environment visit
2
+ # http://www.gradle.org/docs/current/userguide/build_environment.html
3
+ #
4
+ # Specifies the JVM arguments used for the daemon process.
5
+ # The setting is particularly useful for tweaking memory settings.
6
+ # Default value: -Xmx1024m -XX:MaxPermSize=256m
7
+ # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
8
+ #
9
+ # When configured, Gradle will run in incubating parallel mode.
10
+ # This option should only be used with decoupled projects. More details, visit
11
+ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
12
+ # org.gradle.parallel=true
13
+ #Fri Jan 27 18:43:14 CET 2023
14
+ org.gradle.jvmargs=-Xmx1536m
15
+ android.useAndroidX=true
16
+ android.enableJetifier=true
@@ -0,0 +1,160 @@
1
+ #!/usr/bin/env bash
2
+
3
+ ##############################################################################
4
+ ##
5
+ ## Gradle start up script for UN*X
6
+ ##
7
+ ##############################################################################
8
+
9
+ # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10
+ DEFAULT_JVM_OPTS=""
11
+
12
+ APP_NAME="Gradle"
13
+ APP_BASE_NAME=`basename "$0"`
14
+
15
+ # Use the maximum available, or set MAX_FD != -1 to use that value.
16
+ MAX_FD="maximum"
17
+
18
+ warn ( ) {
19
+ echo "$*"
20
+ }
21
+
22
+ die ( ) {
23
+ echo
24
+ echo "$*"
25
+ echo
26
+ exit 1
27
+ }
28
+
29
+ # OS specific support (must be 'true' or 'false').
30
+ cygwin=false
31
+ msys=false
32
+ darwin=false
33
+ case "`uname`" in
34
+ CYGWIN* )
35
+ cygwin=true
36
+ ;;
37
+ Darwin* )
38
+ darwin=true
39
+ ;;
40
+ MINGW* )
41
+ msys=true
42
+ ;;
43
+ esac
44
+
45
+ # Attempt to set APP_HOME
46
+ # Resolve links: $0 may be a link
47
+ PRG="$0"
48
+ # Need this for relative symlinks.
49
+ while [ -h "$PRG" ] ; do
50
+ ls=`ls -ld "$PRG"`
51
+ link=`expr "$ls" : '.*-> \(.*\)$'`
52
+ if expr "$link" : '/.*' > /dev/null; then
53
+ PRG="$link"
54
+ else
55
+ PRG=`dirname "$PRG"`"/$link"
56
+ fi
57
+ done
58
+ SAVED="`pwd`"
59
+ cd "`dirname \"$PRG\"`/" >/dev/null
60
+ APP_HOME="`pwd -P`"
61
+ cd "$SAVED" >/dev/null
62
+
63
+ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64
+
65
+ # Determine the Java command to use to start the JVM.
66
+ if [ -n "$JAVA_HOME" ] ; then
67
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68
+ # IBM's JDK on AIX uses strange locations for the executables
69
+ JAVACMD="$JAVA_HOME/jre/sh/java"
70
+ else
71
+ JAVACMD="$JAVA_HOME/bin/java"
72
+ fi
73
+ if [ ! -x "$JAVACMD" ] ; then
74
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75
+
76
+ Please set the JAVA_HOME variable in your environment to match the
77
+ location of your Java installation."
78
+ fi
79
+ else
80
+ JAVACMD="java"
81
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82
+
83
+ Please set the JAVA_HOME variable in your environment to match the
84
+ location of your Java installation."
85
+ fi
86
+
87
+ # Increase the maximum file descriptors if we can.
88
+ if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89
+ MAX_FD_LIMIT=`ulimit -H -n`
90
+ if [ $? -eq 0 ] ; then
91
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92
+ MAX_FD="$MAX_FD_LIMIT"
93
+ fi
94
+ ulimit -n $MAX_FD
95
+ if [ $? -ne 0 ] ; then
96
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
97
+ fi
98
+ else
99
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100
+ fi
101
+ fi
102
+
103
+ # For Darwin, add options to specify how the application appears in the dock
104
+ if $darwin; then
105
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106
+ fi
107
+
108
+ # For Cygwin, switch paths to Windows format before running java
109
+ if $cygwin ; then
110
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112
+ JAVACMD=`cygpath --unix "$JAVACMD"`
113
+
114
+ # We build the pattern for arguments to be converted via cygpath
115
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116
+ SEP=""
117
+ for dir in $ROOTDIRSRAW ; do
118
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
119
+ SEP="|"
120
+ done
121
+ OURCYGPATTERN="(^($ROOTDIRS))"
122
+ # Add a user-defined pattern to the cygpath arguments
123
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125
+ fi
126
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
127
+ i=0
128
+ for arg in "$@" ; do
129
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131
+
132
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134
+ else
135
+ eval `echo args$i`="\"$arg\""
136
+ fi
137
+ i=$((i+1))
138
+ done
139
+ case $i in
140
+ (0) set -- ;;
141
+ (1) set -- "$args0" ;;
142
+ (2) set -- "$args0" "$args1" ;;
143
+ (3) set -- "$args0" "$args1" "$args2" ;;
144
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150
+ esac
151
+ fi
152
+
153
+ # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154
+ function splitJvmOpts() {
155
+ JVM_OPTS=("$@")
156
+ }
157
+ eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158
+ JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159
+
160
+ exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"