expo-template-bare-minimum 44.0.11 → 45.0.2

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 (32) hide show
  1. package/android/app/build.gradle +135 -11
  2. package/android/app/proguard-rules.pro +4 -0
  3. package/android/app/src/main/AndroidManifest.xml +2 -2
  4. package/android/app/src/main/java/com/helloworld/MainApplication.java +12 -3
  5. package/android/app/src/main/java/com/helloworld/newarchitecture/MainApplicationReactNativeHost.java +116 -0
  6. package/android/app/src/main/java/com/helloworld/newarchitecture/components/MainComponentsRegistry.java +36 -0
  7. package/android/app/src/main/java/com/helloworld/newarchitecture/modules/MainApplicationTurboModuleManagerDelegate.java +48 -0
  8. package/android/app/src/main/jni/Android.mk +49 -0
  9. package/android/app/src/main/jni/MainApplicationModuleProvider.cpp +24 -0
  10. package/android/app/src/main/jni/MainApplicationModuleProvider.h +16 -0
  11. package/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.cpp +45 -0
  12. package/android/app/src/main/jni/MainApplicationTurboModuleManagerDelegate.h +38 -0
  13. package/android/app/src/main/jni/MainComponentsRegistry.cpp +61 -0
  14. package/android/app/src/main/jni/MainComponentsRegistry.h +32 -0
  15. package/android/app/src/main/jni/OnLoad.cpp +11 -0
  16. package/android/app/src/main/res/drawable/rn_edit_text_material.xml +36 -0
  17. package/android/app/src/main/res/values/styles.xml +1 -0
  18. package/android/build.gradle +30 -8
  19. package/android/gitignore +21 -0
  20. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  21. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  22. package/android/gradle.properties +16 -4
  23. package/android/gradlew +154 -103
  24. package/android/gradlew.bat +89 -103
  25. package/android/settings.gradle +6 -0
  26. package/ios/HelloWorld/AppDelegate.mm +143 -0
  27. package/ios/HelloWorld.xcodeproj/project.pbxproj +8 -6
  28. package/ios/Podfile +16 -16
  29. package/ios/gitignore +29 -0
  30. package/package.json +8 -8
  31. package/ios/HelloWorld/AppDelegate.m +0 -75
  32. package/ios/HelloWorld.xcodeproj/project.xcworkspace/xcuserdata/brentvatne.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
@@ -0,0 +1,61 @@
1
+ #include "MainComponentsRegistry.h"
2
+
3
+ #include <CoreComponentsRegistry.h>
4
+ #include <fbjni/fbjni.h>
5
+ #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
6
+ #include <react/renderer/components/rncore/ComponentDescriptors.h>
7
+
8
+ namespace facebook {
9
+ namespace react {
10
+
11
+ MainComponentsRegistry::MainComponentsRegistry(ComponentFactory *delegate) {}
12
+
13
+ std::shared_ptr<ComponentDescriptorProviderRegistry const>
14
+ MainComponentsRegistry::sharedProviderRegistry() {
15
+ auto providerRegistry = CoreComponentsRegistry::sharedProviderRegistry();
16
+
17
+ // Custom Fabric Components go here. You can register custom
18
+ // components coming from your App or from 3rd party libraries here.
19
+ //
20
+ // providerRegistry->add(concreteComponentDescriptorProvider<
21
+ // AocViewerComponentDescriptor>());
22
+ return providerRegistry;
23
+ }
24
+
25
+ jni::local_ref<MainComponentsRegistry::jhybriddata>
26
+ MainComponentsRegistry::initHybrid(
27
+ jni::alias_ref<jclass>,
28
+ ComponentFactory *delegate) {
29
+ auto instance = makeCxxInstance(delegate);
30
+
31
+ auto buildRegistryFunction =
32
+ [](EventDispatcher::Weak const &eventDispatcher,
33
+ ContextContainer::Shared const &contextContainer)
34
+ -> ComponentDescriptorRegistry::Shared {
35
+ auto registry = MainComponentsRegistry::sharedProviderRegistry()
36
+ ->createComponentDescriptorRegistry(
37
+ {eventDispatcher, contextContainer});
38
+
39
+ auto mutableRegistry =
40
+ std::const_pointer_cast<ComponentDescriptorRegistry>(registry);
41
+
42
+ mutableRegistry->setFallbackComponentDescriptor(
43
+ std::make_shared<UnimplementedNativeViewComponentDescriptor>(
44
+ ComponentDescriptorParameters{
45
+ eventDispatcher, contextContainer, nullptr}));
46
+
47
+ return registry;
48
+ };
49
+
50
+ delegate->buildRegistryFunction = buildRegistryFunction;
51
+ return instance;
52
+ }
53
+
54
+ void MainComponentsRegistry::registerNatives() {
55
+ registerHybrid({
56
+ makeNativeMethod("initHybrid", MainComponentsRegistry::initHybrid),
57
+ });
58
+ }
59
+
60
+ } // namespace react
61
+ } // namespace facebook
@@ -0,0 +1,32 @@
1
+ #pragma once
2
+
3
+ #include <ComponentFactory.h>
4
+ #include <fbjni/fbjni.h>
5
+ #include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
6
+ #include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>
7
+
8
+ namespace facebook {
9
+ namespace react {
10
+
11
+ class MainComponentsRegistry
12
+ : public facebook::jni::HybridClass<MainComponentsRegistry> {
13
+ public:
14
+ // Adapt it to the package you used for your Java class.
15
+ constexpr static auto kJavaDescriptor =
16
+ "Lcom/helloworld/newarchitecture/components/MainComponentsRegistry;";
17
+
18
+ static void registerNatives();
19
+
20
+ MainComponentsRegistry(ComponentFactory *delegate);
21
+
22
+ private:
23
+ static std::shared_ptr<ComponentDescriptorProviderRegistry const>
24
+ sharedProviderRegistry();
25
+
26
+ static jni::local_ref<jhybriddata> initHybrid(
27
+ jni::alias_ref<jclass>,
28
+ ComponentFactory *delegate);
29
+ };
30
+
31
+ } // namespace react
32
+ } // namespace facebook
@@ -0,0 +1,11 @@
1
+ #include <fbjni/fbjni.h>
2
+ #include "MainApplicationTurboModuleManagerDelegate.h"
3
+ #include "MainComponentsRegistry.h"
4
+
5
+ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
6
+ return facebook::jni::initialize(vm, [] {
7
+ facebook::react::MainApplicationTurboModuleManagerDelegate::
8
+ registerNatives();
9
+ facebook::react::MainComponentsRegistry::registerNatives();
10
+ });
11
+ }
@@ -0,0 +1,36 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Copyright (C) 2014 The Android Open Source Project
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this file except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
9
+
10
+ Unless required by applicable law or agreed to in writing, software
11
+ distributed under the License is distributed on an "AS IS" BASIS,
12
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ See the License for the specific language governing permissions and
14
+ limitations under the License.
15
+ -->
16
+ <inset xmlns:android="http://schemas.android.com/apk/res/android"
17
+ android:insetLeft="@dimen/abc_edit_text_inset_horizontal_material"
18
+ android:insetRight="@dimen/abc_edit_text_inset_horizontal_material"
19
+ android:insetTop="@dimen/abc_edit_text_inset_top_material"
20
+ android:insetBottom="@dimen/abc_edit_text_inset_bottom_material">
21
+
22
+ <selector>
23
+ <!--
24
+ This file is a copy of abc_edit_text_material (https://bit.ly/3k8fX7I).
25
+ The item below with state_pressed="false" and state_focused="false" causes a NullPointerException.
26
+ NullPointerException:tempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)'
27
+
28
+ <item android:state_pressed="false" android:state_focused="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
29
+
30
+ For more info, see https://bit.ly/3CdLStv (react-native/pull/29452) and https://bit.ly/3nxOMoR.
31
+ -->
32
+ <item android:state_enabled="false" android:drawable="@drawable/abc_textfield_default_mtrl_alpha"/>
33
+ <item android:drawable="@drawable/abc_textfield_activated_mtrl_alpha"/>
34
+ </selector>
35
+
36
+ </inset>
@@ -2,6 +2,7 @@
2
2
  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
