├── .gitignore
├── README.md
├── app
├── .gitignore
├── build.gradle
├── libs
│ └── Xg_sdk_v3.0_20170301_1733.jar
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── imliujun
│ │ └── gradle
│ │ └── ExampleInstrumentedTest.java
│ ├── app1
│ ├── java
│ │ └── com
│ │ │ └── imliujun
│ │ │ └── app1
│ │ │ └── wxapi
│ │ │ ├── WXEntryActivity.java
│ │ │ └── WXPayEntryActivity.java
│ └── res
│ │ └── mipmap-hdpi
│ │ └── ic_launcher.png
│ ├── app2
│ ├── assets
│ │ └── ShareSDK.xml
│ ├── java
│ │ └── com
│ │ │ └── imliujun
│ │ │ └── app2
│ │ │ └── wxapi
│ │ │ ├── WXEntryActivity.java
│ │ │ └── WXPayEntryActivity.java
│ └── res
│ │ └── mipmap-hdpi
│ │ └── ic_launcher.png
│ ├── main
│ ├── AndroidManifest.xml
│ ├── assets
│ │ └── ShareSDK.xml
│ ├── java
│ │ └── com
│ │ │ └── imliujun
│ │ │ └── gradle
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ └── values
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── imliujun
│ └── gradle
│ └── ExampleUnitTest.java
├── build.gradle
├── config.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── jiagu.gradle
├── jiagu
└── Channel.txt
├── pgy.gradle
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea
5 | .DS_Store
6 | /build
7 | /captures
8 | .externalNativeBuild
9 | /jiagu/360jiagu.zip
10 | /jiagu/apk
11 | /jiagu/360jiagubao
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # [使用 Gradle 实现一套代码开发多个应用](http://www.imliujun.com/gradle3.html)
2 | # [提升效率——自动加固并上传到蒲公英](http://www.imliujun.com/automation2.html)
3 |
4 |
欢迎关注微信公众号:**大脑好饿**,更多干货等你来尝
5 |
6 | 
7 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 |
3 | apply from: '../jiagu.gradle'
4 | apply from: '../pgy.gradle'
5 |
6 | android {
7 | compileSdkVersion rootProject.ext.android["compileSdkVersion"]
8 |
9 | defaultConfig {
10 | minSdkVersion rootProject.ext.android["minSdkVersion"]
11 | targetSdkVersion rootProject.ext.android["targetSdkVersion"]
12 | versionCode gitVersionCode()
13 | }
14 |
15 | // 配置你自己的签名文件信息,然后放开注释
16 | // signingConfigs {
17 | // app1 {
18 | // storeFile file("app1.jks")
19 | // storePassword "111111"
20 | // keyAlias "app1"
21 | // keyPassword "111111"
22 | // }
23 | //
24 | // app2 {
25 | // storeFile file("app2.jks")
26 | // storePassword "111111"
27 | // keyAlias "app2"
28 | // keyPassword "111111"
29 | // }
30 | // }
31 |
32 | buildTypes {
33 | release {
34 | // 不显示Log
35 | buildConfigField "boolean", "LOG_DEBUG", "false"
36 | }
37 |
38 | debug {
39 | // 显示Log
40 | buildConfigField "boolean", "LOG_DEBUG", "true"
41 | versionNameSuffix "-debug"
42 | // 配置你自己的签名文件信息,然后放开注释
43 | // signingConfig null
44 | manifestPlaceholders.UMENG_CHANNEL_VALUE = "test"
45 | }
46 | }
47 |
48 | //创建两个维度的 flavor
49 | flavorDimensions "APP", "SERVER"
50 |
51 | productFlavors {
52 |
53 | app1 {
54 | dimension "APP"
55 | applicationId 'com.imliujun.app1'
56 |
57 | versionName rootProject.ext.APP1_VERSION_NAME
58 |
59 | //应用名
60 | resValue "string", "app_name", "APP1"
61 |
62 | buildConfigField("String", "versionNumber", "\"${rootProject.ext.APP1_VERSION_NAME}\"")
63 |
64 | //第三方SDK的一些配置
65 | buildConfigField "int", "IM_APPID", "11111111" //app1的腾讯IM APPID
66 | buildConfigField "String", "IM_ACCOUNTTYPE", "\"app1的腾讯IM accountype\""
67 | manifestPlaceholders = [UMENG_APP_KEY : "app1的友盟 APP KEY",
68 | UMENG_CHANNEL_VALUE: "app1默认的渠道名",
69 | XG_ACCESS_ID : "app1信鸽推送ACCESS_ID",
70 | XG_ACCESS_KEY : "app1信鸽推送ACCESS_KEY",
71 | QQ_APP_ID : "app1的QQ_APP_ID",
72 | AMAP_KEY : "app1的高德地图key",
73 | APPLICATIONID : applicationId]
74 | //签名文件 配置你自己的签名文件信息,然后放开注释
75 | // signingConfig signingConfigs.app1
76 | }
77 |
78 | app2 {
79 | dimension "APP"
80 | applicationId 'com.imliujun.app2'
81 |
82 | versionName rootProject.ext.APP2_VERSION_NAME
83 |
84 | //应用名
85 | resValue "string", "app_name", "APP2"
86 |
87 | buildConfigField "String", "versionNumber", "\"${rootProject.ext.APP2_VERSION_NAME}\""
88 |
89 | //第三方SDK的一些配置
90 | buildConfigField "int", "IM_APPID", "11111111" //app2的腾讯IM APPID
91 | buildConfigField "String", "IM_ACCOUNTTYPE", "\"app2的腾讯IM accountype\""
92 | manifestPlaceholders = [UMENG_APP_KEY : "app2的友盟 APP KEY",
93 | UMENG_CHANNEL_VALUE: "app2默认的渠道名",
94 | XG_ACCESS_ID : "app2信鸽推送ACCESS_ID",
95 | XG_ACCESS_KEY : "app2信鸽推送ACCESS_KEY",
96 | QQ_APP_ID : "app2的QQ_APP_ID",
97 | AMAP_KEY : "app2的高德地图key",
98 | APPLICATIONID : applicationId]
99 | //签名文件 配置你自己的签名文件信息,然后放开注释
100 | // signingConfig signingConfigs.app2
101 | }
102 |
103 | offline {
104 | dimension "SERVER"
105 | }
106 |
107 | online {
108 | dimension "SERVER"
109 | }
110 |
111 | admin {
112 | dimension "SERVER"
113 |
114 | manifestPlaceholders.UMENG_CHANNEL_VALUE = "admin"
115 | }
116 | }
117 | }
118 |
119 | android.applicationVariants.all { variant ->
120 | switch (variant.flavorName) {
121 | case "app1Admin":
122 | variant.buildConfigField "String", "DOMAIN_NAME",
123 | "\"https://admin.app1domain.com/\""
124 | if ("debug" == variant.buildType.getName()) {
125 | variant.outputs.each { output ->
126 | output.versionNameOverride = getTestVersionName("管理员")
127 | }
128 | // variant.mergedFlavor.setVersionName(getTestVersionName() + "-管理员")
129 | } else {
130 | variant.outputs.each { output ->
131 | output.versionNameOverride = rootProject.ext.APP1_VERSION_NAME + "-管理员"
132 | }
133 | // variant.mergedFlavor.setVersionName(rootProject.ext.APP1_VERSION_NAME + "-管理员")
134 | }
135 | break
136 | case "app1Offline":
137 | variant.buildConfigField "String", "DOMAIN_NAME",
138 | "\"https://offline.app1domain.com/\""
139 | variant.outputs.each { output ->
140 | output.versionNameOverride = getTestVersionName("offline")
141 | }
142 | // variant.mergedFlavor.setVersionName(getTestVersionName())
143 | break
144 | case "app1Online":
145 | variant.buildConfigField "String", "DOMAIN_NAME",
146 | "\"https://online.app1domain.com/\""
147 | if ("debug" == variant.buildType.getName()) {
148 | variant.outputs.each { output ->
149 | output.versionNameOverride = getTestVersionName("online")
150 | }
151 | // variant.mergedFlavor.setVersionName(getTestVersionName())
152 | }
153 | break
154 | case "app2Admin":
155 | variant.buildConfigField "String", "DOMAIN_NAME",
156 | "\"https://admin.app2domain.com/\""
157 | if ("debug" == variant.buildType.getName()) {
158 | variant.outputs.each { output ->
159 | output.versionNameOverride = getApp2TestVersionName("管理员")
160 | }
161 | // variant.mergedFlavor.setVersionName(getApp2TestVersionName() + "-管理员")
162 | } else {
163 | variant.outputs.each { output ->
164 | output.versionNameOverride = rootProject.ext.APP2_VERSION_NAME + "-管理员"
165 | }
166 | // variant.mergedFlavor.setVersionName(rootProject.ext.APP2_VERSION_NAME + "-管理员")
167 | }
168 | break
169 | case "app2Offline":
170 | variant.buildConfigField "String", "DOMAIN_NAME",
171 | "\"https://offline.app2domain.com/\""
172 | variant.outputs.each { output ->
173 | output.versionNameOverride = getApp2TestVersionName("offline")
174 | }
175 | // variant.mergedFlavor.setVersionName(getApp2TestVersionName())
176 | break
177 | case "app2Online":
178 | variant.buildConfigField "String", "DOMAIN_NAME",
179 | "\"https://online.app2domain.com/\""
180 | if ("debug" == variant.buildType.getName()) {
181 | variant.outputs.each { output ->
182 | output.versionNameOverride = getApp2TestVersionName("online")
183 | }
184 | // variant.mergedFlavor.setVersionName(getApp2TestVersionName())
185 | }
186 | break
187 | }
188 | variant.outputs.all {
189 | outputFileName = getApkName(variant.versionName)
190 | }
191 | }
192 |
193 |
194 | dependencies {
195 | implementation fileTree(dir: 'libs', include: ['*.jar'])
196 | implementation 'androidx.appcompat:appcompat:1.1.0-alpha03'
197 | implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
198 | }
199 |
--------------------------------------------------------------------------------
/app/libs/Xg_sdk_v3.0_20170301_1733.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imliujun/GradleTest/91ca5b0ae686bbcf4f52f22936c6ea6a83365659/app/libs/Xg_sdk_v3.0_20170301_1733.jar
--------------------------------------------------------------------------------
/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 /Users/liujun/AndroidSDK/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 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/imliujun/gradle/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.imliujun.gradle;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.imliujun.gradle", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/app1/java/com/imliujun/app1/wxapi/WXEntryActivity.java:
--------------------------------------------------------------------------------
1 |
2 | package com.imliujun.app1.wxapi;
3 |
4 | import android.app.Activity;
5 |
6 | /** 微信客户端回调activity示例 */
7 | public class WXEntryActivity extends Activity {
8 |
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/app1/java/com/imliujun/app1/wxapi/WXPayEntryActivity.java:
--------------------------------------------------------------------------------
1 |
2 | package com.imliujun.app1.wxapi;
3 |
4 | import android.app.Activity;
5 | import android.os.Bundle;
6 |
7 | public class WXPayEntryActivity extends Activity {
8 |
9 | @Override
10 | public void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/app/src/app1/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imliujun/GradleTest/91ca5b0ae686bbcf4f52f22936c6ea6a83365659/app/src/app1/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/app2/assets/ShareSDK.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
62 |
64 |
65 |
68 |
69 |
71 |
72 |
74 |
75 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
89 |
90 |
100 |
102 |
103 |
105 |
106 |
107 |
108 |
111 |
112 |
113 |
114 |
116 |
117 |
120 |
121 |
123 |
124 |
125 |
126 |
129 |
130 |
142 |
144 |
145 |
147 |
148 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
166 |
167 |
170 |
171 |
172 |
--------------------------------------------------------------------------------
/app/src/app2/java/com/imliujun/app2/wxapi/WXEntryActivity.java:
--------------------------------------------------------------------------------
1 |
2 | package com.imliujun.app2.wxapi;
3 |
4 | import android.app.Activity;
5 |
6 | /** 微信客户端回调activity示例 */
7 | public class WXEntryActivity extends Activity {
8 |
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/app/src/app2/java/com/imliujun/app2/wxapi/WXPayEntryActivity.java:
--------------------------------------------------------------------------------
1 |
2 | package com.imliujun.app2.wxapi;
3 |
4 | import android.app.Activity;
5 |
6 | public class WXPayEntryActivity extends Activity {
7 |
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/app/src/app2/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imliujun/GradleTest/91ca5b0ae686bbcf4f52f22936c6ea6a83365659/app/src/app2/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
25 |
26 |
33 |
34 |
37 |
40 |
43 |
46 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
--------------------------------------------------------------------------------
/app/src/main/assets/ShareSDK.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
62 |
64 |
65 |
68 |
69 |
71 |
72 |
74 |
75 |
76 |
77 |
78 |
79 |
81 |
82 |
85 |
86 |
89 |
90 |
100 |
102 |
103 |
105 |
106 |
107 |
108 |
111 |
112 |
113 |
114 |
116 |
117 |
120 |
121 |
123 |
124 |
125 |
126 |
129 |
130 |
142 |
144 |
145 |
147 |
148 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
166 |
167 |
170 |
171 |
172 |
--------------------------------------------------------------------------------
/app/src/main/java/com/imliujun/gradle/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.imliujun.gradle;
2 |
3 | import android.content.pm.ApplicationInfo;
4 | import android.content.pm.PackageManager;
5 | import android.os.Bundle;
6 | import android.util.Log;
7 |
8 | import androidx.annotation.NonNull;
9 | import androidx.appcompat.app.AppCompatActivity;
10 |
11 | public class MainActivity extends AppCompatActivity {
12 |
13 | @Override
14 | protected void onCreate(Bundle savedInstanceState) {
15 | super.onCreate(savedInstanceState);
16 | setContentView(R.layout.activity_main);
17 | //可以去 BuildConfig 中查看Gradle中定义的常量
18 | Log.i("tag", BuildConfig.DOMAIN_NAME);
19 | //获取渠道名
20 | String channel = getMetaDataInApp("UMENG_CHANNEL");
21 | Log.i("channel", channel);
22 | }
23 |
24 | public String getMetaDataInApp(@NonNull final String key) {
25 | String value = "";
26 | PackageManager pm = getPackageManager();
27 | String packageName = getPackageName();
28 | try {
29 | ApplicationInfo ai = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
30 | value = String.valueOf(ai.metaData.get(key));
31 | } catch (PackageManager.NameNotFoundException e) {
32 | e.printStackTrace();
33 | }
34 | return value;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imliujun/GradleTest/91ca5b0ae686bbcf4f52f22936c6ea6a83365659/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/app/src/test/java/com/imliujun/gradle/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.imliujun.gradle;
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 | }
18 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 | apply from: 'config.gradle'
3 |
4 | buildscript {
5 | repositories {
6 | jcenter()
7 | google()
8 | }
9 | dependencies {
10 | classpath 'com.android.tools.build:gradle:3.3.2'
11 |
12 | // NOTE: Do not place your application dependencies here; they belong
13 | // in the individual module build.gradle files
14 | }
15 | }
16 |
17 | allprojects {
18 | repositories {
19 | jcenter()
20 | google()
21 | }
22 | }
23 |
24 | task clean(type: Delete) {
25 | delete rootProject.buildDir
26 | }
27 |
28 |
29 | def getTestVersionName(String suffix) {
30 | if (suffix == null || suffix.isEmpty()) {
31 | return String.format("%s.%s", rootProject.ext.APP1_VERSION_NAME, rootProject.ext.APP1_TEST_NUM)
32 | } else {
33 | return String.format("%s.%s.%s", rootProject.ext.APP1_VERSION_NAME, rootProject.ext.APP1_TEST_NUM, suffix)
34 | }
35 | }
36 |
37 | def getApp2TestVersionName(String suffix) {
38 | if (suffix == null || suffix.isEmpty()) {
39 | return String.format("%s.%s", rootProject.ext.APP2_VERSION_NAME, rootProject.ext.APP2_TEST_NUM)
40 | } else {
41 | return String.format("%s.%s.%s", rootProject.ext.APP2_VERSION_NAME, rootProject.ext.APP2_TEST_NUM, suffix)
42 | }
43 | }
44 |
45 | static int gitVersionCode() {
46 | def count = "git rev-list HEAD --count".execute().text.trim()
47 | return count.isInteger() ? count.toInteger() : 0
48 | }
49 |
50 | def getApkName(String versionName) {
51 | return String.format("我是一个包-v%s.apk", versionName)
52 | }
--------------------------------------------------------------------------------
/config.gradle:
--------------------------------------------------------------------------------
1 | //项目配置项,后期有sdk插件的话也在此统一配置版本
2 | ext {
3 | //签名文件配置
4 | signing = [keyAlias : 'xxxxx',
5 | keyPassword : 'xxxxx',
6 | storeFile : '../sign.keystore',
7 | storePassword: 'xxxxxx']
8 |
9 | //蒲公英配置
10 | pgy = [apiKey : "xxxx",
11 | uploadUrl: "https://www.pgyer.com/apiv2/app/upload"]
12 |
13 | //360加固配置
14 | jiagu = [name : 'xxxxx',
15 | password : 'xxxxx',
16 | zipPath : "../jiagu/360jiagu.zip",
17 | unzipPath : "../jiagu/360jiagubao/",
18 | jarPath : '../jiagu/360jiagubao/jiagu/jiagu.jar',
19 | channelConfigPath: '../jiagu/Channel.txt',
20 | jiagubao_mac : "http://down.360safe.com/360Jiagu/360jiagubao_mac.zip",
21 | jiagubao_windows : "http://down.360safe.com/360Jiagu/360jiagubao_windows_64.zip",
22 | ]
23 |
24 | android = [compileSdkVersion: 28,
25 | minSdkVersion : 19,
26 | targetSdkVersion : 28]
27 |
28 | //版本号管理
29 | APP1_VERSION_NAME = "2.0.2"
30 | APP1_TEST_NUM = "0001"
31 | APP2_VERSION_NAME = "1.0.5"
32 | APP2_TEST_NUM = "0005"
33 | }
34 |
--------------------------------------------------------------------------------
/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 | android.enableJetifier=true
13 | android.useAndroidX=true
14 | org.gradle.jvmargs=-Xmx1536m
15 |
16 | # When configured, Gradle will run in incubating parallel mode.
17 | # This option should only be used with decoupled projects. More details, visit
18 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
19 | # org.gradle.parallel=true
20 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/imliujun/GradleTest/91ca5b0ae686bbcf4f52f22936c6ea6a83365659/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Tue Jul 11 09:51:46 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-4.10.1-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 |
--------------------------------------------------------------------------------
/jiagu.gradle:
--------------------------------------------------------------------------------
1 | import org.apache.tools.ant.taskdefs.condition.Os
2 |
3 | def downloadUrl = Os.isFamily(Os.FAMILY_WINDOWS) ? rootProject.ext.jiagu["jiagubao_windows"] : rootProject.ext.jiagu["jiagubao_mac"]
4 |
5 | def zipPath = rootProject.ext.jiagu["zipPath"]
6 | def unzipPath = rootProject.ext.jiagu["unzipPath"]
7 |
8 |
9 | //加固后所有apk的保存路径
10 | def APP1_OUTPUT_PATH = "jiagu/apk/app1/"
11 | def APP2_OUTPUT_PATH = "jiagu/apk/app2/"
12 |
13 | def APP1_APK_PATH = "${projectDir.absolutePath}/build/outputs/apk/app1Online/release/${getApkName(rootProject.ext.APP1_VERSION_NAME)}"
14 | def APP2_APK_PATH = "${projectDir.absolutePath}/build/outputs/apk/app2Online/release/${getApkName(rootProject.ext.APP2_VERSION_NAME)}"
15 |
16 |
17 | def APP1_ADMIN_OUTPUT_PATH = "jiagu/apk/app1Admin/"
18 | def APP2_ADMIN_OUTPUT_PATH = "jiagu/apk/app2Admin/"
19 |
20 | def APP1_ADMIN_APK_PATH = "${projectDir.absolutePath}/build/outputs/apk/app1Admin/release/${getApkName(getTestVersionName("管理员"))}"
21 | def APP2_ADMIN_APK_PATH = "${projectDir.absolutePath}/build/outputs/apk/app2Admin/release/${getApkName(getApp2TestVersionName("管理员"))}"
22 |
23 |
24 |
25 | task download360jiagu() {
26 | doFirst {
27 | //如果 Zip 文件不存在就进行下载
28 | File zipFile = file(zipPath)
29 | if (!zipFile.exists()) {
30 | if (!zipFile.parentFile.exists()) {
31 | zipFile.parentFile.mkdirs()
32 | }
33 | exec {
34 | executable = 'curl'
35 | args = ['-o', zipPath, downloadUrl]
36 | }
37 | }
38 | }
39 | doLast {
40 | //解压 Zip 文件
41 | ant.unzip(src: zipPath, dest: unzipPath, encoding: "GBK")
42 | //将解压后的文件开启读写权限,防止执行 Jar 文件没有权限执行
43 | exec {
44 | executable = 'chmod'
45 | args = ['-R', '777', unzipPath]
46 | }
47 | }
48 | }
49 |
50 | /**
51 | * 加固
52 | * @param config 配置加固可选项
53 | * @param apkPath 要加固的文件路径
54 | * @param outputPath 输出路径
55 | * @param automulpkg 是否自动生成多渠道包
56 | */
57 | def jiaGu(String config, String apkPath, String outputPath, boolean automulpkg) {
58 | //首次使用必须先登录
59 | exec {
60 | executable = 'java'
61 | args = ['-jar', rootProject.ext.jiagu["jarPath"], '-login', rootProject.ext.jiagu["name"], rootProject.ext.jiagu["password"]]
62 | }
63 | //升级到最新版本
64 | exec {
65 | executable = 'java'
66 | args = ['-jar', rootProject.ext.jiagu["jarPath"], '-update']
67 | }
68 | //显示当前版本号
69 | exec {
70 | executable = 'java'
71 | args = ['-jar', rootProject.ext.jiagu["jarPath"], '-version']
72 | }
73 |
74 | //导入签名信息
75 | exec {
76 | executable = 'java'
77 | args = ['-jar', rootProject.ext.jiagu["jarPath"], '-importsign',
78 | rootProject.ext.signing["storeFile"],
79 | rootProject.ext.signing["storePassword"],
80 | rootProject.ext.signing["keyAlias"],
81 | rootProject.ext.signing["keyPassword"]]
82 | }
83 |
84 | //配置加固可选项
85 | exec {
86 | executable = 'java'
87 | args = ['-jar', rootProject.ext.jiagu["jarPath"], '-config', config]
88 | }
89 |
90 | //加固命令
91 | def jiaGuArgs
92 | if (automulpkg) {
93 | jiaGuArgs = ['-jar', rootProject.ext.jiagu["jarPath"], '-jiagu',
94 | apkPath,
95 | outputPath,
96 | '-autosign',
97 | '-automulpkg',
98 | '-pkgparam',
99 | rootProject.ext.jiagu["channelConfigPath"]
100 | ]
101 | } else {
102 | jiaGuArgs = ['-jar', rootProject.ext.jiagu["jarPath"], '-jiagu',
103 | apkPath,
104 | outputPath,
105 | '-autosign'
106 | ]
107 | }
108 | exec {
109 | executable = 'java'
110 | args = jiaGuArgs
111 | }
112 | println "加固的文件路径:${apkPath}"
113 | println "加固后的文件路径:${outputPath}"
114 | }
115 |
116 |
117 | /**
118 | * App1
119 | * 根据多渠道文件进行加固
120 | * 执行命令:./gradlew releaseApp1
121 | */
122 | task releaseApp1(dependsOn: 'assembleApp1OnlineRelease') {
123 | doFirst {
124 | //判断加固程序是否存在,不存在则进行下载
125 | File jarFile = file(rootProject.ext.jiagu["jarPath"])
126 | if (!jarFile.exists()) {
127 | download360jiagu.execute()
128 | }
129 | }
130 | group = "publish"
131 | doLast {
132 | File apkOutputFile = new File(APP1_OUTPUT_PATH, getCurTime())
133 | checkOutputDir(apkOutputFile)
134 | File apkFile = file(APP1_APK_PATH)
135 | if (!apkFile.exists()) {
136 | println("apk file is not exists:" + apkFile.absolutePath)
137 | return
138 | }
139 | jiaGu("-", apkFile.absolutePath, apkOutputFile.absolutePath, true)
140 | }
141 | }
142 |
143 | /**
144 | * App2
145 | * 根据多渠道文件进行加固
146 | * 执行命令:./gradlew releaseApp2
147 | */
148 | task releaseApp2(dependsOn: 'assembleApp2OnlineRelease') {
149 | doFirst {
150 | //判断加固程序是否存在,不存在则进行下载
151 | File jarFile = file(rootProject.ext.jiagu["jarPath"])
152 | if (!jarFile.exists()) {
153 | download360jiagu.execute()
154 | }
155 | }
156 | group = "publish"
157 | doLast {
158 | File apkOutputFile = new File(APP2_OUTPUT_PATH, getCurTime())
159 | checkOutputDir(apkOutputFile)
160 | File apkFile = file(APP2_APK_PATH)
161 | if (!apkFile.exists()) {
162 | println("apk file is not exists:" + apkFile.absolutePath)
163 | return
164 | }
165 | jiaGu("-", apkFile.absolutePath, apkOutputFile.absolutePath, true)
166 | }
167 | }
168 |
169 | /**
170 | * 加固超管服包
171 | * 执行命令:./gradlew jiaGuApp1Admin
172 | */
173 | task jiaGuApp1Admin(dependsOn: 'assembleApp1AdminRelease') {
174 | doFirst {
175 | File jarFile = file(rootProject.ext.jiagu["jarPath"])
176 | if (!jarFile.exists()) {
177 | download360jiagu.execute()
178 | }
179 | }
180 | group = "publish"
181 | doLast {
182 | File apkOutputFile = new File(APP1_ADMIN_OUTPUT_PATH)
183 | checkOutputDir(apkOutputFile)
184 | File apkFile = file(APP1_ADMIN_APK_PATH)
185 | if (!apkFile.exists()) {
186 | println("apk file is not exists:" + apkFile.absolutePath)
187 | return
188 | }
189 | jiaGu("-", apkFile.absolutePath, apkOutputFile.absolutePath, false)
190 | }
191 | }
192 |
193 | /**
194 | * 加固超管服包
195 | * 执行命令:./gradlew jiaGuApp2Admin
196 | */
197 | task jiaGuApp2Admin(dependsOn: 'assembleApp2AdminRelease') {
198 | doFirst {
199 | File jarFile = file(rootProject.ext.jiagu["jarPath"])
200 | if (!jarFile.exists()) {
201 | download360jiagu.execute()
202 | }
203 | }
204 | group = "publish"
205 | doLast {
206 | File apkOutputFile = new File(APP2_ADMIN_OUTPUT_PATH)
207 | checkOutputDir(apkOutputFile)
208 | File apkFile = file(APP2_ADMIN_APK_PATH)
209 | if (!apkFile.exists()) {
210 | println("apk file is not exists:" + apkFile.absolutePath)
211 | return
212 | }
213 | jiaGu("-", apkFile.absolutePath, apkOutputFile.absolutePath, false)
214 | }
215 | }
216 |
217 |
218 | private static void checkOutputDir(File apkOutputFile) {
219 | if (apkOutputFile.exists()) {
220 | File[] files = apkOutputFile.listFiles()
221 | if (files != null) {
222 | for (File file : files) {
223 | file.delete()
224 | }
225 | }
226 | } else {
227 | apkOutputFile.mkdirs()
228 | }
229 | }
230 |
231 |
232 | static def getCurTime() {
233 | return new Date().format("yyyy-MM-dd HH:mm:ss")
234 | }
235 |
--------------------------------------------------------------------------------
/jiagu/Channel.txt:
--------------------------------------------------------------------------------
1 | UMENG_CHANNEL 360应用平台 1
2 | UMENG_CHANNEL 谷歌市场 2
3 | UMENG_CHANNEL 91手机商城 3
4 | UMENG_CHANNEL 豌豆荚 4
5 | UMENG_CHANNEL 安卓市场 5
6 |
--------------------------------------------------------------------------------
/pgy.gradle:
--------------------------------------------------------------------------------
1 | def app1OfflineFile = "${projectDir.absolutePath}/build/outputs/apk/app1Offline/release/${getApkName(getTestVersionName("offline"))}"
2 | def app1OnlineFile = "${projectDir.absolutePath}/build/outputs/apk/app1Online/release/${getApkName(rootProject.ext.APP1_VERSION_NAME)}"
3 | def app2OfflineFile = "${projectDir.absolutePath}/build/outputs/apk/app2Offline/release/${getApkName(getApp2TestVersionName("offline"))}"
4 | def app2OnlineFile = "${projectDir.absolutePath}/build/outputs/apk/app2Online/release/${getApkName(rootProject.ext.APP2_VERSION_NAME)}"
5 | def app1AdminFileDir = "${projectDir.parent}/jiagu/apk/app1Admin/"
6 | def app2AdminFileDir = "${projectDir.parent}/jiagu/apk/app2Admin/"
7 |
8 |
9 | private def uploadPGY(String filePath) {
10 | println "uploadPGY filePath:" + filePath
11 | def stdout = new ByteArrayOutputStream()
12 | exec {
13 | executable = 'curl'
14 | args = ['-F', "file=@${filePath}", '-F', "_api_key=${rootProject.ext.pgy["apiKey"]}", rootProject.ext.pgy["uploadUrl"]]
15 | standardOutput = stdout
16 | }
17 | String output = stdout.toString()
18 | def parsedJson = new groovy.json.JsonSlurper().parseText(output)
19 | println parsedJson.data.buildQRCodeURL
20 | println "版本号:" + parsedJson.data.buildVersion
21 | }
22 |
23 | /**
24 | * 执行 “uploadApp1Offline” 命令自动打包测试环境包,并上传到蒲公英
25 | */
26 | task uploadApp1Offline(dependsOn: 'assembleApp1OfflineRelease') {
27 | group = "publish"
28 |
29 | doLast {
30 | uploadPGY(app1OfflineFile)
31 | }
32 | }
33 |
34 | /**
35 | * 执行 “uploadApp1Online” 命令自动打包生成线上内测环境包,并上传到蒲公英
36 | */
37 | task uploadApp1Online(dependsOn: 'assembleApp1OnlineRelease') {
38 | group = "publish"
39 |
40 | doLast {
41 | uploadPGY(app1OnlineFile)
42 | }
43 | }
44 |
45 | /**
46 | * 执行 “uploadApp1Admin” 命令自动打超管服包,并上传到蒲公英
47 | */
48 | task uploadApp1Admin(dependsOn: 'jiaGuApp1Admin') {
49 | group = "publish"
50 |
51 | doLast {
52 | File dir = new File(app1AdminFileDir)
53 | if (!dir.exists()) {
54 | println "Alpha dir not exists:" + dir.path
55 | return
56 | }
57 | File[] files = dir.listFiles(new FileFilter() {
58 | @Override
59 | boolean accept(File file) {
60 | return file.isFile() && file.name.endsWith(".apk")
61 | }
62 | })
63 | if (files == null || files.size() == 0) {
64 | println "files == null || files.size() == 0"
65 | return
66 | }
67 | File apkFile = files[0]
68 |
69 | uploadPGY(apkFile.path)
70 | }
71 | }
72 |
73 | /**
74 | * 执行 “uploadApp2Offline” 命令自动打包测试环境包,并上传到蒲公英
75 | */
76 | task uploadApp2Offline(dependsOn: 'assembleApp2OfflineRelease') {
77 | group = "publish"
78 |
79 | doLast {
80 | uploadPGY(app2OfflineFile)
81 | }
82 | }
83 |
84 | /**
85 | * 执行 “uploadApp2Online” 命令自动打包生成线上内测环境包,并上传到蒲公英
86 | */
87 | task uploadApp2Online(dependsOn: 'assembleApp2OnlineRelease') {
88 | group = "publish"
89 |
90 | doLast {
91 | uploadPGY(app2OnlineFile)
92 | }
93 | }
94 |
95 | /**
96 | * 执行 “uploadApp2Admin” 命令自动打超管服包,并上传到蒲公英
97 | */
98 | task uploadApp2Admin(dependsOn: 'jiaGuApp2Admin') {
99 | group = "publish"
100 |
101 | doLast {
102 | File dir = new File(app2AdminFileDir)
103 | if (!dir.exists()) {
104 | println "Alpha dir not exists:" + dir.path
105 | return
106 | }
107 | File[] files = dir.listFiles(new FileFilter() {
108 | @Override
109 | boolean accept(File file) {
110 | return file.isFile() && file.name.endsWith(".apk")
111 | }
112 | })
113 | if (files == null || files.size() == 0) {
114 | println "files == null || files.size() == 0"
115 | return
116 | }
117 | File apkFile = files[0]
118 |
119 | uploadPGY(apkFile.path)
120 | }
121 | }
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------