Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
GradlePlugin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
Gradle
GradlePlugin
Commits
1f7e37b6
Commit
1f7e37b6
authored
May 30, 2023
by
tongzifang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add flavor
parent
14445715
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
9 deletions
+33
-9
OssBuildAndUploadPlugin.groovy
...vy/com/qmai/android/plugin/OssBuildAndUploadPlugin.groovy
+12
-4
OssUploadTask.groovy
src/main/groovy/com/qmai/android/plugin/OssUploadTask.groovy
+21
-5
No files found.
src/main/groovy/com/qmai/android/plugin/OssBuildAndUploadPlugin.groovy
View file @
1f7e37b6
...
@@ -15,20 +15,28 @@ class OssBuildAndUploadPlugin implements Plugin<Project> {
...
@@ -15,20 +15,28 @@ class OssBuildAndUploadPlugin implements Plugin<Project> {
void
apply
(
Project
project
)
{
void
apply
(
Project
project
)
{
OssBean
ossBean
=
project
.
getExtensions
().
create
(
"BuildAndOssInfo"
,
OssBean
.
class
)
OssBean
ossBean
=
project
.
getExtensions
().
create
(
"BuildAndOssInfo"
,
OssBean
.
class
)
project
.
afterEvaluate
{
project
.
afterEvaluate
{
// AppExtension app = project.
// AppExtension app = project.
AppExtension
app
=
project
.
getExtensions
().
findByType
(
AppExtension
.
class
)
AppExtension
app
=
project
.
getExtensions
().
findByType
(
AppExtension
.
class
)
app
.
getApplicationVariants
().
all
(
new
Action
<
ApplicationVariant
>()
{
app
.
getApplicationVariants
().
all
(
new
Action
<
ApplicationVariant
>()
{
@Override
@Override
void
execute
(
ApplicationVariant
applicationVariant
)
{
void
execute
(
ApplicationVariant
applicationVariant
)
{
def
name
=
applicationVariant
.
getName
()
def
taskName
=
applicationVariant
.
getName
()
def
buildType
=
applicationVariant
.
buildType
.
name
def
flavor
=
applicationVariant
.
flavorName
def
versionCode
=
applicationVariant
.
versionCode
def
versionName
=
applicationVariant
.
versionName
def
appName
=
applicationVariant
.
buildType
.
manifestPlaceholders
.
get
(
"app_name"
,
"企迈数店"
)
applicationVariant
.
outputs
.
all
(
new
Action
<
BaseVariantOutput
>()
{
applicationVariant
.
outputs
.
all
(
new
Action
<
BaseVariantOutput
>()
{
@Override
@Override
void
execute
(
BaseVariantOutput
baseVariantOutput
)
{
void
execute
(
BaseVariantOutput
baseVariantOutput
)
{
File
flie
=
baseVariantOutput
.
getOutputFile
()
File
flie
=
baseVariantOutput
.
getOutputFile
()
def
task
=
project
.
getTasks
().
create
(
"buildAndOss"
+
firstLetterUpper
(
name
),
OssUploadTask
.
class
,
flie
,
ossBean
.
ossPath
,
firstLetterUpper
(
name
))
def
task
=
project
.
getTasks
().
create
(
"buildAndOss"
+
firstLetterUpper
(
taskName
),
OssUploadTask
.
class
,
flie
,
ossBean
.
ossPath
,
buildType
,
flavor
,
versionCode
,
versionName
,
appName
)
//先编译
//先编译
// task.dependsOn("clean")
// task.dependsOn("clean")
task
.
dependsOn
(
"assemble"
+
firstLetterUpper
(
name
))
task
.
dependsOn
(
"assemble"
+
firstLetterUpper
(
name
))
}
}
})
})
...
...
src/main/groovy/com/qmai/android/plugin/OssUploadTask.groovy
View file @
1f7e37b6
...
@@ -19,15 +19,30 @@ import javax.inject.Inject
...
@@ -19,15 +19,30 @@ import javax.inject.Inject
import
java.util.concurrent.TimeUnit
import
java.util.concurrent.TimeUnit
class
OssUploadTask
extends
DefaultTask
{
class
OssUploadTask
extends
DefaultTask
{
@OutputFile
File
file
;
@OutputFile
@Input
String
ossPath
=
"appfile/demo/"
File
file
;
@Input
String
buildType
;
@Input
String
ossPath
=
"appfile/demo/"
@Input
String
buildType
@Input
String
flavor
@Input
int
versionCode
@Input
String
versionName
@Input
String
appName
@Inject
@Inject
OssUploadTask
(
File
file
,
String
ossPath
,
buildTyp
e
)
{
OssUploadTask
(
File
file
,
String
ossPath
,
buildType
,
flavor
,
versionCode
,
versionName
,
appNam
e
)
{
this
.
file
=
file
this
.
file
=
file
this
.
ossPath
=
ossPath
this
.
ossPath
=
ossPath
this
.
buildType
=
buildType
this
.
buildType
=
buildType
this
.
flavor
=
flavor
this
.
versionCode
=
versionCode
this
.
versionName
=
versionName
this
.
appName
=
appName
setGroup
(
"oss"
)
setGroup
(
"oss"
)
}
}
...
@@ -74,7 +89,8 @@ class OssUploadTask extends DefaultTask {
...
@@ -74,7 +89,8 @@ class OssUploadTask extends DefaultTask {
//钉钉通知
//钉钉通知
MediaType
JSON
=
MediaType
.
parse
(
"application/json; charset=utf-8"
);
MediaType
JSON
=
MediaType
.
parse
(
"application/json; charset=utf-8"
);
def
gson
=
new
Gson
()
def
gson
=
new
Gson
()
def
content
=
"qmshopassitant: 下载地址为: "
+
"https://files.qmai.cn/"
+
ossPath
+
fileName
+
" 当前环境: "
+
buildType
+
" 当前分支: "
+
getBranch
()
def
content
=
"$appName: 下载地址为: "
+
"https://files.qmai.cn/"
+
ossPath
+
fileName
+
" 当前分支: "
+
getBranch
()+
" 当前环境: "
+
buildType
+
" 当前abi: $flavor"
def
dingDingdetail
=
new
FsDetailInfoModel
(
content
)
def
dingDingdetail
=
new
FsDetailInfoModel
(
content
)
def
dingdingInfo
=
new
FsInfoModel
(
dingDingdetail
)
def
dingdingInfo
=
new
FsInfoModel
(
dingDingdetail
)
RequestBody
requestBody
=
RequestBody
.
create
(
JSON
,
gson
.
toJson
(
dingdingInfo
))
RequestBody
requestBody
=
RequestBody
.
create
(
JSON
,
gson
.
toJson
(
dingdingInfo
))
...
...
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