3
3
  <item name="android:textColor">@android:color/black</item>
4
4
  <item name="android:editTextStyle">@style/ResetEditText</item>
5
+ <item name="android:editTextBackground">@drawable/rn_edit_text_material</item>
5
6
  </style>
6
7
  <style name="ResetEditText" parent="@android:style/Widget.EditText">
7
8
  <item name="android:padding">0dp</item>
@@ -1,20 +1,37 @@
1
+ import org.apache.tools.ant.taskdefs.condition.Os
2
+
1
3
  // Top-level build file where you can add configuration options common to all sub-projects/modules.
2
4
 
3
5
  buildscript {
4
6
  ext {
5
- buildToolsVersion = "29.0.3"
7
+ buildToolsVersion = findProperty('android.buildToolsVersion') ?: "31.0.0"
6
8
  minSdkVersion = 21
7
- compileSdkVersion = 30
8
- targetSdkVersion = 30
9
+ compileSdkVersion = Integer.parseInt(findProperty('android.compileSdkVersion') ?: "31")
10
+ targetSdkVersion = Integer.parseInt(findProperty('android.targetSdkVersion') ?: "31")
11
+ if (hasProperty('android.kotlinVersion')) {
12
+ kotlinVersion = findProperty('android.kotlinVersion')
13
+ }
14
+
15
+ if (System.properties['os.arch'] == "aarch64") {
16
+ // For M1 Users we need to use the NDK 24 which added support for aarch64
17
+ ndkVersion = "24.0.8215888"
18
+ } else if (Os.isFamily(Os.FAMILY_WINDOWS)) {
19
+ // For Android Users, we need to use NDK 23, otherwise the build will
20
+ // fail due to paths longer than the OS limit
21
+ ndkVersion = "23.1.7779620"
22
+ } else {
23
+ // Otherwise we default to the side-by-side NDK version from AGP.
24
+ ndkVersion = "21.4.7075529"
25
+ }
9
26
  }
10
27
  repositories {
11
28
  google()
12
29
  mavenCentral()
13
- jcenter()
14
30
  }
15
31
  dependencies {
16
- classpath("com.android.tools.build:gradle:4.1.0")
17
-
32
+ classpath("com.android.tools.build:gradle:7.0.4")
33
+ classpath("com.facebook.react:react-native-gradle-plugin")
34
+ classpath("de.undercouch:gradle-download-task:4.1.2")
18
35
  // NOTE: Do not place your application dependencies here; they belong
19
36
  // in the individual module build.gradle files
20
37
  }
@@ -33,8 +50,13 @@ allprojects {
33
50
  }
34
51
 
35
52
  google()
36
- mavenCentral()
37
- jcenter()
53
+ mavenCentral {
54
+ // We don't want to fetch react-native from Maven Central as there are
55
+ // older versions over there.
56
+ content {
57
+ excludeGroup "com.facebook.react"
58
+ }
59
+ }
38
60
  maven { url 'https://www.jitpack.io' }
39
61
  }
40
62
  }
@@ -0,0 +1,21 @@
1
+ # OSX
2
+ #
3
+ .DS_Store
4
+
5
+ # Android/IntelliJ
6
+ #
7
+ build/
8
+ .idea
9
+ .gradle
10
+ local.properties
11
+ *.iml
12
+ *.hprof
13
+
14
+ # BUCK
15
+ buck-out/
16
+ \.buckd/
17
+ *.keystore
18
+ !debug.keystore
19
+
20
+ # Bundle artifacts
21
+ *.jsbundle
@@ -1,5 +1,5 @@
1
1
  distributionBase=GRADLE_USER_HOME
2
2
  distributionPath=wrapper/dists
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-6.9-all.zip
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
@@ -9,8 +9,8 @@
9
9
 
10
10
  # Specifies the JVM arguments used for the daemon process.
11
11
  # The setting is particularly useful for tweaking memory settings.
