Last active
November 6, 2015 19:01
-
-
Save menny/832c6a3a5e10752fd357 to your computer and use it in GitHub Desktop.
Buck examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [buildfile] | |
| includes = //DEFS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| android_library( | |
| name = "my-libt", | |
| manifest = 'src/main/AndroidManifest.xml', | |
| deps = [':guava'], | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def android_support_library(pkg): | |
| group, name, version = pkg.split(':', 3) | |
| id = name | |
| filename = name+'-'+version | |
| if os.path.isfile('libs/'+filename+".aar"): | |
| filename = filename+".aar" | |
| android_prebuilt_aar( | |
| name = id, | |
| aar = filename, | |
| visibility = ['PUBLIC'], | |
| ) | |
| elif os.path.isfile('libs/'+filename+".jar"): | |
| filename = filename+".jar" | |
| prebuilt_jar( | |
| name = id, | |
| binary_jar = filename, | |
| visibility = ['PUBLIC'], | |
| ) | |
| else: | |
| print 'could not locate support library '+pkg+' under '+filename |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| android_support_library('com.android.support:support-annotations:23.1.0') | |
| android_support_library('com.android.support:support-v4:23.1.0') | |
| android_support_library('com.android.support:palette-v7:23.1.0') | |
| android_support_library('com.android.support:appcompat-v7:23.1.0') | |
| android_support_library('com.android.support:recyclerview-v7:23.1.0') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| maven('guava', 'com.google.guava:guava:18.0') | |
| android_library( | |
| name = "my-libt", | |
| manifest = 'src/main/AndroidManifest.xml', | |
| deps = [':guava'], | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def mavensha1(group, name, version, ar): | |
| try: | |
| link = 'http://repo1.maven.org/maven2/{0}/{1}/{2}/{1}-{2}.{3}.sha1'.format(group.replace('.', '/'), name, version, ar) | |
| f = urllib.urlopen(link) | |
| cksum = f.read() | |
| int(cksum, 16) # will throw an error if cksum is not a hexadecimal string | |
| return cksum | |
| except ValueError: | |
| return None | |
| def maven(id, pkg): | |
| group, name, version = pkg.split(':', 3) | |
| for ar in ['aar', 'jar']: | |
| cksum = mavensha1(group, name, version, ar) | |
| if cksum != None: | |
| if ar == 'aar': | |
| android_prebuilt_aar( | |
| name = id, | |
| aar = ':'+id+'-maven-aar', | |
| ) | |
| remote_file( | |
| name = id + '-maven-aar', | |
| sha1 = cksum, | |
| url = 'mvn:' + group + ':' + name + ':' + ar + ':' + version, | |
| out = name + '.' + ar, | |
| ) | |
| else: | |
| prebuilt_jar( | |
| name = id, | |
| binary_jar = ':' + id + '-maven-jar', | |
| visibility = ['PUBLIC'], | |
| ) | |
| remote_file( | |
| name = id + '-maven-jar', | |
| sha1 = cksum, | |
| url = 'mvn:' + group + ':' + name + ':' + ar + ':' + version, | |
| out = name + '.' + ar, | |
| ) | |
| return | |
| print('Not found ' + pkg) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| remote_file( | |
| name = 'guava', | |
| sha1 = '947641f6bb535b1d942d1bc387c45290', | |
| url = 'mvn:com.google.guava:guava:jar:18.0', | |
| out = 'guava.jar', | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| android_library( | |
| name = "my-lib", | |
| srcs = glob(['src/main/java/**/*.java']), | |
| manifest = 'src/main/AndroidManifest.xml', | |
| deps = ['//libs:support-annotations', '//libs:support-v4', '//libs:palette-v7', '//libs:appcompat-v7', '//libs:recyclerview-v7', | |
| visibility = ['PUBLIC'] | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment