Skip to content

Commit 402cc73

Browse files
committed
add(publish): support publish mavenCentral
1 parent 357b243 commit 402cc73

File tree

24 files changed

+380
-326
lines changed

24 files changed

+380
-326
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
* `21/05/13` [add] Support publish mavenCentral.
12
* `21/02/22` [add] Fix ToastUtils rtl bug. Publish v1.30.6.
23
* `20/11/16` [add] Add ImageUtils#save2Album support param of dirName.
34
* `20/11/13` [add] Fix MessengerUtils ANR. Add NetworkUtils#getWifiScanResult, [add|remove]OnWifiChangedConsumer. Publish v1.30.5.

build.gradle

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22
buildscript {
33
ConfigUtils.init(gradle)
44
repositories {
5-
// use for debug plugin local
6-
if (Config.depConfig.plugin_bus.useLocal || Config.depConfig.plugin_api.useLocal) {
7-
maven() { url uri("${project.rootDir.path}/mavenLocal") }
8-
}
5+
mavenLocal()
96
google()
7+
mavenCentral()
108
jcenter()
119
}
1210

@@ -19,18 +17,19 @@ buildscript {
1917

2018
allprojects {
2119
repositories {
22-
maven() { url uri("${project.rootDir.path}/mavenLocal") }
20+
mavenLocal()
2321
maven { url "https://jitpack.io" }
2422
google()
23+
mavenCentral()
2524
jcenter()
2625
}
2726

2827
configurations.all {
2928
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
3029

3130
resolutionStrategy.eachDependency {
32-
if (it.requested.group == 'com.android.support'
33-
&& !it.requested.name.contains('multidex')) {
31+
if (it.requested.group == 'com.android.support' && !it.requested.name.contains(
32+
'multidex')) {
3433
it.useVersion Config.supportVersion
3534
}
3635
}

buildApp.gradle

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply {
22
plugin "com.android.application"
3-
from "${rootDir.path}/buildCommon.gradle"
3+
from "${rootDir.path}/buildCommon.gradle"
4+
from "${rootDir.path}/config/flavor.gradle"
45
if (Config.depConfig.plugin_api.isApply) {
56
plugin Config.depConfig.plugin_api.pluginId
67
}
@@ -32,19 +33,11 @@ android {
3233
}
3334

3435
buildTypes {
35-
debug {
36-
minifyEnabled false
37-
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
38-
applicationIdSuffix ".debug"
39-
resValue "string", "app_name", Config.appName + suffix + ".debug"
40-
}
36+
debug {}
4137

4238
release {
43-
aaptOptions.cruncherEnabled = false
44-
aaptOptions.useNewCruncher = false
4539
minifyEnabled true
4640
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
47-
resValue "string", "app_name", Config.appName + suffix
4841
}
4942
}
5043

@@ -58,8 +51,19 @@ android {
5851
maxProcessCount 8
5952
dexInProcess = true
6053
}
61-
}
6254

55+
productFlavors {
56+
dev {
57+
applicationIdSuffix ".dev"
58+
versionNameSuffix "-dev"
59+
resValue "string", "app_name", Config.appName + suffix + "-dev"
60+
}
61+
62+
production {
63+
resValue "string", "app_name", Config.appName + suffix
64+
}
65+
}
66+
}
6367

6468
dependencies {
6569
// LeakCanary
@@ -80,7 +84,9 @@ dependencies {
8084

8185
def getSuffix() {
8286
if (project.name == "feature_launcher_app") return ""
83-
return "." + project.name.substring("feature_".length(), project.name.length() - "_app".length())
87+
return "." + project.
88+
name.
89+
substring("feature_".length(), project.name.length() - "_app".length())
8490
}
8591

8692
def configSigning() {
@@ -110,12 +116,14 @@ def configApkName() {
110116
if (variant.buildType.name != "debug") {
111117
def artifact = variant.getPackageApplicationProvider().get()
112118
artifact.outputDirectory = new File("${rootDir.path}/apk")
113-
artifact.outputScope.apkDatas.forEach { apkData ->
114-
apkData.outputFileName = "util" + suffix +
115-
(variant.flavorName == "" ? "" : ("_" + variant.flavorName)) +
116-
"_" + variant.versionName.replace(".", "_") +
117-
"_" + variant.buildType.name +
118-
".apk"
119+
variant.outputs.each {
120+
it.outputFileName = "util" + suffix +
121+
(variant.flavorName == "" ? "" : ("_" + variant.flavorName)) +
122+
"_" +
123+
variant.versionName.replace(".", "_") +
124+
"_" +
125+
variant.buildType.name +
126+
".apk"
119127
}
120128
}
121129
}

buildCommon.gradle

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,4 @@ android {
2222
lintOptions {
2323
abortOnError false
2424
}
25-
26-
// viewBinding {
27-
// enabled = true
28-
// }
29-
30-
// flavorDimensions "region"
31-
//
32-
// productFlavors {
33-
// china {
34-
// dimension "region"
35-
// }
36-
//
37-
// oversea {
38-
// dimension "region"
39-
// }
40-
// }
4125
}

buildSrc/src/main/groovy/Config.groovy

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ class Config {
1515
static minSdkVersion = 14
1616
static targetSdkVersion = 29
1717
static versionCode = 1_030_006
18-
static versionName = '1.30.6'// E.g. 1.9.72 => 1,009,072
18+
static versionName = '1.30.7-alpha1'// E.g. 1.9.72 => 1,009,072
1919

2020
// lib version
21-
static gradlePluginVersion = '3.5.2'
21+
static gradlePluginVersion = '4.1.0'
2222
static kotlinVersion = '1.3.72'
2323
static androidxVersion = '1.0.0'
2424

@@ -47,8 +47,6 @@ class Config {
4747
/*Never delete this line*/
4848
plugin_gradle : new DepConfig(pluginPath: "com.android.tools.build:gradle:$gradlePluginVersion"),
4949
plugin_kotlin : new DepConfig(pluginPath: "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"),
50-
plugin_maven : new DepConfig(pluginPath: "com.github.dcendents:android-maven-gradle-plugin:2.1", pluginId: "com.github.dcendents.android-maven"),// 上传到 maven
51-
plugin_bintray : new DepConfig(pluginPath: "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4", pluginId: "com.jfrog.bintray"),// 上传到 bintray
5250
plugin_traute : new DepConfig(pluginPath: "tech.harmonysoft:traute-gradle:1.1.10", pluginId: "tech.harmonysoft.oss.traute"),// 注解转非空判断
5351

5452
// 上传新版本插件更新 pluginPath 中的版本号,并设置 isApply = false

config/flavor.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
android {
2+
flavorDimensions "env"
3+
productFlavors {
4+
dev {
5+
dimension "env"
6+
}
7+
8+
production {
9+
dimension "env"
10+
}
11+
}
12+
13+
variantFilter { variant ->
14+
def flavorNames = variant.flavors*.name
15+
def buildTypeName = variant.buildType.name
16+
17+
// production 包不允许 debug 构建
18+
if (flavorNames.contains("production") && buildTypeName.contains("debug")) {
19+
variant.setIgnore(true)
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)