12
- # Default value: -Xmx10248m -XX:MaxPermSize=256m
13
- org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
12
+ # Default value: -Xmx512m -XX:MaxMetaspaceSize=256m
13
+ org.gradle.jvmargs=-Xmx2048m -XX:MaxMetaspaceSize=512m
14
14
 
15
15
  # When configured, Gradle will run in incubating parallel mode.
16
16
  # This option should only be used with decoupled projects. More details, visit
@@ -26,7 +26,19 @@ android.useAndroidX=true
26
26
  android.enableJetifier=true
27
27
 
28
28
  # Version of flipper SDK to use with React Native
29
- FLIPPER_VERSION=0.54.0
29
+ FLIPPER_VERSION=0.125.0
30
+
31
+ # Use this property to specify which architecture you want to build.
32
+ # You can also override it from the CLI using
33
+ # ./gradlew <task> -PreactNativeArchitectures=x86_64
34
+ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
35
+
36
+ # Use this property to enable support to the new architecture.
37
+ # This will allow you to use TurboModules and the Fabric render in
38
+ # your application. You should enable this flag either if you want
39
+ # to write custom TurboModules/Fabric components OR use libraries that
40
+ # are providing them.
41
+ newArchEnabled=false
30
42
 
31
43
  # The hosted JavaScript engine
32
44
  # Supported values: expo.jsEngine = "hermes" | "jsc"
@@ -38,4 +50,4 @@ expo.gif.enabled=true
38
50
  expo.webp.enabled=true
39
51
  # Enable animated webp support (~3.4 MB increase)
40
52
  # Disabled by default because iOS doesn't support animated webp
41
- expo.webp.animated=false
53
+ expo.webp.animated=false
package/android/gradlew CHANGED
@@ -1,7 +1,7 @@
1
- #!/usr/bin/env sh
1
+ #!/bin/sh
2
2
 
3
3
  #
4
- # Copyright 2015 the original author or authors.
4
+ # Copyright © 2015-2021 the original authors.
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
7
7
  # you may not use this file except in compliance with the License.
@@ -17,78 +17,113 @@
17
17
  #
18
18
 
19
19
  ##############################################################################
20
- ##
21
- ## Gradle start up script for UN*X
22
- ##
20
+ #
21
+ # Gradle start up script for POSIX generated by Gradle.
22
+ #
23
+ # Important for running:
24
+ #
25
+ # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26
+ # noncompliant, but you have some other compliant shell such as ksh or
27
+ # bash, then to run this script, type that shell name before the whole
28
+ # command line, like:
29
+ #
30
+ # ksh Gradle
31
+ #
32
+ # Busybox and similar reduced shells will NOT work, because this script
33
+ # requires all of these POSIX shell features:
34
+ # * functions;
35
+ # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36
+ # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37
+ # * compound commands having a testable exit status, especially «case»;
38
+ # * various built-in commands including «command», «set», and «ulimit».
39
+ #
40
+ # Important for patching:
41
+ #
42
+ # (2) This script targets any POSIX shell, so it avoids extensions provided
43
+ # by Bash, Ksh, etc; in particular arrays are avoided.
44
+ #
45
+ # The "traditional" practice of packing multiple parameters into a
46
+ # space-separated string is a well documented source of bugs and security
47
+ # problems, so this is (mostly) avoided, by progressively accumulating
48
+ # options in "$@", and eventually passing that to Java.
49
+ #
50
+ # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51
+ # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52
+ # see the in-line comments for details.
53
+ #
54
+ # There are tweaks for specific operating systems such as AIX, CygWin,
55
+ # Darwin, MinGW, and NonStop.
56
+ #
57
+ # (3) This script is generated from the Groovy template
58
+ # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59
+ # within the Gradle project.
60
+ #
61
+ # You can find Gradle at https://github.com/gradle/gradle/.
62
+ #
23
63
  ##############################################################################
24
64
 
25
65
  # Attempt to set APP_HOME
66
+
26
67
  # 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
