Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
WelfarePurchase
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘明明
WelfarePurchase
Commits
8126cfb1
Commit
8126cfb1
authored
Apr 30, 2025
by
刘明明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改gradle脚本批量出包 并自动上传阿里云oss
parent
b817f80d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
52 deletions
+47
-52
build-values.txt
app/build-values.txt
+3
-50
build.gradle
app/build.gradle
+36
-2
build.gradle
build.gradle
+3
-0
gradle.properties
gradle.properties
+5
-0
No files found.
app/build-values.txt
View file @
8126cfb1
2068725
2063627
2068729
2063628
2068731
2063629
2068735
2069603
2069604
2069605
2069606
2069607
2069608
2069609
2069610
2069611
2069612
2069613
2069614
2069615
2069616
2069617
2069618
2069619
2069620
2069621
2069622
2069623
2069624
2069625
2069626
2069627
2069628
2069629
2069678
2069679
2069680
2069681
2069682
2069683
2069684
2069685
2069686
2069687
2069688
2069689
2069690
2069691
2069692
2069693
2069694
2069695
2069696
app/build.gradle
View file @
8126cfb1
apply
plugin:
'com.android.application'
apply
plugin:
'com.android.application'
apply
plugin:
'kotlin-android'
apply
plugin:
'kotlin-android'
import
com.aliyun.oss.OSSClient
android
{
android
{
//noinspection GradleDependency
//noinspection GradleDependency
compileSdkVersion
32
compileSdkVersion
32
...
@@ -42,6 +42,7 @@ android {
...
@@ -42,6 +42,7 @@ android {
}
}
debug
{
debug
{
buildConfigField
"String"
,
"TASK_ID"
,
project
.
taskId
minifyEnabled
false
minifyEnabled
false
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
proguardFiles
getDefaultProguardFile
(
'proguard-android.txt'
),
'proguard-rules.pro'
}
}
...
@@ -66,7 +67,6 @@ android {
...
@@ -66,7 +67,6 @@ android {
buildConfigField
"String"
,
"CHANNEL_NAME"
,
"\"${value}\""
buildConfigField
"String"
,
"CHANNEL_NAME"
,
"\"${value}\""
}
}
}
}
productFlavors
.
all
{
productFlavors
.
all
{
dimension
"market"
dimension
"market"
}
}
...
@@ -85,9 +85,11 @@ dependencies {
...
@@ -85,9 +85,11 @@ dependencies {
api
'com.google.zxing:core:3.4.1'
api
'com.google.zxing:core:3.4.1'
// 对于编码和解码功能
// 对于编码和解码功能
api
'com.journeyapps:zxing-android-embedded:4.2.0'
api
'com.journeyapps:zxing-android-embedded:4.2.0'
}
}
//批量打包
task
executeAssembleRelease
{
task
executeAssembleRelease
{
//先执行打包任务
//先执行打包任务
dependsOn
'assembleRelease'
dependsOn
'assembleRelease'
...
@@ -116,4 +118,36 @@ task executeAssembleRelease {
...
@@ -116,4 +118,36 @@ task executeAssembleRelease {
}
}
}
}
}
}
}
}
//上传阿里云对象存储oss
task
uploadApkToOss
{
//先执行executeAssembleRelease
dependsOn
executeAssembleRelease
doLast
{
def
endpoint
=
project
.
properties
[
'OSS_ENDPOINT'
]
def
accessKeyId
=
project
.
properties
[
'OSS_ACCESS_KEY_ID'
]
def
accessKeySecret
=
project
.
properties
[
'OSS_ACCESS_KEY_SECRET'
]
def
bucketName
=
project
.
properties
[
'OSS_BUCKET_NAME'
]
def
values
=
new
File
(
'D:\\Halomobi\\HaloDemo\\app\\build-values.txt'
).
readLines
()
values
.
each
{
value
->
def
newFileName
=
"halodhh-${value}.apk"
println
"-----------------------------$newFileName"
def
apkPath
=
"${project.projectDir.absolutePath}/release/${newFileName}"
println
"-----------------------------$apkPath"
def
ossClient
=
new
OSSClient
(
endpoint
,
accessKeyId
,
accessKeySecret
)
try
{
def
objectName
=
"apk/${newFileName}"
ossClient
.
putObject
(
bucketName
,
objectName
,
new
File
(
apkPath
))
println
(
"APK上传成功!OSS路径: ${objectName}"
)
}
catch
(
e
)
{
throw
new
GradleException
(
"上传失败: ${e.message}"
)
}
finally
{
ossClient
.
shutdown
()
}
}
}
}
\ No newline at end of file
build.gradle
View file @
8126cfb1
...
@@ -11,6 +11,7 @@ buildscript {
...
@@ -11,6 +11,7 @@ buildscript {
maven
{
url
'https://maven.aliyun.com/nexus/content/groups/public/'
}
maven
{
url
'https://maven.aliyun.com/nexus/content/groups/public/'
}
maven
{
url
"https://jitpack.io"
}
maven
{
url
"https://jitpack.io"
}
maven
{
url
'https://developer.huawei.com/repo/'
}
maven
{
url
'https://developer.huawei.com/repo/'
}
maven
{
url
'https://plugins.gradle.org/m2/'
}
google
()
google
()
mavenCentral
()
mavenCentral
()
}
}
...
@@ -20,6 +21,7 @@ buildscript {
...
@@ -20,6 +21,7 @@ buildscript {
classpath
'com.google.protobuf:protobuf-gradle-plugin:0.8.17'
classpath
'com.google.protobuf:protobuf-gradle-plugin:0.8.17'
// NOTE: Do not place your application dependencies here; they belong
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
// in the individual module build.gradle files
classpath
'com.aliyun.oss:aliyun-sdk-oss:3.10.2'
}
}
}
}
...
@@ -33,6 +35,7 @@ allprojects {
...
@@ -33,6 +35,7 @@ allprojects {
maven
{
url
'https://maven.aliyun.com/repository/google'
}
maven
{
url
'https://maven.aliyun.com/repository/google'
}
maven
{
url
'https://maven.aliyun.com/nexus/content/groups/public/'
}
maven
{
url
'https://maven.aliyun.com/nexus/content/groups/public/'
}
maven
{
url
'https://developer.hihonor.com/repo'
}
maven
{
url
'https://developer.hihonor.com/repo'
}
maven
{
url
'https://plugins.gradle.org/m2/'
}
google
()
google
()
mavenCentral
()
mavenCentral
()
maven
{
url
"https://jitpack.io"
}
maven
{
url
"https://jitpack.io"
}
...
...
gradle.properties
View file @
8126cfb1
...
@@ -17,5 +17,10 @@ android.useAndroidX=true
...
@@ -17,5 +17,10 @@ android.useAndroidX=true
android.enableJetifier
=
true
android.enableJetifier
=
true
channelName
=
""
channelName
=
""
taskId
=
"219955634"
taskId
=
"219955634"
OSS_ENDPOINT
=
oss-cn-beijing.aliyuncs.com
OSS_ACCESS_KEY_ID
=
OSS_ACCESS_KEY_SECRET
=
OSS_BUCKET_NAME
=
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment