All Projects → Meituan-Dianping → Walle

Meituan-Dianping / Walle

Licence: apache-2.0
Android Signature V2 Scheme签名下的新一代渠道包打包神器

Programming Languages

java
68154 projects - #9 most used programming language
groovy
2714 projects
shell
77523 projects

Projects that are alternatives of or similar to Walle

channelHelper
基于walle工具的多渠道打包脚本
Stars: ✭ 35 (-99.44%)
Mutual labels:  apk-signature-scheme-v2, v2signingenabled
Minecraftdev
Plugin for IntelliJ IDEA that gives special support for Minecraft modding projects.
Stars: ✭ 645 (-89.73%)
Mutual labels:  gradle
Gradle Git
Git plugin for Gradle
Stars: ✭ 559 (-91.1%)
Mutual labels:  gradle
Spock Example
Spock example specifications along with ready-to-go Gradle and Maven builds
Stars: ✭ 595 (-90.53%)
Mutual labels:  gradle
Learning Resources
"Technology Gold mine" to collect and share materials/resources
Stars: ✭ 573 (-90.88%)
Mutual labels:  gradle
Applozic Android Sdk
Android Real Time Chat & Messaging SDK
Stars: ✭ 611 (-90.28%)
Mutual labels:  gradle
Gradle Advanced Build Version
A plugin to generate the Android version code and version name automatically based on git commits number, date and ...
Stars: ✭ 545 (-91.33%)
Mutual labels:  gradle
Fs Blog
个人博客,Spring Boot 开山之作,采用 Spring Boot + MyBatis,前端 Bootstrap + LayUI,支持程序员非常青睐的轻量化的 Markdown 编辑器 Editor.md,支持标签分类检索
Stars: ✭ 700 (-88.86%)
Mutual labels:  gradle
Gradle Docker
A Gradle plugin to build Docker images from the build script.
Stars: ✭ 639 (-89.83%)
Mutual labels:  gradle
Gradle Tips
Gradle tips for all of us
Stars: ✭ 588 (-90.64%)
Mutual labels:  gradle
Java Sdk
🥇 Java SDK to use the IBM Watson services.
Stars: ✭ 587 (-90.66%)
Mutual labels:  gradle
Kotlin Frontend Plugin
Gradle Kotlin (http://kotlinlang.org) plugin for frontend development
Stars: ✭ 578 (-90.8%)
Mutual labels:  gradle
Hibeaver
HiBeaver is a gradle plugin for java byte code manipulation and AOP design by modifying project byte code during build of the package, or modifying byte code within Jar independently.
Stars: ✭ 617 (-90.18%)
Mutual labels:  gradle
Gradlekotlinconverter
Convert from Groovy to Kotlin DSL for Gradle, focused on Android.
Stars: ✭ 559 (-91.1%)
Mutual labels:  gradle
Ok Gradle
IntelliJ/Android Studio plugin for searching artifacts ids of popular Java libraries.
Stars: ✭ 664 (-89.43%)
Mutual labels:  gradle
Mixin
Mixin is a trait/mixin and bytecode weaving framework for Java using ASM
Stars: ✭ 557 (-91.13%)
Mutual labels:  gradle
Adblockfast
Adblock Fast is a new, faster ad blocker for Android, iOS, Chrome, and Opera.
Stars: ✭ 582 (-90.74%)
Mutual labels:  gradle
Charlatano
Proves JVM cheats are viable on native games, and demonstrates the longevity against anti-cheat signature detection systems
Stars: ✭ 599 (-90.47%)
Mutual labels:  gradle
Gogradle
A Gradle Plugin Providing Full Support for Go
Stars: ✭ 712 (-88.67%)
Mutual labels:  gradle
Deep Clean
When Gradle or the IDE let you down, just --nuke all them caches
Stars: ✭ 689 (-89.03%)
Mutual labels:  gradle

Walle

Release Version Build Status PRs Welcome License

Walle(瓦力):Android Signature V2 Scheme签名下的新一代渠道包打包神器

瓦力通过在Apk中的APK Signature Block区块添加自定义的渠道信息来生成渠道包,从而提高了渠道包生成效率,可以作为单机工具来使用,也可以部署在HTTP服务器上来实时处理渠道包Apk的升级网络请求。

Quick Start

为了方便大家的使用,我们提供了2种使用方式:

  • Gradle插件方式,方便快速集成
  • 命令行方式,最大化满足各种自定义需求

Gradle插件使用方式

配置build.gradle

在位于项目的根目录 build.gradle 文件中添加Walle Gradle插件的依赖, 如下:

buildscript {
    dependencies {
        classpath 'com.meituan.android.walle:plugin:1.1.7'
    }
}

并在当前App的 build.gradle 文件中apply这个插件,并添加上用于读取渠道号的AAR

apply plugin: 'walle'

dependencies {
    compile 'com.meituan.android.walle:library:1.1.7'
}

配置插件

walle {
    // 指定渠道包的输出路径
    apkOutputFolder = new File("${project.buildDir}/outputs/channels");
    // 定制渠道包的APK的文件名称
    apkFileNameFormat = '${appName}-${packageName}-${channel}-${buildType}-v${versionName}-${versionCode}-${buildTime}.apk';
    // 渠道配置文件
    channelFile = new File("${project.getProjectDir()}/channel")
}

配置项具体解释:

  • apkOutputFolder:指定渠道包的输出路径, 默认值为new File("${project.buildDir}/outputs/apk")

  • apkFileNameFormat:定制渠道包的APK的文件名称, 默认值为'${appName}-${buildType}-${channel}.apk'
    可使用以下变量:

         projectName - 项目名字
         appName - App模块名字
         packageName - applicationId (App包名packageName)
         buildType - buildType (release/debug等)
         channel - channel名称 (对应渠道打包中的渠道名字)
         versionName - versionName (显示用的版本号)
         versionCode - versionCode (内部版本号)
         buildTime - buildTime (编译构建日期时间)
         fileSHA1 - fileSHA1 (最终APK文件的SHA1哈希值)
         flavorName - 编译构建 productFlavors 名
    
  • channelFile:包含渠道配置信息的文件路径。 具体内容格式详见:渠道配置文件示例,支持使用#号添加注释。

如何获取渠道信息

在需要渠道等信息时可以通过下面代码进行获取

String channel = WalleChannelReader.getChannel(this.getApplicationContext());

如何生成渠道包

生成渠道包的方式是和assemble${variantName}Channels指令结合,渠道包的生成目录默认存放在 build/outputs/apk/,也可以通过walle闭包中的apkOutputFolder参数来指定输出目录

用法示例:

  • 生成渠道包 ./gradlew clean assembleReleaseChannels
  • 支持 productFlavors ./gradlew clean assembleMeituanReleaseChannels

更多用法

插入额外信息

channelFile只支持渠道写入,如果想插入除渠道以外的其他信息,请在walle配置中使用configFile

walle {
    // 渠道&额外信息配置文件,与channelFile互斥
	configFile = new File("${project.getProjectDir()}/config.json")
}

configFile是包含渠道信息和额外信息的配置文件路径。
配置文件采用json格式,支持为每个channel单独配置额外的写入信息。具体内容格式详见:渠道&额外信息配置文件示例

注意:

  • 此配置项与channelFile功能互斥,开发者在使用时选择其一即可,两者都存在时configFile优先执行。
  • extraInfo 不要出现以channel为key的情况

而对应的渠道信息获取方式如下:

ChannelInfo channelInfo= WalleChannelReader.getChannelInfo(this.getApplicationContext());
if (channelInfo != null) {
   String channel = channelInfo.getChannel();
   Map<String, String> extraInfo = channelInfo.getExtraInfo();
}
// 或者也可以直接根据key获取
String value = WalleChannelReader.get(context, "buildtime");
临时生成某渠道包

我们推荐使用channelFile/configFile配置来生成渠道包,但有时也可能有临时生成渠道包需求,这时可以使用:

  • 生成单个渠道包: ./gradlew clean assembleReleaseChannels -PchannelList=meituan

  • 生成多个渠道包: ./gradlew clean assembleReleaseChannels -PchannelList=meituan,dianping

  • 生成渠道包&写入额外信息:

    ./gradlew clean assembleReleaseChannels -PchannelList=meituan -PextraInfo=buildtime:20161212,hash:xxxxxxx

    注意: 这里的extraInfo以key:value形式提供,多个以,分隔。

  • 使用临时channelFile生成渠道包: ./gradlew clean assembleReleaseChannels -PchannelFile=/Users/xx/Documents/channel

  • 使用临时configFile生成渠道包: ./gradlew clean assembleReleaseChannels -PconfigFile=/Users/xx/Documents/config.json

使用上述-P参数后,本次打包channelFile/configFile配置将会失效,其他配置仍然有效。 -PchannelList,-PchannelFile, -PconfigFile三者不可同时使用。

命令行工具使用方式

可以使用命令行工具来支持各类自定义的需求,具体使用方式详见:Walle CLI 使用说明

其他使用方式

为了更好的满足大家的各类自定义需求,我们把对APK Signing Block区块进行读写操作的模块进行了封装。

读写模块的使用说明详见:

Q&A

原理介绍

对该工具的原理感兴趣的同学,可以移步美团Android新一代渠道包生成工具进行了解。

注意事项

  • 使用apksigner重新对Apk签名会导致渠道信息丢失,需要再次写入渠道信息
  • 1.1.3版本起,walle支持对含有comment的apk进行渠道写入, 详见issue 52

技术支持

  • Read The Fucking Source Code
  • 通过提交issue来寻求帮助
  • 联系我们寻求帮助

贡献代码

  • 欢迎提交issue
  • 欢迎提交PR

参考

License

Copyright 2017 Meituan-Dianping

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].