68
+ app_path=$0
69
+
70
+ # Need this for daisy-chained symlinks.
71
+ while
72
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73
+ [ -h "$app_path" ]
74
+ do
75
+ ls=$( ls -ld "$app_path" )
76
+ link=${ls#*' -> '}
77
+ case $link in #(
78
+ /*) app_path=$link ;; #(
79
+ *) app_path=$APP_HOME$link ;;
80
+ esac
37
81
  done
38
- SAVED="`pwd`"
39
- cd "`dirname \"$PRG\"`/" >/dev/null
40
- APP_HOME="`pwd -P`"
41
- cd "$SAVED" >/dev/null
82
+
83
+ APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
42
84
 
43
85
  APP_NAME="Gradle"
44
- APP_BASE_NAME=`basename "$0"`
86
+ APP_BASE_NAME=${0##*/}
45
87
 
46
88
  # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47
89
  DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48
90
 
49
91
  # Use the maximum available, or set MAX_FD != -1 to use that value.
50
- MAX_FD="maximum"
92
+ MAX_FD=maximum
51
93
 
52
94
  warn () {
53
95
  echo "$*"
54
- }
96
+ } >&2
55
97
 
56
98
  die () {
57
99
  echo
58
100
  echo "$*"
59
101
  echo
60
102
  exit 1
61
- }
103
+ } >&2
62
104
 
63
105
  # OS specific support (must be 'true' or 'false').
64
106
  cygwin=false
65
107
  msys=false
66
108
  darwin=false
67
109
  nonstop=false
68
- case "`uname`" in
69
- CYGWIN* )
70
- cygwin=true
71
- ;;
72
- Darwin* )
73
- darwin=true
74
- ;;
75
- MINGW* )
76
- msys=true
77
- ;;
78
- NONSTOP* )
79
- nonstop=true
80
- ;;
110
+ case "$( uname )" in #(
111
+ CYGWIN* ) cygwin=true ;; #(
112
+ Darwin* ) darwin=true ;; #(
113
+ MSYS* | MINGW* ) msys=true ;; #(
114
+ NONSTOP* ) nonstop=true ;;
81
115
  esac
82
116
 
83
117
  CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84
118
 
119
+
85
120
  # Determine the Java command to use to start the JVM.
86
121
  if [ -n "$JAVA_HOME" ] ; then
87
122
  if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
88
123
  # IBM's JDK on AIX uses strange locations for the executables
89
- JAVACMD="$JAVA_HOME/jre/sh/java"
124
+ JAVACMD=$JAVA_HOME/jre/sh/java
90
125
  else
91
- JAVACMD="$JAVA_HOME/bin/java"
126
+ JAVACMD=$JAVA_HOME/bin/java
92
127
  fi
93
128
  if [ ! -x "$JAVACMD" ] ; then
94
129
  die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
@@ -97,7 +132,7 @@ Please set the JAVA_HOME variable in your environment to match the
97
132
  location of your Java installation."
98
133
  fi
99
134
  else
100
- JAVACMD="java"
135
+ JAVACMD=java
101
136
  which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
102
137
 
103
138
  Please set the JAVA_HOME variable in your environment to match the
@@ -105,79 +140,95 @@ location of your Java installation."
105
140
  fi
106
141
 
107
142
  # Increase the maximum file descriptors if we can.
108
- if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
109
- MAX_FD_LIMIT=`ulimit -H -n`
110
- if [ $? -eq 0 ] ; then
111
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
112
- MAX_FD="$MAX_FD_LIMIT"
113
- fi
114
- ulimit -n $MAX_FD
115
- if [ $? -ne 0 ] ; then
116
- warn "Could not set maximum file descriptor limit: $MAX_FD"
117
- fi
118
- else
119
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
120
- fi
143
+ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144
+ case $MAX_FD in #(
145
+ max*)
146
+ MAX_FD=$( ulimit -H -n ) ||
147
+ warn "Could not query maximum file descriptor limit"
148
+ esac
149
+ case $MAX_FD in #(
150
+ '' | soft) :;; #(
151
+ *)
152
+ ulimit -n "$MAX_FD" ||
153
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
154
+ esac
121
155
  fi
122
156
 
