173 | *
174 | * @param list
175 | * @param separator
176 | * @return join list to string with separator. if list is empty, return ""
177 | */
178 | public static String join(List list, String separator) {
179 | if( isEmpty( list ) || TextUtils.isEmpty( separator ) ){
180 | throw new IllegalArgumentException( "list or separator is illegal, please check it!" );
181 | }
182 |
183 | if (separator == null) {
184 | separator = DEFAULT_JOIN_SEPARATOR;
185 | }
186 |
187 | StringBuilder joinStr = new StringBuilder();
188 | for (int i = 0; i < list.size(); i++) {
189 | joinStr.append(list.get(i));
190 | if (i != list.size() - 1) {
191 | joinStr.append(separator);
192 | }
193 | }
194 | return joinStr.toString();
195 | }
196 |
197 | /**
198 | * add distinct entry to list
199 | *
200 | * @param
201 | * @param sourceList
202 | * @param entry
203 | * @return if entry already exist in sourceList, return false, else add it and return true.
204 | */
205 | public static boolean addDistinctEntry(List sourceList, V entry) {
206 | if( isEmpty( sourceList ) || null == entry ){
207 | throw new IllegalArgumentException( "sourceList or entry is illegal, please check it!" );
208 | }
209 |
210 | return (sourceList != null && !sourceList.contains(entry)) ? sourceList.add(entry) : false;
211 | }
212 |
213 | /**
214 | * add all distinct entry to list1 from list2
215 | *
216 | * @param
217 | * @param sourceList
218 | * @param entryList
219 | * @return the count of entries be added
220 | */
221 | public static int addDistinctList(List sourceList, List entryList) {
222 | if( isEmpty( sourceList ) || isEmpty( entryList ) ){
223 | throw new IllegalArgumentException( "sourceList or entryList is illegal, please check it!" );
224 | }
225 |
226 | int sourceCount = sourceList.size();
227 | for (V entry : entryList) {
228 | if (!sourceList.contains(entry)) {
229 | sourceList.add(entry);
230 | }
231 | }
232 | return sourceList.size() - sourceCount;
233 | }
234 |
235 | /**
236 | * add not null entry to list
237 | *
238 | * @param sourceList
239 | * @param value
240 | * @return
241 | *
if sourceList is null, return false
242 | *
if value is null, return false
243 | *
return {@link List#add(Object)}
244 | *
245 | */
246 | public static boolean addListNotNullValue(List sourceList, V value) {
247 | if( isEmpty( sourceList ) || null == value ){
248 | throw new IllegalArgumentException( "sourceList or value is illegal, please check it!" );
249 | }
250 |
251 | return (sourceList != null && value != null) ? sourceList.add(value) : false;
252 | }
253 |
254 | /**
255 | * invert list
256 | *
257 | * @param sourceList
258 | * @return random list
259 | */
260 | public static List invertList(List sourceList) {
261 | if (isEmpty(sourceList)) {
262 | throw new IllegalArgumentException( "sourceList is illegal, please check it!" );
263 | }
264 |
265 | List invertList = new ArrayList(sourceList.size());
266 | for (int i = sourceList.size() - 1; i >= 0; i--) {
267 | invertList.add(sourceList.get(i));
268 | }
269 |
270 | return invertList;
271 | }
272 |
273 | /**
274 | * 打乱List
275 | *
276 | * */
277 | public static List randomList(List sourceList){
278 | // Collections.shuffle( sourceList ); 可以用这个方法代替
279 | if (ListUtils.isEmpty( sourceList )) {
280 | throw new IllegalArgumentException( "sourceList is illegal, please check it!" );
281 | }
282 |
283 | List randomList = new ArrayList( sourceList.size( ) );
284 | do{
285 | int randomIndex = Math.abs( new Random( ).nextInt( sourceList.size() ) );
286 | randomList.add( sourceList.remove( randomIndex ) );
287 | }while( !ListUtils.isEmpty( sourceList ) );
288 |
289 | return randomList;
290 | }
291 | }
292 |
--------------------------------------------------------------------------------
/app/src/main/java/com/zsj/filetodbdemo/util/PreferencesUtils.java:
--------------------------------------------------------------------------------
1 | package com.zsj.filetodbdemo.util;
2 |
3 | import android.content.Context;
4 | import android.content.SharedPreferences;
5 |
6 | /**
7 | * PreferencesUtils, easy to get or put data
8 | *
9 | * Preference Name
10 | *
you can change preference name by {@link #PREFERENCE_NAME}
11 | *
12 | *
13 | * Put Value
14 | *
put string {@link #putString(Context, String, String)}
15 | *
put int {@link #putInt(Context, String, int)}
16 | *
put long {@link #putLong(Context, String, long)}
17 | *
put float {@link #putFloat(Context, String, float)}
18 | *
put boolean {@link #putBoolean(Context, String, boolean)}
19 | *
20 | *
21 | * Get Value
22 | *
get string {@link #getString(Context, String)}, {@link #getString(Context, String, String)}
23 | *
get int {@link #getInt(Context, String)}, {@link #getInt(Context, String, int)}
24 | *
get long {@link #getLong(Context, String)}, {@link #getLong(Context, String, long)}
25 | *
get float {@link #getFloat(Context, String)}, {@link #getFloat(Context, String, float)}
26 | *
get boolean {@link #getBoolean(Context, String)}, {@link #getBoolean(Context, String, boolean)}
27 | *
28 | *
29 | */
30 | public class PreferencesUtils {
31 | public static String PREFERENCE_NAME = "Open";
32 | private PreferencesUtils() {
33 | throw new AssertionError();
34 | }
35 |
36 | /**
37 | * put string preferences
38 | *
39 | * @param context
40 | * @param key The name of the preference to modify
41 | * @param value The new value for the preference
42 | * @return True if the new values were successfully written to persistent storage.
43 | */
44 | public static boolean putString(Context context, String key, String value) {
45 | SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
46 | SharedPreferences.Editor editor = settings.edit();
47 | editor.putString(key, value);
48 | return editor.commit();
49 | }
50 |
51 | /**
52 | * get string preferences
53 | *
54 | * @param context
55 | * @param key The name of the preference to retrieve
56 | * @return The preference value if it exists, or null. Throws ClassCastException if there is a preference with this
57 | * name that is not a string
58 | * @see #getString(Context, String, String)
59 | */
60 | public static String getString(Context context, String key) {
61 | return getString(context, key, null);
62 | }
63 |
64 | /**
65 | * get string preferences
66 | *
67 | * @param context
68 | * @param key The name of the preference to retrieve
69 | * @param defaultValue Value to return if this preference does not exist
70 | * @return The preference value if it exists, or defValue. Throws ClassCastException if there is a preference with
71 | * this name that is not a string
72 | */
73 | public static String getString(Context context, String key, String defaultValue) {
74 | SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
75 | return settings.getString(key, defaultValue);
76 | }
77 |
78 | /**
79 | * put int preferences
80 | *
81 | * @param context
82 | * @param key The name of the preference to modify
83 | * @param value The new value for the preference
84 | * @return True if the new values were successfully written to persistent storage.
85 | */
86 | public static boolean putInt(Context context, String key, int value) {
87 | SharedPreferences settings = context.getApplicationContext().getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
88 | SharedPreferences.Editor editor = settings.edit();
89 | editor.putInt(key, value);
90 | return editor.commit();
91 | }
92 |
93 | /**
94 | * get int preferences
95 | *
96 | * @param context
97 | * @param key The name of the preference to retrieve
98 | * @return The preference value if it exists, or -1. Throws ClassCastException if there is a preference with this
99 | * name that is not a int
100 | * @see #getInt(Context, String, int)
101 | */
102 | public static int getInt(Context context, String key) {
103 | return getInt(context, key, -1);
104 | }
105 |
106 | /**
107 | * get int preferences
108 | *
109 | * @param context
110 | * @param key The name of the preference to retrieve
111 | * @param defaultValue Value to return if this preference does not exist
112 | * @return The preference value if it exists, or defValue. Throws ClassCastException if there is a preference with
113 | * this name that is not a int
114 | */
115 | public static int getInt(Context context, String key, int defaultValue) {
116 | SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
117 | return settings.getInt(key, defaultValue);
118 | }
119 |
120 | /**
121 | * put long preferences
122 | *
123 | * @param context
124 | * @param key The name of the preference to modify
125 | * @param value The new value for the preference
126 | * @return True if the new values were successfully written to persistent storage.
127 | */
128 | public static boolean putLong(Context context, String key, long value) {
129 | SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
130 | SharedPreferences.Editor editor = settings.edit();
131 | editor.putLong(key, value);
132 | return editor.commit();
133 | }
134 |
135 | /**
136 | * get long preferences
137 | *
138 | * @param context
139 | * @param key The name of the preference to retrieve
140 | * @return The preference value if it exists, or -1. Throws ClassCastException if there is a preference with this
141 | * name that is not a long
142 | * @see #getLong(Context, String, long)
143 | */
144 | public static long getLong(Context context, String key) {
145 | return getLong(context, key, -1);
146 | }
147 |
148 | /**
149 | * get long preferences
150 | *
151 | * @param context
152 | * @param key The name of the preference to retrieve
153 | * @param defaultValue Value to return if this preference does not exist
154 | * @return The preference value if it exists, or defValue. Throws ClassCastException if there is a preference with
155 | * this name that is not a long
156 | */
157 | public static long getLong(Context context, String key, long defaultValue) {
158 | SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
159 | return settings.getLong(key, defaultValue);
160 | }
161 |
162 | /**
163 | * put float preferences
164 | *
165 | * @param context
166 | * @param key The name of the preference to modify
167 | * @param value The new value for the preference
168 | * @return True if the new values were successfully written to persistent storage.
169 | */
170 | public static boolean putFloat(Context context, String key, float value) {
171 | SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
172 | SharedPreferences.Editor editor = settings.edit();
173 | editor.putFloat(key, value);
174 | return editor.commit();
175 | }
176 |
177 | /**
178 | * get float preferences
179 | *
180 | * @param context
181 | * @param key The name of the preference to retrieve
182 | * @return The preference value if it exists, or -1. Throws ClassCastException if there is a preference with this
183 | * name that is not a float
184 | * @see #getFloat(Context, String, float)
185 | */
186 | public static float getFloat(Context context, String key) {
187 | return getFloat(context, key, -1);
188 | }
189 |
190 | /**
191 | * get float preferences
192 | *
193 | * @param context
194 | * @param key The name of the preference to retrieve
195 | * @param defaultValue Value to return if this preference does not exist
196 | * @return The preference value if it exists, or defValue. Throws ClassCastException if there is a preference with
197 | * this name that is not a float
198 | */
199 | public static float getFloat(Context context, String key, float defaultValue) {
200 | SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
201 | return settings.getFloat(key, defaultValue);
202 | }
203 |
204 | /**
205 | * put boolean preferences
206 | *
207 | * @param context
208 | * @param key The name of the preference to modify
209 | * @param value The new value for the preference
210 | * @return True if the new values were successfully written to persistent storage.
211 | */
212 | public static boolean putBoolean(Context context, String key, boolean value) {
213 | SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
214 | SharedPreferences.Editor editor = settings.edit();
215 | editor.putBoolean(key, value);
216 | return editor.commit();
217 | }
218 |
219 | /**
220 | * get boolean preferences, default is false
221 | *
222 | * @param context
223 | * @param key The name of the preference to retrieve
224 | * @return The preference value if it exists, or false. Throws ClassCastException if there is a preference with this
225 | * name that is not a boolean
226 | * @see #getBoolean(Context, String, boolean)
227 | */
228 | public static boolean getBoolean(Context context, String key) {
229 | return getBoolean(context, key, false);
230 | }
231 |
232 | /**
233 | * get boolean preferences
234 | *
235 | * @param context
236 | * @param key The name of the preference to retrieve
237 | * @param defaultValue Value to return if this preference does not exist
238 | * @return The preference value if it exists, or defValue. Throws ClassCastException if there is a preference with
239 | * this name that is not a boolean
240 | */
241 | public static boolean getBoolean(Context context, String key, boolean defaultValue) {
242 | SharedPreferences settings = context.getSharedPreferences(PREFERENCE_NAME, Context.MODE_PRIVATE);
243 | return settings.getBoolean(key, defaultValue);
244 | }
245 | }
246 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
27 |
28 |
37 |
38 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangshao45612/FileToDbDemo/7a4e5a7b7116a9026523d153132d5c59e74f778f/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangshao45612/FileToDbDemo/7a4e5a7b7116a9026523d153132d5c59e74f778f/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangshao45612/FileToDbDemo/7a4e5a7b7116a9026523d153132d5c59e74f778f/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangshao45612/FileToDbDemo/7a4e5a7b7116a9026523d153132d5c59e74f778f/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangshao45612/FileToDbDemo/7a4e5a7b7116a9026523d153132d5c59e74f778f/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangshao45612/FileToDbDemo/7a4e5a7b7116a9026523d153132d5c59e74f778f/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangshao45612/FileToDbDemo/7a4e5a7b7116a9026523d153132d5c59e74f778f/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangshao45612/FileToDbDemo/7a4e5a7b7116a9026523d153132d5c59e74f778f/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangshao45612/FileToDbDemo/7a4e5a7b7116a9026523d153132d5c59e74f778f/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangshao45612/FileToDbDemo/7a4e5a7b7116a9026523d153132d5c59e74f778f/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 | 16dp
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FileToDbDemo
3 | Settings
4 | 把excel文件写进数据库
5 | 读取assets里db数据
6 | 把assets里的文件写入数据库
7 | 把assets里的db文件拷贝到数据库
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/test/java/com/zsj/filetodbdemo/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.zsj.filetodbdemo;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/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 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.3'
9 |
10 | // NOTE: Do not place your application dependencies here; they belong
11 | // in the individual module build.gradle files
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | jcenter()
18 | }
19 | }
20 |
21 | task clean(type: Delete) {
22 | delete rootProject.buildDir
23 | }
24 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-Xmx1536m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zhangshao45612/FileToDbDemo/7a4e5a7b7116a9026523d153132d5c59e74f778f/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Nov 23 10:06:39 CST 2017
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-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------