Skip to content

Commit

Permalink
style:(build) 修改构建脚本方便修改仓库地址及发布版本
Browse files Browse the repository at this point in the history
  • Loading branch information
RealOnlyone committed Dec 31, 2021
1 parent 04fbefd commit c10b568
Show file tree
Hide file tree
Showing 6 changed files with 104 additions and 17 deletions.
39 changes: 33 additions & 6 deletions Android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,22 @@ buildscript {
maven {
url "https://oss.sonatype.org/content/groups/public"
}
maven {
//本地插件地址:需替换成你自己的本地地址
url uri('/Users/name/project/dokit_repo')

println("[dokit build] add buildscript private repositories")
println("[dokit build] usePrivateEnv=" + usePrivateEnv() +",privateRepository="+ privateRepository())
println("[dokit build] useLocalRepository="+useLocalRepository()+",localRepository="+localRepository() )

if (usePrivateEnv()){
maven {
url privateRepository()
}
}
if (useLocalRepository()){
maven {
url uri(localRepository())
}
}

}
dependencies {
classpath "com.android.tools.build:gradle:$gradlePluginVersion"
Expand All @@ -43,17 +55,32 @@ buildscript {

}

apply from: "./config.gradle"

allprojects {
def isRootProject = "Dokit-Android".equals(project.name)
repositories {
google()
mavenCentral()
jcenter()
maven {
url "https://oss.sonatype.org/content/groups/public"
}
maven {
//本地插件地址:需替换成你自己的本地地址
url uri('/Users/name/project/dokit_repo')

println("[dokit build] add allprojects repositories config project=" + project.name)
println("[dokit build] usePrivateEnv=" + usePrivateEnv() + ",privateRepository=" + privateRepository())
println("[dokit build] useLocalRepository=" + useLocalRepository() + ",localRepository=" + localRepository())

if (usePrivateEnv()) {
maven {
url privateRepository()
}
}

if (useLocalRepository()){
maven {
url uri(localRepository())
}
}
}
}
Expand Down
33 changes: 32 additions & 1 deletion Android/config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ ext {
//0:依赖dokit本地module运行
//1:依赖dokit远程aar运行
run_type : 0,
//0:外部公共环境
//1:内部私有环境,使用私有仓库构建,仓库地址在 local.properties 中添加 PRIVATE_REPOSITORY_URL
run_env : 0,
//是否使用本地仓库,需要使用绝对路径,仓库地址在 local.properties 中添加 LOCAL_REPOSITORY_URL
use_local : false,
group_id : 'io.github.didi.dokit',
version : '3.6.0'
]
Expand All @@ -22,7 +27,7 @@ ext {
glide_version : "4.9.0",
kotlin_version_v13 : "1.3.72",
kotlin_version_v14 : "1.4.32",
// kotlin_version_v15 : "1.5.31",
kotlin_version_v15 : "1.5.31",
kotlinx_coroutines_version_v13: "1.3.7",
kotlinx_coroutines_version_v14: "1.4.3",
booster_version : "4.0.0",
Expand Down Expand Up @@ -164,4 +169,30 @@ ext {
String[] vs = version.split("\\.")
return vs.length == 3
}

usePrivateEnv = {
def runEnv = publish_config["run_env"]
return runEnv == 1
}

useLocalRepository = {
def useLocal = publish_config["use_local"]
return useLocal
}

privateRepository = {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def url = properties.getProperty('PRIVATE_REPOSITORY_URL', "")
return url
}

localRepository = {
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
def url = properties.getProperty('LOCAL_REPOSITORY_URL', "")
return url
}


}
2 changes: 1 addition & 1 deletion Android/dokit-rpc-mc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ dependencies {
compileOnly rootProject.ext.dependencies["hummer"]

//此处需要使用api的形式 向上暴露内部api
// implementation project(':dokit-rpc')
implementation project(':dokit-rpc')
implementation project(':dokit-mc')

compileOnly project(":dokit-okhttp-api")
Expand Down
19 changes: 16 additions & 3 deletions Android/upload_didi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,24 @@ BLUE_COLOR="\033[1;34m" #蓝
PINK="\033[1;35m" #粉红
RES="\033[0m"

./gradlew checkUploadConfig4Didi || ! echo -e "${RED_COLOR}未通过打包的配置检测!!! ${RES}" || exit
#./gradlew checkUploadConfig4Didi || ! echo -e "${RED_COLOR}未通过打包的配置检测!!! ${RES}" || exit
./gradlew copyPluginSource
./gradlew clean
./gradlew :dokit-plugin:assemble
./gradlew assembleRelease
#./gradlew assembleRelease
./gradlew :dokit-plugin:assemble --stacktrace
./gradlew :dokit:assembleRelease --stacktrace
./gradlew :dokit-no-op:assembleRelease --stacktrace
./gradlew :dokit-okhttp-api:assembleRelease --stacktrace
./gradlew :dokit-okhttp-v3:assembleRelease --stacktrace
./gradlew :dokit-okhttp-v4:assembleRelease --stacktrace
./gradlew :dokit-util:assembleRelease --stacktrace
./gradlew :dokit-weex:assembleRelease --stacktrace
./gradlew :dokit-ft:assembleRelease --stacktrace
./gradlew :dokit-mc:assembleRelease --stacktrace
./gradlew :dokit-rpc:assembleRelease --stacktrace
./gradlew :dokit-rpc-mc:assembleRelease --stacktrace
./gradlew :dokit-pthread-hook:assembleRelease --stacktrace
#publish
./gradlew :dokit:publish
./gradlew :dokit-ft:publish
./gradlew :dokit-mc:publish
Expand Down
6 changes: 4 additions & 2 deletions Android/upload_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@ RES="\033[0m"

./gradlew checkUploadConfig4Local || ! echo -e "${RED_COLOR}未通过打包的配置检测!!! ${RES}" || exit
./gradlew copyPluginSource
./gradlew :dokit-plugin:assemble --stacktrace
#./gradlew assembleRelease --stacktrace
./gradlew :dokit-plugin:assemble --stacktrace
./gradlew :dokit:assembleRelease --stacktrace
./gradlew :dokit-no-op:assembleRelease --stacktrace
./gradlew :dokit-okhttp-api:assembleRelease --stacktrace
./gradlew :dokit-okhttp-v3:assembleRelease --stacktrace
./gradlew :dokit-okhttp-v4:assembleRelease --stacktrace
./gradlew :dokit-plugin:assembleRelease --stacktrace
./gradlew :dokit-util:assembleRelease --stacktrace
./gradlew :dokit-weex:assembleRelease --stacktrace
./gradlew :dokit-ft:assembleRelease --stacktrace
./gradlew :dokit-mc:assembleRelease --stacktrace
#./gradlew :dokit-rpc:assembleRelease --stacktrace
#./gradlew :dokit-rpc-mc:assembleRelease --stacktrace
./gradlew :dokit-pthread-hook:assembleRelease --stacktrace
#publish
./gradlew :dokit:publish --stacktrace
./gradlew :dokit-no-op:publish --stacktrace
./gradlew :dokit-okhttp-api:publish --stacktrace
Expand Down
22 changes: 18 additions & 4 deletions Android/upload_maven.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,22 @@ RES="\033[0m"
./gradlew checkUploadConfig4Maven || ! echo -e "${RED_COLOR}未通过打包的配置检测!!! ${RES}" || exit
./gradlew copyPluginSource
./gradlew clean
./gradlew :dokit-plugin:assemble
./gradlew assembleRelease
#./gradlew assembleRelease
./gradlew :dokit-plugin:assemble --stacktrace
./gradlew :dokit:assembleRelease --stacktrace
./gradlew :dokit-no-op:assembleRelease --stacktrace
./gradlew :dokit-okhttp-api:assembleRelease --stacktrace
./gradlew :dokit-okhttp-v3:assembleRelease --stacktrace
./gradlew :dokit-okhttp-v4:assembleRelease --stacktrace
./gradlew :dokit-util:assembleRelease --stacktrace
./gradlew :dokit-weex:assembleRelease --stacktrace
./gradlew :dokit-ft:assembleRelease --stacktrace
./gradlew :dokit-mc:assembleRelease --stacktrace
./gradlew :dokit-rpc:assembleRelease --stacktrace
./gradlew :dokit-rpc-mc:assembleRelease --stacktrace
./gradlew :dokit-pthread-hook:assembleRelease --stacktrace
./gradlew :dokit-pthread-hook:assembleRelease --stacktrace
#publish
./gradlew :dokit:publishReleasePublicationToMavenCentralRepository
./gradlew :dokit-ft:publishReleasePublicationToMavenCentralRepository
./gradlew :dokit-mc:publishReleasePublicationToMavenCentralRepository
Expand All @@ -21,8 +35,8 @@ RES="\033[0m"
./gradlew :dokit-okhttp-v3:publishReleasePublicationToMavenCentralRepository
./gradlew :dokit-okhttp-v4:publishReleasePublicationToMavenCentralRepository
./gradlew :dokit-plugin:publishReleasePublicationToMavenCentralRepository
#./gradlew :dokit-rpc:publishReleasePublicationToMavenCentralRepository
#./gradlew :dokit-rpc-mc:publishReleasePublicationToMavenCentralRepository
./gradlew :dokit-rpc:publishReleasePublicationToMavenCentralRepository
./gradlew :dokit-rpc-mc:publishReleasePublicationToMavenCentralRepository
./gradlew :dokit-util:publishReleasePublicationToMavenCentralRepository
./gradlew :dokit-weex:publishReleasePublicationToMavenCentralRepository
echo -e "${GREEN_COLOR} 打包上传到MavenCenter()仓库完成!!! ${RES}"

0 comments on commit c10b568

Please sign in to comment.