123
- # For Darwin, add options to specify how the application appears in the dock
124
- if $darwin; then
125
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
126
- fi
157
+ # Collect all arguments for the java command, stacking in reverse order:
158
+ # * args from the command line
159
+ # * the main class name
160
+ # * -classpath
161
+ # * -D...appname settings
162
+ # * --module-path (only if needed)
163
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
127
164
 
128
165
  # For Cygwin or MSYS, switch paths to Windows format before running java
129
- if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
130
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132
- JAVACMD=`cygpath --unix "$JAVACMD"`
133
-
134
- # We build the pattern for arguments to be converted via cygpath
135
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
136
- SEP=""
137
- for dir in $ROOTDIRSRAW ; do
138
- ROOTDIRS="$ROOTDIRS$SEP$dir"
139
- SEP="|"
140
- done
141
- OURCYGPATTERN="(^($ROOTDIRS))"
142
- # Add a user-defined pattern to the cygpath arguments
143
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
144
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
145
- fi
166
+ if "$cygwin" || "$msys" ; then
167
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169
+
170
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
171
+
146
172
  # Now convert the arguments - kludge to limit ourselves to /bin/sh
147
- i=0
148
- for arg in "$@" ; do
149
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
150
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
151
-
152
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
153
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
154
- else
155
- eval `echo args$i`="\"$arg\""
173
+ for arg do
174
+ if
175
+ case $arg in #(
176
+ -*) false ;; # don't mess with options #(
177
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178
+ [ -e "$t" ] ;; #(
179
+ *) false ;;
180
+ esac
181
+ then
182
+ arg=$( cygpath --path --ignore --mixed "$arg" )
156
183
  fi
157
- i=`expr $i + 1`
184
+ # Roll the args list around exactly as many times as the number of
185
+ # args, so each arg winds up back in the position where it started, but
186
+ # possibly modified.
187
+ #
188
+ # NB: a `for` loop captures its iteration list before it begins, so
189
+ # changing the positional parameters here affects neither the number of
190
+ # iterations, nor the values presented in `arg`.
191
+ shift # remove old arg
192
+ set -- "$@" "$arg" # push replacement arg
158
193
  done
159
- case $i in
160
- 0) set -- ;;
161
- 1) set -- "$args0" ;;
162
- 2) set -- "$args0" "$args1" ;;
163
- 3) set -- "$args0" "$args1" "$args2" ;;
164
- 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165
- 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166
- 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167
- 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168
- 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169
- 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
170
- esac
171
194
  fi
172
195
 
173
- # Escape application args
174
- save () {
175
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176
- echo " "
177
- }
178
- APP_ARGS=`save "$@"`
196
+ # Collect all arguments for the java command;
197
+ # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198
+ # shell script including quotes and variable substitutions, so put them in
199
+ # double quotes to make sure that they get re-expanded; and
200
+ # * put everything else in single quotes, so that it's not re-expanded.
201
+
202
+ set -- \
203
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
204
+ -classpath "$CLASSPATH" \
205
+ org.gradle.wrapper.GradleWrapperMain \
206
+ "$@"
207
+
208
+ # Use "xargs" to parse quoted args.
209
+ #
210
+ # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211
+ #
212
+ # In Bash we could simply go:
213
+ #
214
+ # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215
+ # set -- "${ARGS[@]}" "$@"
216
+ #
217
+ # but POSIX shell has neither arrays nor command substitution, so instead we
218
+ # post-process each arg (as a line of input to sed) to backslash-escape any
219
+ # character that might be a shell metacharacter, then use eval to reverse
220
+ # that process (while maintaining the separation between arguments), and wrap
221
+ # the whole thing up as a single "set" statement.
222
+ #
223
+ # This will of course break if any of these variables contains a newline or
224
+ # an unmatched quote.
225
+ #
179
226
 
180
- # Collect all arguments for the java command, following the shell quoting and substitution rules
181
- eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
227
+ eval "set -- $(
228
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229
+ xargs -n1 |
230
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231
+ tr '\n' ' '
232
+ )" '"$@"'
182
233
 
183
234
  exec "$JAVACMD" "$@"