
OkBuck is a gradle plugin, aiming to help developers utilize the super fast build system: BUCK, based on the existing project with Android Studio + gradle, and keep both build systems work, with few lines configuration.
Android Studio + Gradle has already been many Android developers' option, and to migrate to BUCK, there are many works to be done, which are difficult and buggy. OkBuck aims to provide a gradle plugin, which will do these buggy job for you automaticlly after few lines configuration.
Further more, you can still use OkBuck to maintain your BUCK build system when your gradle configurations changes, OkBuck let you even needn't write one line of the magic BUCK script!
| LOGO | User/Org | Repo |
|---|---|---|
![]() |
YOLO | - |
| 木瓜金融 | - | |
| Piasy | AndroidTDDBootStrap |
If you are using OkBuck in your project, send me a e-mail, I'll add your repo in this list.
Configurations in root project build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.piasy:okbuck-gradle-plugin:1.0.0-beta8'
}
}
allprojects {
repositories {
jcenter()
}
}
apply plugin: 'com.github.piasy.okbuck-gradle-plugin'
okbuck {
resPackages = [
dummylibrary : 'com.github.piasy.okbuck.example.dummylibrary',
app : 'com.github.piasy.okbuck.example',
"another-app": 'com.github.piasy.okbuck.example.anotherapp',
common : 'com.github.piasy.okbuck.example.common',
emptylibrary : 'com.github.piasy.okbuck.example.empty',
]
}- OkBuck hosts on jcenter, so
jcenter()must be added intobuildscriptandallprojects'repositorieslist, and must add beforeapply plugin resPackagesis a map, used for specifing Android library module and Android Application module's package name for generated resources, its key is module's name, value is package name, must be specified, it should be the same aspackagepart in correspondingAndroidManifest.xmlfile- After apply OkBuck plugin (sync project after modify root project
build.gradlefile), two tasks are added into your gradle project ,okbuck, andokbuckClean okbuckwill generate all flavor (you specified) and variant BUCK configs, and each flavor + variant combination will have an BUCK aliasokbuckCleanwill delete all files/dirs generated by OkBuck and BUCK- After execute
./gradlew okbuck, there will be a.buckconfigfile in your project root dir, inside it, there are lots of BUCK alias, e.g.appDevDebug,appProdRelease,another-appDebugetc, which you could use to run BUCK build, e.g.buck build appDevDebugetc
okbuck {
buildToolVersion "23.0.3"
target "android-23"
overwrite true
checkDepConflict true
resPackages = [
dummylibrary : 'com.github.piasy.okbuck.example.dummylibrary',
app : 'com.github.piasy.okbuck.example',
"another-app": 'com.github.piasy.okbuck.example.anotherapp',
common : 'com.github.piasy.okbuck.example.common',
emptylibrary : 'com.github.piasy.okbuck.example.empty',
]
linearAllocHardLimit = [
app: 7194304
]
primaryDexPatterns = [
app: [
'^com/github/piasy/okbuck/example/AppShell^',
'^com/github/piasy/okbuck/example/BuildConfig^',
'^android/support/multidex/',
'^com/facebook/buck/android/support/exopackage/',
'^com/github/promeg/xlog_android/lib/XLogConfig^',
'^com/squareup/leakcanary/LeakCanary^',
]
]
exopackage = [
app: true
]
appClassSource = [
app: 'src/main/java/com/github/piasy/okbuck/example/AppShell.java'
]
appLibDependencies = [
app: [
'buck-android-support',
'multidex',
'javalibrary',
]
]
flavorFilter = [
app: [
'dev',
'prod',
]
]
cpuFilters = [
app: [
'armeabi',
]
]
buckProjects = project.subprojects
}buildToolVersionspecifies the version of the Android SDK Build-tools, default23.0.3targetspecifies the Android target sdk version, which could be abtained by<sdk home>/tools/android list targets --compact, defaultandroid-23overwriteis used to control whether overwrite existing BUCK files, defaultfalsecheckDepConflictis used to control whether check dependency conflict, defaulttruelinearAllocHardLimitandprimaryDexPatternsare maps, used for specifing linearAllocHardLimit and primaryDexPatterns used by BUCK multidex, more details about multidex configuration, please read multidex wiki page, if you don't need multidex (not enable it inbuild.gradle), you can ignore these two parametersexopackage,appClassSourceandappLibDependenciesare maps, used for configuring BUCK exopackage mode, more details about exopackage configuration, please read exopackage wiki page, if you don't need exopackage, you can ignore these three parametersflavorFilteris a map, used for controlling OkBuck only generate BUCK files for flavors you need, default is empty, which will generate all flavors BUCK filecpuFiltersis a map, used for controlling BUCK only create the specific cpu architecture native library folder in your apk file, the same asndk.abiFilterof gradle, support values are:armeabi,armeabi-v7a,x86,x86_64,mips. Note: If you set this parameter, you must set a environment variable namedANDROID_NDKpointing to your local android ndk root dir, otherwise BUCK build will fail.buckProjectsis a set of projects to generate buck configs for. Default is all sub projects of root project.
If you come with bugs of OkBuck, please open an issue,
and it's really appreciated to post the output of ./gradle okbuck --stacktrace --debug
at the same time, or you can join our BUCK QQ group: 170102067.
OkBuck can only generate BUCK configs for you, so if your source code is incompatible with BUCK, you need do more jobs.
Read more on Known caveats wiki page.
Maybe there are more caveats waiting for you, but for the super fast build brought by BUCK, it's worthwhile.
The rest modules in this repo is a full example usage of OkBuck and BUCK.
OkBuck is tested under gradle 2.2.1 ~ 2.11, and com.android.tools.build:gradle 1.5.0 ~ 2.0.0.
If other versions have compatibility problems, please file an issue.
Exceptions:
Any form of contributions are welcome! See the [detail todo list](https://github.com/Piasy/ OkBuck/wiki/TODO-list).
- Thanks for Facebook open source buck build system.
- Thanks for the discussion and help from promeG during my development.
- Thanks for ヤ①個亼簡單 of the manifest merge contribution, and the idea of multi-product flavor support.
- Thanks for hujin1860@gmail.com of the manifest genrule advice.
The MIT License (MIT)
Copyright (c) 2015 Piasy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
