Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持productFlavorName #148

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ class VasDollyPlugin : Plugin<Project> {
if (project.hasProperty(PROPERTY_CHANNELS)) {
val channels = project.properties[PROPERTY_CHANNELS] as String
if (channels.isNotEmpty()) {
channelList = channels.split(",")
channelList.clear()
channelList.addAll(channels.split(","))
}
if (channelList.isEmpty()) {
throw InvalidUserDataException("Property(${PROPERTY_CHANNELS}) channel list is empty , please fix it")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ open class ApkChannelPackageTask : ChannelPackageTask() {
generateChannelApk();
}

private fun getOutputDir(): File? {
if (variant?.flavorName?.isNotEmpty() == true) {
return File(channelExtension?.outputDir, variant!!.flavorName!!)
} else {
return channelExtension?.outputDir
}
}

/***
* check channel plugin params
*/
Expand Down Expand Up @@ -63,7 +71,7 @@ open class ApkChannelPackageTask : ChannelPackageTask() {
throw InvalidUserDataException("Task $name channel is null")
}
channelExtension?.checkParams()
println("Task $name, channel files outputDir:${channelExtension?.outputDir?.absolutePath}")
println("Task $name, channel files outputDir:${getOutputDir()?.absolutePath}")
}

@Suppress("PrivateApi")
Expand Down Expand Up @@ -93,7 +101,13 @@ open class ApkChannelPackageTask : ChannelPackageTask() {
* 根据签名类型生成不同的渠道包
*/
private fun generateChannelApk() {
val outputDir = channelExtension?.outputDir
val outputDir = getOutputDir()
// 清理旧的apk
outputDir?.listFiles()?.forEach { file ->
if (file.name.endsWith(".apk")) {
file.delete()
}
}
println("generateChannelApk baseApk:${baseApk?.absolutePath},outputDir:${outputDir?.path}")
val signingConfig = variant?.signingConfig!!
val lowMemory = channelExtension?.lowMemory ?: false
Expand Down Expand Up @@ -124,6 +138,8 @@ open class ApkChannelPackageTask : ChannelPackageTask() {

val keyValue: MutableMap<String, String> = mutableMapOf()
keyValue["appName"] = project.name
keyValue["productFlavorName"] = variant?.flavorName ?: ""
keyValue["channelName"] = channel
keyValue["flavorName"] = channel
keyValue["buildType"] = variant?.buildType ?: ""
keyValue["versionName"] = outInfo?.versionName?.get() ?: ""
Expand Down