I am working through the AntennaPod and looking at how it builds the submodules
folder.
There is a jar file android-support-v4.jar
that is part of this project.
I don't see anywhere in the code where this .jar is actually added. I also don't see it in the buck-out/bin
folder.
Here is the android_library
step for it:
android_library(
name = 'dslv-lib',
srcs = glob(['submodules/dslv/library/src/**/*.java']),
deps = [
':all-jars',
':dslv-res',
],
)
I see that its fetching the java files, and it depends on all-jars and the dslv-res rule. But all-jars only grabs the jars in the libs folder (which doesnt have the support-v4.jar).
My question is: Why is this android-support-v4.jar
not being added (or am I missing something), and what would be the build rule to add it?
Full AntennaPod code from Buck example is below:
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
Here is the library project I am trying to implement.
Here is the Buck file in the library project
prebuilt_jar(
name = 'android-support-v4',
binary_jar = 'android-support-v4.jar',
visibility = [
'PUBLIC',
],
)
prebuilt_jar(
name = 'bolts',
binary_jar = 'bolts.jar',
visibility = [
'PUBLIC',
],
)
Here is the best attempt build rules I have attempted.
### 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,
)
In that BUCK
file, a prebuilt_jar
rule is created for each .jar
file Buck finds under lib/
. We add support-v4-19.1.0.jar
under that folder in this commit. This is referenced as an exported_dep
in the //:all-jars
build target. The //:dslv-lib
build target takes a dependency on //:all-jars
, so it ends up being a dependency that shows up in IntelliJ.