From ae45d8bd4cc7b0fc810c3f21dcf2c7188ae3097d Mon Sep 17 00:00:00 2001 From: Konstantin Raev Date: Sat, 23 Jan 2016 02:57:58 -0800 Subject: [PATCH] More fixes to BUCK and java builds of OSS React Native Reviewed By: mkonicek Differential Revision: D2849743 fb-gh-sync-id: 7d0ae9a2fcfda8c017b60af3e8fe7fa4029ab6ea --- ReactAndroid/DEFS | 36 ++++++ .../java/com/facebook/react/testing/BUCK | 1 - .../src/test/java/com/facebook/powermock/BUCK | 89 ++++++++++++++ .../src/main/third-party/java/asm/BUCK | 71 +++++++++++ .../src/main/third-party/java/fest/BUCK | 23 +++- .../src/main/third-party/java/junit/BUCK | 25 +++- .../src/main/third-party/java/mockito/BUCK | 23 +++- .../java/robolectric3/robolectric/BUCK | 111 ++++++++++++++++++ .../src/main/third-party/java/sqlite/BUCK | 19 +++ .../third-party/java/testing-support-lib/BUCK | 12 ++ .../test/java/com/facebook/react/bridge/BUCK | 3 +- 11 files changed, 408 insertions(+), 5 deletions(-) create mode 100644 ReactAndroid/src/main/third-party/java/asm/BUCK create mode 100644 ReactAndroid/src/main/third-party/java/sqlite/BUCK create mode 100644 ReactAndroid/src/main/third-party/java/testing-support-lib/BUCK diff --git a/ReactAndroid/DEFS b/ReactAndroid/DEFS index 87477552f..1ba010a93 100644 --- a/ReactAndroid/DEFS +++ b/ReactAndroid/DEFS @@ -4,6 +4,9 @@ # - At Facebook by running buck from the root of the fb repo # - Outside of Facebook by running buck in the root of the git repo +import os + + # Example: react_native_target('java/com/facebook/react/common:common') def react_native_target(path): return '//ReactAndroid/src/main/' + path @@ -51,3 +54,36 @@ def android_library( annotation_processor_deps=annotation_processor_deps, *args, **kwargs) + + +def robolectric3_test(name, deps, vm_args=None, *args, **kwargs): + + vm_args = vm_args or [] + + # We may need to create buck-out/gen/ if we're running after buck clean. + tmp = 'buck-out/gen/' + get_base_path() + '/__java_test_' + name + '_output__' + extra_vm_args = [ + '-XX:+UseConcMarkSweepGC', # required by -XX:+CMSClassUnloadingEnabled + '-XX:+CMSClassUnloadingEnabled', + '-XX:ReservedCodeCacheSize=150M', + '-Drobolectric.dependency.dir=buck-out/gen/ReactAndroid/src/main/third-party/java/robolectric3/robolectric', + '-Dlibraries=buck-out/gen/ReactAndroid/src/main/third-party/java/robolectric3/robolectric/*.jar', + '-Drobolectric.logging.enabled=true', + '-XX:MaxPermSize=620m', + '-Drobolectric.offline=true', + ] + if os.path.isdir("/dev/shm"): + extra_vm_args.append('-Djava.io.tmpdir=/dev/shm') + else: + extra_vm_args.append( + '-Djava.io.tmpdir=%s' % os.path.join(os.path.abspath('.'), + 'buck-out/bin')) + + # defined in BUCK + robolectric_test( + name=name, + deps=deps, + vm_args=vm_args + extra_vm_args, + *args, + **kwargs + ) \ No newline at end of file diff --git a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/BUCK b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/BUCK index d3c6d7255..2ec639651 100644 --- a/ReactAndroid/src/androidTest/java/com/facebook/react/testing/BUCK +++ b/ReactAndroid/src/androidTest/java/com/facebook/react/testing/BUCK @@ -14,7 +14,6 @@ android_library( react_native_target('java/com/facebook/react/uimanager:uimanager'), react_native_dep('libraries/soloader/java/com/facebook/soloader:soloader'), react_native_dep('third-party/android/support/v4:lib-support-v4'), - react_native_dep('third-party/java/guava:guava'), react_native_dep('third-party/java/infer-annotations:infer-annotations'), react_native_dep('third-party/java/jsr-305:jsr-305'), react_native_dep('third-party/java/junit:junit'), diff --git a/ReactAndroid/src/main/libraries/fbcore/src/test/java/com/facebook/powermock/BUCK b/ReactAndroid/src/main/libraries/fbcore/src/test/java/com/facebook/powermock/BUCK index 7bb6f6802..c5d9b9f49 100644 --- a/ReactAndroid/src/main/libraries/fbcore/src/test/java/com/facebook/powermock/BUCK +++ b/ReactAndroid/src/main/libraries/fbcore/src/test/java/com/facebook/powermock/BUCK @@ -2,10 +2,17 @@ android_library( name = 'powermock', exported_deps = [ ':powermock-api-mockito', + ':mockito-all', ':powermock-api-support', ':powermock-module-junit4-rule', + ':powermock-classloading-base', ':powermock-classloading-xstream', + ':xstream', ':powermock-core', + ':powermock-reflect', + ':javassist', + ':xmlpull', + ':xpp3' ], visibility = ['//ReactAndroid/...',], ) @@ -70,4 +77,86 @@ remote_file( sha1 = '3ced31cd7024fe365b9f3c8082d22c02434577da', ) +prebuilt_jar( + name = 'powermock-classloading-base', + binary_jar = ':download-powermock-classloading-base', + visibility = ['//ReactAndroid/...',], +) +remote_file( + name = 'download-powermock-classloading-base', + url = 'mvn:org.powermock:powermock-classloading-base:jar:1.6.2', + sha1 = 'c8bfc10731a02d3b241892cf2c334a754d473ca7', +) + +prebuilt_jar( + name = 'xstream', + binary_jar = ':download-xstream', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'download-xstream', + url = 'mvn:com.thoughtworks.xstream:xstream:jar:1.4.2', + sha1 = '97e5013f391487cce4de6b0eebcde21549e91872', +) + +prebuilt_jar( + name = 'powermock-reflect', + binary_jar = ':download-powermock-reflect', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'download-powermock-reflect', + url = 'mvn:org.powermock:powermock-reflect:jar:1.6.2', + sha1 = '1af1bbd1207c3ecdcf64973e6f9d57dcd17cc145', +) + +prebuilt_jar( + name = 'javassist', + binary_jar = ':download-javassist', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'download-javassist', + url = 'mvn:org.javassist:javassist:jar:3.20.0-GA', + sha1 = 'a9cbcdfb7e9f86fbc74d3afae65f2248bfbf82a0', +) + +prebuilt_jar( + name = 'mockito-all', + binary_jar = ':download-mockito-all', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'download-mockito-all', + url = 'mvn:org.mockito:mockito-all:jar:1.10.19', + sha1 = '539df70269cc254a58cccc5d8e43286b4a73bf30', +) + +prebuilt_jar( + name = 'xmlpull', + binary_jar = ':download-xmlpull', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'download-xmlpull', + url = 'mvn:xmlpull:xmlpull:jar:1.1.3.1', + sha1 = '2b8e230d2ab644e4ecaa94db7cdedbc40c805dfa', +) + +prebuilt_jar( + name = 'xpp3', + binary_jar = ':download-xpp3', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'download-xpp3', + url = 'mvn:xpp3:xpp3_min:jar:1.1.4c', + sha1 = '19d4e90b43059058f6e056f794f0ea4030d60b86', +) diff --git a/ReactAndroid/src/main/third-party/java/asm/BUCK b/ReactAndroid/src/main/third-party/java/asm/BUCK new file mode 100644 index 000000000..08b3194c4 --- /dev/null +++ b/ReactAndroid/src/main/third-party/java/asm/BUCK @@ -0,0 +1,71 @@ +android_library( + name = 'asm', + exported_deps = [ + ':asm-core', + ':asm-commons', + ':asm-util', + ':asm-analysis', + ':asm-tree', + ], + visibility = ['//ReactAndroid/...',], +) + +prebuilt_jar( + name = 'asm-core', + binary_jar = ':download-asm', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'download-asm', + url = 'mvn:org.ow2.asm:asm:jar:5.0.1', + sha1 = '2fd56467a018aafe6ec6a73ccba520be4a7e1565', +) + +prebuilt_jar( + name = 'asm-commons', + binary_jar = ':download-asm-commons', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'download-asm-commons', + url = 'mvn:org.ow2.asm:asm-commons:jar:5.0.1', + sha1 = '7b7147a390a93a14d2edfdcf3f7b0e87a0939c3e', +) + +prebuilt_jar( + name = 'asm-tree', + binary_jar = ':download-asm-tree', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'download-asm-tree', + url = 'mvn:org.ow2.asm:asm-tree:jar:5.0.1', + sha1 = '1b1e6e9d869acd704056d0a4223071a511c619e6', +) + +prebuilt_jar( + name = 'asm-util', + binary_jar = ':download-asm-util', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'download-asm-util', + url = 'mvn:org.ow2.asm:asm-util:jar:5.0.1', + sha1 = '7c8caddfbd0b2d7b844f8fcc75175b9cb9cf4724', +) + +prebuilt_jar( + name = 'asm-analysis', + binary_jar = ':download-asm-analysis', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'download-asm-analysis', + url = 'mvn:org.ow2.asm:asm-analysis:jar:5.0.1', + sha1 = 'e286fbee48efacb4e7c175f7948d9d8b2ab52352', +) diff --git a/ReactAndroid/src/main/third-party/java/fest/BUCK b/ReactAndroid/src/main/third-party/java/fest/BUCK index b802709c6..9b9e10c86 100644 --- a/ReactAndroid/src/main/third-party/java/fest/BUCK +++ b/ReactAndroid/src/main/third-party/java/fest/BUCK @@ -1,5 +1,14 @@ -prebuilt_jar( +android_library( name = 'fest', + exported_deps = [ + ':fest-core', + ':fest-util', + ], + visibility = ['//ReactAndroid/...',], +) + +prebuilt_jar( + name = 'fest-core', binary_jar = ':fest-binary-jar', visibility = ['//ReactAndroid/...',], ) @@ -9,3 +18,15 @@ remote_file( url = 'mvn:org.easytesting:fest-assert-core:jar:2.0M10', sha1 = 'cb7c91cf614901928ae405f19d9bcdedf82781db', ) + +prebuilt_jar( + name = 'fest-util', + binary_jar = ':fest-util-binary-jar', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'fest-util-binary-jar', + url = 'mvn:org.easytesting:fest-util:jar:1.2.5', + sha1 = 'c4a8d7305b23b8d043be12c979813b096df11f44', +) diff --git a/ReactAndroid/src/main/third-party/java/junit/BUCK b/ReactAndroid/src/main/third-party/java/junit/BUCK index c5f67b010..327e10078 100644 --- a/ReactAndroid/src/main/third-party/java/junit/BUCK +++ b/ReactAndroid/src/main/third-party/java/junit/BUCK @@ -1,5 +1,16 @@ -prebuilt_jar( +include_defs('//ReactAndroid/DEFS') + +android_library( name = 'junit', + exported_deps = [ + ':junit-core', + ':hamcrest', + ], + visibility = ['//ReactAndroid/...',], +) + +prebuilt_jar( + name = 'junit-core', binary_jar = ':download-junit', visibility = ['//ReactAndroid/...',], ) @@ -9,3 +20,15 @@ remote_file( url = 'mvn:junit:junit:jar:4.12', sha1 = '2973d150c0dc1fefe998f834810d68f278ea58ec', ) + +prebuilt_jar( + name = 'hamcrest', + binary_jar = ':download-hamcrest', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'download-hamcrest', + url = 'mvn:org.hamcrest:hamcrest-all:jar:1.3', + sha1 = '63a21ebc981131004ad02e0434e799fd7f3a8d5a', +) diff --git a/ReactAndroid/src/main/third-party/java/mockito/BUCK b/ReactAndroid/src/main/third-party/java/mockito/BUCK index ef93db4ab..35b50499a 100644 --- a/ReactAndroid/src/main/third-party/java/mockito/BUCK +++ b/ReactAndroid/src/main/third-party/java/mockito/BUCK @@ -1,5 +1,14 @@ -prebuilt_jar( +android_library( name = 'mockito', + exported_deps = [ + ':mockito-core', + ':objenesis', + ], + visibility = ['//ReactAndroid/...',], +) + +prebuilt_jar( + name = 'mockito-core', binary_jar = ':mockito-binary-jar', visibility = ['//ReactAndroid/...',], ) @@ -9,3 +18,15 @@ remote_file( url = 'mvn:org.mockito:mockito-core:jar:1.10.19', sha1 = 'e8546f5bef4e061d8dd73895b4e8f40e3fe6effe', ) + +prebuilt_jar( + name = 'objenesis', + binary_jar = ':objenesis-binary-jar', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'objenesis-binary-jar', + url = 'mvn:org.objenesis:objenesis:jar:2.1', + sha1 = '87c0ea803b69252868d09308b4618f766f135a96', +) diff --git a/ReactAndroid/src/main/third-party/java/robolectric3/robolectric/BUCK b/ReactAndroid/src/main/third-party/java/robolectric3/robolectric/BUCK index 7e30d1c02..b035e0941 100644 --- a/ReactAndroid/src/main/third-party/java/robolectric3/robolectric/BUCK +++ b/ReactAndroid/src/main/third-party/java/robolectric3/robolectric/BUCK @@ -1,9 +1,24 @@ +include_defs('//ReactAndroid/DEFS') + android_library( name = 'robolectric', exported_deps = [ ':robolectric-core', ':robolectric-resources', ':robolectric-annotations', + ':robolectric-utils', + ':bouncycastle', + ':vtd-xml', + ':icu', + ':android-all-4.1.2_r1-robolectric-0', + ':json-20080701', + ':tagsoup-1.2', + ':shadows-core-3.0-16', + react_native_dep('third-party/java/asm:asm'), + react_native_dep('third-party/java/sqlite:sqlite'), + ], + deps = [ +# ':locate_android-all', ], visibility = ['//ReactAndroid/...',], ) @@ -43,3 +58,99 @@ remote_file( url = 'mvn:org.robolectric:robolectric-annotations:jar:3.0', sha1 = '2a6cfc072d7680694c1ff893c5dc8fec33163110', ) + +prebuilt_jar( + name = 'robolectric-utils', + binary_jar = ':robolectric-utils-binary-jar', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'robolectric-utils-binary-jar', + url = 'mvn:org.robolectric:robolectric-utils:jar:3.0', + sha1 = '4bcecd8115fe7296088bb1636e6cbd7ae8927392', +) + +prebuilt_jar( + name = 'bouncycastle', + binary_jar = ':bouncycastle-binary-jar', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'bouncycastle-binary-jar', + url = 'mvn:org.bouncycastle:bcprov-jdk16:jar:1.46', + sha1 = 'ce091790943599535cbb4de8ede84535b0c1260c', +) + +prebuilt_jar( + name = 'vtd-xml', + binary_jar = ':vtd-xml-binary-jar', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'vtd-xml-binary-jar', + url = 'mvn:com.ximpleware:vtd-xml:jar:2.11', + sha1 = 'ee5bcf62c1acf76434ee9f1c67a840bafef72a6d', +) + +prebuilt_jar( + name = 'icu', + binary_jar = ':icu-binary-jar', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'icu-binary-jar', + url = 'mvn:com.ibm.icu:icu4j:jar:53.1', + sha1 = '786d9055d4ca8c1aab4a7d4ac8283f973fd7e41f', +) + +prebuilt_jar( + name = 'android-all-4.1.2_r1-robolectric-0', # name defines filename used by robolectric in runtime + binary_jar = ':robolectric-android-all-binary-jar', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'robolectric-android-all-binary-jar', + url = 'mvn:org.robolectric:android-all:jar:4.1.2_r1-robolectric-0', + sha1 = 'aecc8ce5119a25fcea1cdf8285469c9d1261a352', +) + +prebuilt_jar( + name = 'json-20080701', # name defines filename used by robolectric in runtime + binary_jar = ':json-jar', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'json-jar', + url = 'mvn:org.json:json:jar:20080701', + sha1 = 'd652f102185530c93b66158b1859f35d45687258', +) + +prebuilt_jar( + name = 'tagsoup-1.2', # name defines filename used by robolectric in runtime + binary_jar = ':tagsoup-jar', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'tagsoup-jar', + url = 'mvn:org.ccil.cowan.tagsoup:tagsoup:jar:1.2', + sha1 = '639fd364750d7363c85797dc944b4a80f78fa684', +) + +prebuilt_jar( + name = 'shadows-core-3.0-16', # name defines filename used by robolectric in runtime + binary_jar = ':robolectric-shadows-binary-jar', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'robolectric-shadows-binary-jar', + url = 'https://repo1.maven.org/maven2/org/robolectric/shadows-core/3.0/shadows-core-3.0-16.jar', + sha1 = '39d7a856bf91640b1a6d044333336a2b3f3c198f', +) diff --git a/ReactAndroid/src/main/third-party/java/sqlite/BUCK b/ReactAndroid/src/main/third-party/java/sqlite/BUCK new file mode 100644 index 000000000..441701450 --- /dev/null +++ b/ReactAndroid/src/main/third-party/java/sqlite/BUCK @@ -0,0 +1,19 @@ +android_library( + name = 'sqlite', + exported_deps = [ + ':sqlite4java' + ], + visibility = ['//ReactAndroid/...',], +) + +prebuilt_jar( + name = 'sqlite4java', + binary_jar = ':download-sqlite4java', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'download-sqlite4java', + url = 'mvn:com.almworks.sqlite4java:sqlite4java:jar:0.282', + sha1 = '745a7e2f35fdbe6336922e0d492c979dbbfa74fb', +) diff --git a/ReactAndroid/src/main/third-party/java/testing-support-lib/BUCK b/ReactAndroid/src/main/third-party/java/testing-support-lib/BUCK new file mode 100644 index 000000000..f3b93922c --- /dev/null +++ b/ReactAndroid/src/main/third-party/java/testing-support-lib/BUCK @@ -0,0 +1,12 @@ +android_prebuilt_aar( + name = 'testing-support-lib', + aar = ':testing-support-lib-download', + visibility = ['//ReactAndroid/...',], +) + +remote_file( + name = 'testing-support-lib-download', + url = 'mvn:com.android.support.test:testing-support-lib:aar:0.1', + sha1 = '36e4f08b2a3389dd5a5093411df35091bdd68361', +) + diff --git a/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK b/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK index 22f7d5535..bb67c85be 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK +++ b/ReactAndroid/src/test/java/com/facebook/react/bridge/BUCK @@ -12,7 +12,8 @@ android_library( react_native_target('java/com/facebook/react/uimanager:uimanager'), react_native_dep('third-party/java/mockito:mockito'), react_native_dep('third-party/java/robolectric3/robolectric:robolectric'), - ], + react_native_tests_target('java/org/mockito/configuration:configuration'), +], visibility = [ 'PUBLIC' ],