Skip to content

OkBuck options and examples

Nelson Osacky edited this page May 23, 2018 · 3 revisions

This is an example okbuck configuration block that you can use inside your root project's build.gradle.

okbuck {
    buildToolVersion = config.build.buildTools // What you set for buildToolsVersion in the rest of the project
    target = "android-23" // What you set for targetSdkVersion in the rest of the project

    // See https://github.com/uber/okbuck/wiki/Exopackage-Configuration-Guide
    primaryDexPatterns = [
            'app': [
                    '^com/uber/okbuck/example/AppShell^',
                    '^com/uber/okbuck/example/BuildConfig^',
                    '^android/support/multidex/',
                    '^com/facebook/buck/android/support/exopackage/',
                    '^com/github/promeg/xlog_android/lib/XLogConfig^',
                    '^com/squareup/leakcanary/LeakCanary^',
                    '^com/uber/okbuck/example/common/Calc^',
                    '^com/uber/okbuck/example/common/BuildConfig^',
            ]
    ]
    exopackage = [
            'appDevDebug': true
    ]
    appLibDependencies = [
            'appProd': [
                    'buck-android-support',
                    'com.android.support:multidex',
                    'libraries/javalibrary:main',
                    'libraries/common:paidRelease',
            ],
            'appDev' : [
                    'buck-android-support',
                    'com.android.support:multidex',
                    'libraries/javalibrary:main',
                    'libraries/common:freeDebug',
            ],
            'appDemo': [
                    'buck-android-support',
                    'com.android.support:multidex',
                    'libraries/javalibrary:main',
                    'libraries/common:paidRelease',
            ]
    ]
    // Projects to include or exclude as part of the buck build.
    buckProjects = project.subprojects.findAll { it.name != "plugin" && it.name != "transform-cli" }
    
    // Allows buck to generate an intellij project configuration when running ./buckw project
    intellij {
        sources = true
    }
    
    // Allows okbuck to espresso and robolectric buck rules.
    test {
        espresso = true
        robolectric = true
    }

    // Additional options for the buck wrapper generation.
    wrapper {
        watch += ["**/*.sq"] // Additional files that watchman should look at.
    }

    // Allows the use of custom hand-written DEFS which are automatically applied to every BUCK file
    extraDefs += project.file('tooling/buck-defs/DEFS')

    // Set a specific buck binary or alternate buck distribution.
    buckBinary = "com.github.facebook:buck:fc8f977a04b2847c6707668a73320ad336d20527@pex"
}
Clone this wiki locally