2015-11-05 62 views
1

我正在通過AntennaPod並查看它如何構建submodules文件夾。爲什麼在Buck AntennaPod示例中不添加android-support-v4.jar?

enter image description here

有一個jar文件android-support-v4.jar這是該項目的一部分。

我沒有看到代碼中實際添加了這個.jar的任何地方。我也沒有在buck-out/bin文件夾中看到它。

這裏是android_library一步吧:

android_library(
    name = 'dslv-lib', 
    srcs = glob(['submodules/dslv/library/src/**/*.java']), 
    deps = [ 
    ':all-jars', 
    ':dslv-res', 
    ], 
) 

我看到,其獲取的java文件,而且它依賴於全罐子和dslv清晰度規則。但是所有jar只抓取libs文件夾中的jar(它沒有support-v4.jar)。

我的問題是:這是爲什麼android-support-v4.jar不添加(或我思念的東西),而且這將是構建規則增加嗎?從巴克例如

完全AntennaPod代碼如下:

import re 

jar_deps = [] 
for jarfile in glob(['libs/*.jar']): 
    name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) 
    jar_deps.append(':' + name) 
    prebuilt_jar(
    name = name, 
    binary_jar = jarfile, 
) 

android_library(
    name = 'all-jars', 
    exported_deps = jar_deps, 
) 

presto_gen_aidls = [] 
for aidlfile in glob(['src/com/aocate/presto/service/*.aidl']): 
    name = 'presto_aidls__' + re.sub(r'^.*/([^/]+)\.aidl$', r'\1', aidlfile) 
    presto_gen_aidls.append(':' + name) 
    gen_aidl(
    name = name, 
    aidl = aidlfile, 
    import_path = 'src', 
) 

android_library(
    name = 'presto-aidls', 
    srcs = presto_gen_aidls, 
) 


android_build_config(
    name = 'build-config', 
    package = 'de.danoeh.antennapod', 
) 

APP_CLASS_SOURCE = 'src/de/danoeh/antennapod/AppShell.java' 

android_library(
    name = 'main-lib', 
    srcs = glob(['src/de/danoeh/antennapod/**/*.java'], excludes = [APP_CLASS_SOURCE]), 
    deps = [ 
    ':all-jars', 
    ':dslv-lib', 
    ':presto-lib', 
    ':appcompat', 
    ':build-config', 
    ':res', 
    ], 
) 

android_library(
    name = 'application-lib', 
    srcs = [APP_CLASS_SOURCE], 
    deps = [ 
    ':build-config', 
    ':jars__buck-android-support', 
    ], 
) 

android_resource(
    name = 'res', 
    package = 'de.danoeh.antennapod', 
    res = 'res', 
    assets = 'assets', 
    deps = [ 
    ':appcompat', 
    ':dslv-res', 
    ] 
) 

android_library(
    name = 'dslv-lib', 
    srcs = glob(['submodules/dslv/library/src/**/*.java']), 
    deps = [ 
    ':all-jars', 
    ':dslv-res', 
    ], 
) 

android_resource(
    name = 'dslv-res', 
    package = 'com.mobeta.android.dslv', 
    res = 'submodules/dslv/library/res', 
    deps = [ 
    ] 
) 

android_library(
    name = 'presto-lib', 
    srcs = glob(['src/com/aocate/**/*.java']), 
    deps = [ 
    ':presto-aidls', 
    ':all-jars', 
    ], 
) 

android_manifest(
    name = 'manifest', 
    skeleton = 'AndroidManifest.xml', 
    deps = [ 
    ':main-lib', 
    ], 
) 

keystore(
    name = 'debug_keystore', 
    store = 'keystore/debug.keystore', 
    properties = 'keystore/debug.keystore.properties', 
) 

android_binary(
    name = 'antennapod', 
    manifest = ':manifest', 
    keystore = ':debug_keystore', 
    use_split_dex = True, 
    exopackage = True, 
    primary_dex_patterns = [ 
    '^de/danoeh/antennapod/AppShell^', 
    '^de/danoeh/antennapod/BuildConfig^', 
    '^com/facebook/buck/android/support/exopackage/' 
    ], 
    deps = [ 
    ':main-lib', 
    ':application-lib', 
    ], 
) 


android_prebuilt_aar(
    name = 'appcompat', 
    aar = 'libs/appcompat-v7-19.1.0.aar', 
) 

UPDATE

這裏是庫項目,我想實現。

enter image description here

這裏是巴克在庫項目

prebuilt_jar(
    name = 'android-support-v4', 
    binary_jar = 'android-support-v4.jar', 
    visibility = [ 
    'PUBLIC', 
    ], 
) 

prebuilt_jar(
    name = 'bolts', 
    binary_jar = 'bolts.jar', 
    visibility = [ 
    'PUBLIC', 
    ], 
) 

這裏是最好的嘗試打造我試圖規則文件。

### com.phonegap.plugins.facebook 

android_library(
    name = 'facebook-plugin-java', 
    srcs = glob(['com.phonegap.plugins.facebookconnect/app-FacebookLib/src/**/*.java']), 
) 

android_resource(
    name = 'facebook-plugin-res', 
    package = 'com.facebook', 
    res = 'com.phonegap.plugins.facebookconnect/app-FacebookLib/res', 
) 

facebook_plugin_jar_deps = [] 
for jarfile in glob(['com.phonegap.plugins.facebookconnect/app-FacebookLib/libs/*.jar']): 
    name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) 
    facebook_plugin_jar_deps.append(':' + name) 
    prebuilt_jar(
    name = name, 
    binary_jar = jarfile, 
) 

android_library(
    name = 'facebook-plugin-jars', 
    exported_deps = facebook_plugin_jar_deps, 
) 

回答

1

在這種BUCK文件,prebuilt_jar規則爲每個.jar文件巴克lib/下找到創建。我們在this commit的該文件夾下添加support-v4-19.1.0.jar。這在//:all-jars構建目標中被引用爲exported_dep。構建目標依賴//:all-jars,因此它最終成爲IntelliJ中顯示的依賴關係。

+1

啊,'support-v4-19.1.0.jar' == == android-support-v4.jar' – Aggressor

相關問題