├── Sample ├── app │ ├── .gitignore │ ├── src │ │ └── main │ │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── newtronlabs │ │ │ │ └── easypermissions │ │ │ │ └── sample │ │ │ │ ├── MainActivity.java │ │ │ │ └── ExampleService.java │ │ │ └── AndroidManifest.xml │ └── build.gradle ├── settings.gradle ├── .idea │ ├── copyright │ │ └── profiles_settings.xml │ ├── runConfigurations.xml │ ├── compiler.xml │ └── misc.xml ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── build.gradle ├── .gitignore ├── gradlew.bat └── gradlew ├── Sample-Diagram.png └── README.md /Sample/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /Sample/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | -------------------------------------------------------------------------------- /Sample-Diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NewtronLabs/EasyPermissions/HEAD/Sample-Diagram.png -------------------------------------------------------------------------------- /Sample/.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Sample/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NewtronLabs/EasyPermissions/HEAD/Sample/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /Sample/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NewtronLabs/EasyPermissions/HEAD/Sample/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /Sample/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NewtronLabs/EasyPermissions/HEAD/Sample/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /Sample/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NewtronLabs/EasyPermissions/HEAD/Sample/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Sample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NewtronLabs/EasyPermissions/HEAD/Sample/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Sample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NewtronLabs/EasyPermissions/HEAD/Sample/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Sample/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #fff05f40 4 | #fff05f40 5 | #FFFFFFFF 6 | 7 | -------------------------------------------------------------------------------- /Sample/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sun Sep 09 23:29:58 EDT 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip 7 | -------------------------------------------------------------------------------- /Sample/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 5dp 6 | 16dp 7 | 32dp 8 | 1dip 9 | 10dip 10 | 200dip 11 | 12 | -------------------------------------------------------------------------------- /Sample/.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /Sample/app/src/main/java/com/newtronlabs/easypermissions/sample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.newtronlabs.easypermissions.sample; 2 | 3 | import android.content.Intent; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.os.Bundle; 6 | 7 | public class MainActivity extends AppCompatActivity 8 | { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) 12 | { 13 | super.onCreate(savedInstanceState); 14 | setContentView(R.layout.activity_main); 15 | 16 | // Launch a service to show that even from a Service we can request permissions. 17 | Intent intent = new Intent(this, ExampleService.class); 18 | startService(intent); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Sample/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Sample/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 27 5 | 6 | defaultConfig { 7 | applicationId "com.newtronlabs.easypermissions.sample" 8 | minSdkVersion 19 9 | targetSdkVersion 27 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | implementation fileTree(dir: 'libs', include: ['*.jar']) 23 | implementation 'com.android.support:appcompat-v7:27.1.1' 24 | 25 | // Maven dependency. 26 | compileOnly 'com.newtronlabs.easypermissions:easypermissions:4.0.1' 27 | } 28 | -------------------------------------------------------------------------------- /Sample/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | google() 6 | jcenter() 7 | maven { url "http://code.newtronlabs.com:8081/artifactory/libs-release-local" } 8 | } 9 | dependencies { 10 | classpath 'com.android.tools.build:gradle:3.0.1' 11 | classpath 'com.newtronlabs.android:plugin:2.0.1' 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | google() 18 | jcenter() 19 | maven { url "http://code.newtronlabs.com:8081/artifactory/libs-release-local" } 20 | } 21 | } 22 | 23 | subprojects { 24 | apply plugin: 'com.newtronlabs.android' 25 | } 26 | 27 | task clean(type: Delete) { 28 | delete rootProject.buildDir 29 | } -------------------------------------------------------------------------------- /Sample/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | Easy Permissions Sample 3 | 4 | Information 5 | 6 | Each Android app operates in a process sandbox, apps must 7 | explicitly request access to resources and data outside their sandbox. If the device 8 | is running Android 6.0 (API level 23) or higher, and the app\'s targetSdkVersion is 23 9 | or higher, the app requests permissions from the user at run-time. 10 | 11 | \n\nHowever, Android requires that these request come from an Activity. With Easy Permissions 12 | this is no longer an issue, you may request permission from anywhere as long as you provide 13 | context. In addition if you request a permission that is already granted the user will not 14 | be prompted. 15 | 16 | 17 | -------------------------------------------------------------------------------- /Sample/.gitignore: -------------------------------------------------------------------------------- 1 | *.apk 2 | *.ap_ 3 | 4 | # Files for the ART/Dalvik VM 5 | *.dex 6 | 7 | # Java class files 8 | *.class 9 | 10 | # Generated files 11 | bin/ 12 | gen/ 13 | out/ 14 | 15 | # Gradle files 16 | .gradle/ 17 | build/ 18 | 19 | # Local configuration file (sdk path, etc) 20 | local.properties 21 | 22 | # Proguard folder generated by Eclipse 23 | proguard/ 24 | 25 | # Log Files 26 | *.log 27 | 28 | # Android Studio Navigation editor temp files 29 | .navigation/ 30 | 31 | # Android Studio captures folder 32 | captures/ 33 | 34 | # Intellij 35 | *.iml 36 | .idea/workspace.xml 37 | .idea/tasks.xml 38 | .idea/gradle.xml 39 | .idea/dictionaries 40 | .idea/libraries 41 | 42 | # Keystore files 43 | *.jks 44 | 45 | # External native build folder generated in Android Studio 2.2 and later 46 | .externalNativeBuild 47 | 48 | # Google Services (e.g. APIs or Firebase) 49 | google-services.json 50 | 51 | # Freeline 52 | freeline.py 53 | freeline/ 54 | freeline_project_description.json.externalNativeBuild 55 | -------------------------------------------------------------------------------- /Sample/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 15 | 16 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Sample/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /Sample/app/src/main/java/com/newtronlabs/easypermissions/sample/ExampleService.java: -------------------------------------------------------------------------------- 1 | package com.newtronlabs.easypermissions.sample; 2 | 3 | import android.app.Service; 4 | import android.content.Intent; 5 | import android.os.IBinder; 6 | import android.support.annotation.Nullable; 7 | 8 | import com.newtronlabs.easypermissions.EasyPermissions; 9 | import com.newtronlabs.easypermissions.listener.IError; 10 | import com.newtronlabs.easypermissions.listener.IPermissionsListener; 11 | 12 | import java.util.Set; 13 | 14 | public class ExampleService extends Service implements IPermissionsListener 15 | { 16 | @Override 17 | public void onCreate() 18 | { 19 | super.onCreate(); 20 | 21 | // Will request all permissions from the Manifest automatically. 22 | EasyPermissions.getInstance().requestPermissions(this, this); 23 | } 24 | 25 | @Override 26 | public void onRequestSent(Set set) 27 | { 28 | } 29 | 30 | @Override 31 | public void onFailure(IError error) 32 | { 33 | } 34 | 35 | @Override 36 | public void onCompleted(Set grantedPermissions, Set deniedPermissions) 37 | { 38 | } 39 | 40 | 41 | @Override 42 | public int onStartCommand(Intent intent, int flags, int startId) 43 | { 44 | return START_NOT_STICKY; 45 | } 46 | 47 | 48 | @Nullable 49 | @Override 50 | public IBinder onBind(Intent intent) 51 | { 52 | return null; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Sample/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 15 | 16 | 20 | 21 | 24 | 25 | 26 | 30 | 31 | 34 | 35 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /Sample/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /Sample/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Easy Permissions 2 | 3 | Easy Permissions allows you to request all the permissions declared in your `AndroidManifest` with one line of code. It knows what permissions you have declared in your `AndroidManifest` and will request them for you if needed. In addition, it allows you to make this request from anywhere in your code; no longer will you have to request permissions exclusively from an `Activity`. 4 | 5 |

