├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ └── main
│ ├── AndroidManifest.xml
│ ├── assets
│ └── stat_id.json
│ ├── java
│ └── com
│ │ └── tamic
│ │ └── statsdkdemo
│ │ ├── BaseActivity.java
│ │ ├── MainActivity.java
│ │ ├── SecondActivity.java
│ │ └── StatAppliation.java
│ └── res
│ ├── layout
│ ├── activity_main.xml
│ └── lay_activity_second.xml
│ ├── mipmap-hdpi
│ └── ic_launcher.png
│ ├── mipmap-mdpi
│ └── ic_launcher.png
│ ├── mipmap-xhdpi
│ └── ic_launcher.png
│ ├── mipmap-xxhdpi
│ └── ic_launcher.png
│ ├── values-w820dp
│ └── dimens.xml
│ └── values
│ ├── dimens.xml
│ ├── strings.xml
│ └── styles.xml
├── build.gradle
├── gradle.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the ART/Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 | out/
15 |
16 | # Gradle files
17 | .gradle/
18 | build/
19 |
20 | # Local configuration file (sdk path, etc)
21 | local.properties
22 |
23 | # Proguard folder generated by Eclipse
24 | proguard/
25 |
26 | # Log Files
27 | *.log
28 |
29 | # Android Studio Navigation editor temp files
30 | .navigation/
31 |
32 | # Android Studio captures folder
33 | captures/
34 |
35 | # Intellij
36 | *.iml
37 | .idea/workspace.xml
38 |
39 | # Keystore files
40 | *.jks
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Sky Monitoring 天眼
2 | # Android StaticFrameWork
3 | 自定义统计SDK, 完全放弃第三方平台,让app拥有自主的数据统计功能
4 |
5 | >支持Activity统计
6 |
7 | >自定义事件统计
8 |
9 | >APP启动退出唤醒自动统计
10 |
11 | >crsah日志统计
12 |
13 |
14 |
15 |
16 |
17 | 客户端SDK功能概述
18 | -------
19 | 在使用统计服务前,开发者先要拿到本身APPID。其中AppId是客户端的身份标识,在客户端SDK初始化时使用。然后下载最新Library的SDK压缩包,其中包括了Android SDK和AndroidDemo。Android版SDK以Module形式提供, 你的APP只需要添加少量代码和配置,即可完成接入TcInterface统计服务。
20 |
21 | >统计服务Android
22 |
23 | SDK所有的接口都封装在TcStatInterface抽象类的静态方法中,主要功能接口请参考第3节API说明。应用在启动时,需要调用initialize方法来初始化统计服务,之后便可按照统计的业务需求,调用统计数据上报接口上报统计打点。
24 | SDK提供了接口给开发者来设置向统计统计服务器上报统计数据的策略,开发者可以在任意时候调用修改策略。客户端SDK上报的数据包括默认事件统计、应用全局(AppAction)统计(用于统计app的唤醒、打开关闭频率、使用时长等)、页面访问统计(Page)和自定义事件统计(Event)。
25 | 统计SDK提供app的崩溃日志收集功能(统计SDK2.0 将会新增)。功能开启后,对于app在使用过程中的崩溃,SDK将自动采集崩溃日志,并上传到统计后台;统计后台会根据app版本,对崩溃进行聚合、展示。
26 |
27 | SDK使用配置
28 | ----
29 |
30 |
31 | 本节主要介绍使用统计SDK前的准备工作,开发者也可以参照SDK中的demo来配置。
32 |
33 | 2.1. 配置AndroidManifest.xml文件
34 | SDK支持的最低安卓版本为2.2。
35 |
36 |
37 | 统计服务需要的权限列表
38 | 权限
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 | 对应的5种权限,用途如下:
49 |
50 | 网络访问权限,需要联网以便于向小米统计服务端上报统计数据。
51 | 查看网络状态,用于根据不同的网络环境,选择相应的上报策略。同时也需要上报当前的网络环境用于后台统计展示。
52 | 读取手机状态和身份,用于获取设备的唯一标识,为当前设备生成一个唯一设备ID。
53 | 查看Wifi状态权限,用于获取mac地址,生成设备唯一标示。
54 | 获取用户地理位置信息,用于获取精准确的地理位置,变于统计用户分布情况。
55 |
56 | 2.2. 初始化统计服务
57 | 应用启动时,需要调用统计SDK中的初始化方法,传入appID(目前已定义好相关APPID,参见下表)等身份验证参数和应用对应的渠道号。在调用其他统计服务相关API前,必须调用本方法初始化统计服务,
58 | 建议您在程序的Application的onCreate中初始化Tamic统计服务。传入即可。
59 |
60 |
61 |
62 | APP常规数据统计
63 | --
64 |
65 | 本节主要介绍如何设置数据上报策略,如何记录页面访问行为和用户自定义事件。本节也介绍了通过集成测试模块验证SDK是否集成成功的方法。
66 |
67 |
68 | 3.1. 数据上报策略
69 |
70 | 统计服务SDK会先把数据记录缓存在本地,然后根据开发者设定的数据上报策略,触发上报流程。SDK中提供了一系列数据上报策略供开发者选择,这些策略包括:
71 |
72 | >UPLOAD_POLICY_REALTIME 实时上报。每当有一条新的记录,就会激发一次上报。
73 |
74 | >UPLOAD_POLICY_WIFI_ONLY 只在WIFI下上报。当设备处于WIFI连接时实时上报,否则不上报记录。
75 |
76 | > UPLOAD_POLICY_BATCH 批量上报。当记录在本地累积超过一个固定值时(100条),会触发一次上报。
77 |
78 | > UPLOAD_POLICY_WHILE_INITIALIZE
79 | 启动时候上报。每次应用启动(调用initialize方法)时候,会将上一次应用使用产生的数据记录打包上报。
80 | UPLOAD_POLICY_INTERVAL
81 | 指定时间间隔上报。开发者可以指定从1分钟-60天之间的任意时间间隔上报数据记录。需要注意,由于SDK并没有使用安卓的实时唤醒机制,采用Handler,因此采用此策略上报,SDK做不到严格的遵守开发者设定的间隔,而会根据应用数据采集的频率和设备休眠策略,会有一定的偏差。
82 |
83 | > UPLOAD_POLICY_DEVELOPMENT
84 | 调试模式。使用此策略,只有开发者手动调用一个接口才会触发上报,否则在任何情况下都不上报。SDK中提供了一个reportData()方法用于手动触发。这种策略主要用于开发者调试时候可手动控制上报时机,便于做数据对比。
85 |
86 |
87 | 统计服务的本地缓存最长会永久保存,只要在数据有效期内上报流程被触发,就会将本地之前没上报成功的所有数据打包ZIP格式上报。如果数据上报成功,则会把已经成功的数据从本地删除。
88 | 默认的数据上报策略是UPLOAD_POLICY_INTERVAL,默认的上报时间间隔是三分钟(非wifi是30分钟) 现在也只有默认策略有效。
89 |
90 |
91 |
92 | 设置上报策略的代码示例如下:
93 |
94 | // 设置策略模式 第一个是策略模式 ,第二是是时间(单位/分)
95 | TcStatInterface.setUploadPolicy(TcStatInterface.UploadPolicy.UPLOAD_POLICY_INTERVA, 3);
96 |
97 |
98 |
99 |
100 | ## API说明
101 | --
102 |
103 | 4.1. API细节
104 |
105 | 请具体看demo 注释
106 |
107 |
108 | ## 集成步骤
109 |
110 | 5.1 依赖项目
111 |
112 |
113 | **Gradle:**
114 |
115 | root:
116 |
117 | repositories {
118 | maven { url "https://jitpack.io" }
119 | jcenter()
120 | }
121 |
122 | Module:
123 |
124 | dependencies {
125 | compile 'com.tamic:StatInterface:2.1'
126 |
127 | }
128 |
129 |
130 | 5.3 加入权限
131 |
132 | 见2.1的说明。
133 |
134 | 5.4 初始化
135 |
136 | Application的onCreate():
137 |
138 | // assets
139 | String fileName = "stat_id.json";
140 |
141 | String url = "http://www.baidu.com";
142 |
143 | // init statSdk
144 | TcStatInterface.initialize(this, appId, "you app chanel", fileName);
145 | // set upload url
146 | TcStatInterface.setUrl(url);
147 |
148 | 见Wiki说明 参见demo
149 |
150 | 5.5 AppAction
151 |
152 | 此统计包含是三个类型
153 |
154 | 1. App启动
155 |
156 |
157 | TcStatInterface.recordAppStart();
158 |
159 | 2. App退出
160 |
161 |
162 | TcStatInterface.recordAppEnd();
163 |
164 | 3. APP唤醒
165 |
166 | 无需开发者上层使用,sdk会自动打点记录
167 |
168 |
169 |
170 |
171 | 5.6 事件统计
172 |
173 | 记录某个动作,并包含事件参数时,
174 |
175 |
176 | findViewById(R.id.id_button).setOnClickListener(new View.OnClickListener() {
177 | @Override
178 | public void onClick(View v) {
179 | TcStatInterface.onEvent("main", "onlick", "send data");
180 | //reportData
181 | TcStatInterface.reportData();
182 |
183 | }
184 |
185 | });
186 |
187 |
188 | findViewById(R.id.id_button2).setOnClickListener(new View.OnClickListener() {
189 | @Override
190 | public void onClick(View v) {
191 |
192 | // test
193 | HashMap map = new HashMap<>();
194 | map.put("id1", "xxx");
195 | map.put("id2", "yyy");
196 |
197 | TcStatInterface.onEvent("openNext", map);
198 |
199 | Intent intent = new Intent(MainActivity.this, SecondActivity.class);
200 | startActivity(intent);
201 |
202 | }
203 |
204 | });
205 |
206 |
207 |
208 |
209 | 5.7 Activity统计
210 |
211 |
212 | 统计activity启动时间,从哪个地方跳过来,业务开发者可以自己写一个base,让其他activity继承Base就行,就可完成自动搜集功能
213 |
214 |
215 | public class BaseActivity extends Activity {
216 |
217 | @override
218 | protected void onResume() {
219 | super.onResume();
220 | //可以直接传this
221 | TcStatInterface.recordPageStart(“ID”);
222 | }
223 |
224 | protected void onPause() {
225 | super.onPause();
226 | TcStatInterface.recordPageEnd();
227 | }
228 | }
229 |
230 |
231 |
232 | 注意
233 | --
234 |
235 | 目前服务端代码需要你自我实现,数据结结构按客户端数据Model实现即可。收到数据落地到数据库,需要查看的时候即可查看,如果后端有可视化界面,那么更好不过。
236 |
237 | 客户端:搜集,存储,上报。
238 | 服务端:接受数据,落地数据库,最后做大数据处理。
239 |
240 | > 作者:
241 | > FrameWork [@Tamic](https://github.com/Jianglei0716) : http://www.jianshu.com/p/cd83e81b78aa
242 |
243 | >crash:[@jianglei0716](https://github.com/Jianglei0716)
244 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | android {
4 | compileSdkVersion 23
5 | buildToolsVersion "23.0.2"
6 |
7 | defaultConfig {
8 | applicationId "com.tamic.statsdkdemo"
9 | minSdkVersion 14
10 | targetSdkVersion 23
11 | versionCode 1
12 | versionName "1.0"
13 | }
14 | buildTypes {
15 | release {
16 | minifyEnabled false
17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
18 | }
19 | }
20 | }
21 |
22 | dependencies {
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | compile 'com.tamic:StatInterface:2.1'
25 | }
26 |
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in E:\Users\AppData\Local\Android\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | ### keep Statsdk
20 | -keep class com.tamic.statInterface.statsdk.db.** { *; }
21 | ### keep Statsdk
22 | -keep class com.tamic.statInterface.statsdk.model.header** { *; }
23 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/app/src/main/assets/stat_id.json:
--------------------------------------------------------------------------------
1 | {
2 | "SecondActivity":"3",
3 | "MainActivity":"2",
4 | "BaseActivity":"1"
5 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/tamic/statsdkdemo/BaseActivity.java:
--------------------------------------------------------------------------------
1 | package com.tamic.statsdkdemo;
2 |
3 | import android.app.Activity;
4 |
5 | import com.tamic.statInterface.statsdk.core.TcStatInterface;
6 |
7 | /**
8 | * Created by Tamic on 2016-03-17.
9 | */
10 | public abstract class BaseActivity extends Activity {
11 |
12 | @Override
13 | protected void onResume() {
14 | super.onResume();
15 |
16 | TcStatInterface.recordPageStart(BaseActivity.this);
17 | }
18 |
19 | @Override
20 | protected void onPause() {
21 | super.onPause();
22 |
23 | TcStatInterface.recordPageEnd();
24 | }
25 |
26 | @Override
27 | protected void onDestroy() {
28 | super.onDestroy();
29 |
30 | // APP退出
31 | TcStatInterface.recordAppEnd();
32 |
33 | }
34 |
35 |
36 |
37 |
38 |
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/app/src/main/java/com/tamic/statsdkdemo/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.tamic.statsdkdemo;
2 |
3 | import android.content.Intent;
4 | import android.os.*;
5 | import android.view.View;
6 |
7 | import com.tamic.statInterface.statsdk.core.TcStatInterface;
8 |
9 | import java.util.HashMap;
10 |
11 |
12 | public class MainActivity extends BaseActivity {
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.activity_main);
18 | findViewById(R.id.id_button).setOnClickListener(new View.OnClickListener() {
19 | @Override
20 | public void onClick(View v) {
21 | TcStatInterface.onEvent("main", "onlick", "send data");
22 | //发送数据
23 | TcStatInterface.reportData();
24 |
25 | }
26 |
27 | });
28 |
29 | findViewById(R.id.id_button2).setOnClickListener(new View.OnClickListener() {
30 | @Override
31 | public void onClick(View v) {
32 |
33 | // test
34 | HashMap map = new HashMap();
35 | map.put("id1", "xxx");
36 | map.put("id2", "yyyy");
37 |
38 | TcStatInterface.onEvent("open next", map);
39 |
40 | Intent intent = new Intent(MainActivity.this, SecondActivity.class);
41 | startActivity(intent);
42 |
43 | }
44 |
45 | });
46 | }
47 |
48 |
49 | }
50 |
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/tamic/statsdkdemo/SecondActivity.java:
--------------------------------------------------------------------------------
1 | package com.tamic.statsdkdemo;
2 |
3 | import android.os.Bundle;
4 | import android.view.View;
5 | import android.widget.Button;
6 | import com.tamic.statInterface.statsdk.core.TcStatInterface;
7 |
8 | /**
9 | * Created by Tamic on 2016-03-16.
10 | */
11 | public class SecondActivity extends BaseActivity implements View.OnClickListener {
12 | Button button ;
13 |
14 | @Override
15 | protected void onCreate(Bundle savedInstanceState) {
16 | super.onCreate(savedInstanceState);
17 | setContentView(R.layout.lay_activity_second);
18 | button =(Button)findViewById(R.id.second_button);
19 | button.setOnClickListener(this);
20 |
21 |
22 | }
23 |
24 | @Override
25 | protected void onResume() {
26 | super.onResume();
27 |
28 | }
29 |
30 | @Override
31 | public void onClick(View v) {
32 | TcStatInterface.onEvent("second Activity", "onclik", "testButton");
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/app/src/main/java/com/tamic/statsdkdemo/StatAppliation.java:
--------------------------------------------------------------------------------
1 | package com.tamic.statsdkdemo;
2 | import android.app.Application;
3 |
4 | import com.tamic.statInterface.statsdk.core.TcStatInterface;
5 |
6 | /**
7 | * Created by LIUYONGKUI726 on 2016-04-13.
8 | */
9 | public class StatAppliation extends Application {
10 |
11 | @Override
12 | public void onCreate() {
13 | super.onCreate();
14 | // you app id
15 | int appId = 21212;
16 | // assets
17 | String fileName = "stat_id.json";
18 | String url = "http://www.baidu.com";
19 | // init statSdk
20 | TcStatInterface.initialize(this, appId, "you app chanel", fileName);
21 | TcStatInterface.setUrl(url);
22 | TcStatInterface.setUploadPolicy(TcStatInterface.UploadPolicy.UPLOAD_POLICY_DEVELOPMENT, TcStatInterface.UPLOAD_TIME_ONE);
23 | }
24 |
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
15 |
16 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/lay_activity_second.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
13 |
14 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tamicer/SkyMonitoring/ff7751c57d98bb826d0ada556bfe353df23a2069/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tamicer/SkyMonitoring/ff7751c57d98bb826d0ada556bfe353df23a2069/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tamicer/SkyMonitoring/ff7751c57d98bb826d0ada556bfe353df23a2069/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tamicer/SkyMonitoring/ff7751c57d98bb826d0ada556bfe353df23a2069/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | StaticticsSdkDemo
3 |
4 | Hello world!
5 | Settings
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/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:1.2.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 |
--------------------------------------------------------------------------------
/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 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/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 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------