为什么在Buck AntennaPod示例中没有添加android-support-v4.jar?

时间:2015-11-05 00:29:13

标签: python buck

我正在查看AntennaPod并查看它如何构建submodules文件夹。

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文件,它取决于所有jar和dslv-res规则。但是所有罐子只能抓住libs文件夹中的罐子(它没有support-v4.jar)。

我的问题是:为什么没有添加android-support-v4.jar(或者我遗漏了什么),以及添加它的构建规则是什么?

来自Buck示例的Full 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',
)

更新

这是我试图实施的图书馆项目。

enter image description here

这是库项目中的Buck文件

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 个答案:

答案 0 :(得分:1)

在该BUCK文件中,为{Bunt}在.jar下找到的每个lib/文件创建了prebuilt_jar规则。我们在this commit的该文件夹下添加support-v4-19.1.0.jar。这在exported_dep构建目标中被引用为//:all-jars//:dslv-lib构建目标依赖于//:all-jars,因此它最终成为IntelliJ中显示的依赖项。