6 | Easy Permissions 7 |

8 | 9 | --- 10 | 11 | **Sample** - It knows what permissions you have in your `AndroidManifest` and will request them if needed. 12 | ```kotlin 13 | EasyPermissions.getInstance().requestPermissions(IPermissionsListener( 14 | onCompleted = { grantedPermissions, deniedPermissions -> 15 | 16 | } 17 | )) 18 | ``` 19 | 20 | --- 21 | 22 | # Table of Contents 23 | 1. [Information](#information) 24 | 2. [Setup](#setup) 25 | 3. [Example 1](#example-1) 26 | * [Kotlin](#kotlin) 27 | * [Java](#java) 28 | 4. [Example 2](#example-2) 29 | 5. [Example 3](#example-3) 30 | 6. [Demo App](#demo-app) 31 | 7. [Support Us](#support-us) 32 | 8. [License](#license) 33 | 9. [Contact](#contact) 34 | 35 | 36 | ## Information 37 | Request permissions from anywhere. Make sure you implement `IPermissionsListener` to receive information about what is happening with your permission request. 38 | 39 | ## Setup 40 | Include the below dependencies in your `build.gradle` project. 41 | 42 | ```gradle 43 | buildscript { 44 | repositories { 45 | google() 46 | maven { url "https://newtronlabs.jfrog.io/artifactory/libs-release-local" } 47 | } 48 | dependencies { 49 | classpath 'com.android.tools.build:gradle:7.0.4' 50 | classpath 'com.newtronlabs.android:plugin:5.0.2' 51 | } 52 | } 53 | 54 | allprojects { 55 | repositories { 56 | google() 57 | maven { url "https://newtronlabs.jfrog.io/artifactory/libs-release-local" } 58 | } 59 | } 60 | 61 | subprojects { 62 | apply plugin: 'com.newtronlabs.android' 63 | } 64 | ``` 65 | 66 | In the `build.gradle` for your app. 67 | 68 | ```gradle 69 | dependencies { 70 | compileOnly 'com.newtronlabs.easypermissions:easypermissions:5.0.3-alpha01' 71 | } 72 | ``` 73 | 74 | ## Example 1 75 | This example uses a `Service` to request the permission, something that cannot be done without EasyPermissions. It also automatically requests the permissions that you have enabled on your `AndroidManifest`. 76 | 77 | 78 | ### Kotlin 79 | ```kotlin 80 | class ExampleService : Service(), IPermissionsListener { 81 | override fun onCreate() { 82 | super.onCreate() 83 | 84 | // Will request all permissions from the Manifest automatically. 85 | EasyPermissions.getInstance().requestPermissions(this) 86 | } 87 | 88 | override fun onCompleted(grantedPermissions: Set, deniedPermissions: Set) {} 89 | 90 | override fun onFailure(throwable: Throwable) {} 91 | } 92 | ``` 93 | 94 | ### Java 95 | ```java 96 | public class ExampleService extends Service implements IPermissionsListener { 97 | @Override 98 | public void onCreate() { 99 | super.onCreate(); 100 | 101 | // Will request all permissions from the Manifest automatically. 102 | EasyPermissions.getInstance().requestPermissions(this); 103 | } 104 | 105 | @Override 106 | public void onCompleted(Set grantedPermissions, Set deniedPermissions) {} 107 | 108 | @Override 109 | public void onFailure(Throwable throwable) {} 110 | } 111 | ``` 112 | 113 | ## Example 2 114 | This example allows more flexibility so that you can decide which permissions you desire. Request as many permissions as you like. You may seperate them by commas or pass an array. Make sure that these permissions are declared in your `AndroidManifest` as well. 115 | 116 | ```kotlin 117 | EasyPermissions.getInstance().requestPermissions(this, 118 | Manifest.permission.ACCESS_FINE_LOCATION, 119 | Manifest.permission.CAMERA, 120 | Manifest.permission.CALL_PHONE, 121 | Manifest.permission.WRITE_EXTERNAL_STORAGE); 122 | ``` 123 | 124 | ## Example 3 125 | Get a set of granted permissions. 126 | 127 | ```kotlin 128 | EasyPermissions.getInstance().getGrantedPermissions() 129 | ``` 130 | 131 | ### Always add the permission to your AndroidManifest.xml 132 | 133 | As an Android requirement permissions must be included in the Manifest. 134 | 135 | ```xml 136 | 137 | 138 | 139 | 140 | ``` 141 | 142 | ## Demo App 143 | More detailed exmaples can be found in this repo's samples folders: [Demo app](/Sample) 144 | 145 | --- 146 | 147 | ## Support Us 148 | Please support the continued development of these libraries. We host and develop these libraries for free. Any support is deeply appriciated. Thank you! 149 | 150 |

151 | Support us 152 |

153 | 154 |

155 | BTC Address: 39JmAfnNhaEPKz5wjQjQQj4jcv9BM11NQb 156 |

157 | 158 | 159 | 160 | 161 | 162 | --- 163 | 164 | ## License 165 | https://gist.github.com/NewtronLabs/216f45db2339e0bc638e7c14a6af9cc8 166 | 167 | ## Contact 168 | solutions@newtronlabs.com 169 | 170 | ### Website 171 | http://www.newtronlabs.com/ 172 | -------------------------------------------------------------------------------- /Sample/gradlew: -------------------------------------------------------------------------------- 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 "$@" 161 | --------------------------------------------------------------------------------