Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

This push brings more improvements to the release candidate for the n…

…ew pants build system as well as a good start towards full py 3.x compatibility.

    pants:
      + Get depmap graphviz support working on dotty - omnigraffle was hiding a few bugs.
      + Add support for passing tests to the junit runner and the specs runner via @argfiles for command lines that are beyond a size threshold.
      + Divorce the ide algorithm from bang so it can operate on unchunked targets and avoid cycles that can result in aggregated ide targets.
      + Add a markdown_to_html task.
      + Make javac and scalac tasks resilient to targets with no files.
      + Fix jar_publish change tracking to include internal and external dependency changes.
      + Fix codegen tasks to always link synthetic targets for upstream even when actually skipping codegen.
      + Move mostly to __future__ print_function make pants bootstrappable in python 3.x add pants.multi to manage pants with multiple python interpreters/
      + Harden BuildFile against valid BUILD file paths that are in fact dirs.
      + Add Phase.uninstall to support trimming away un-needed pants goals.
      + Fixup target ids to handle a top-level BUILD and compiler class mapping to normalize path names for comparison.
      + Change the 1-arg FuncTask wrapper to take a context - this will be a much more common use-case for func actions.
      + Add deploy_excludes to jvm_binary and respect these in the binary and bundle tasks as a short-term hack to be replaced with proper ivy configuration/maven scope support.
      + Add support for globs and rglobs when defining bundles

    python:
      + Make python twitter.commons more py3x friendly.
      + Changes to python common log:
        + change logs from going to stdout to going to stderr
        + change the default log level for stderr to ERROR rather than NONE
        + if we are writing both to disk and to stderr, write a message stating where we write the log files

    jvm:
      Upgrade to guava 11.0.2, twitter-text 1.4.8 and finagle/util 2.0.0.

      app:
        + Log more exception info in applauncher.

      args:
        + Refactoring of command line args parsing.
        + Scala prototype command line parsing implementation.
  • Loading branch information...
commit 522438231c1cb9d72dc3fd1ae23eb79d6cd31298 1 parent 9b4997f
John Sirois authored
Showing with 4,626 additions and 2,488 deletions.
  1. +0 −1  .gitignore
  2. +73 −46 3rdparty/BUILD
  3. +5 −1 3rdparty/python/BUILD
  4. BIN  3rdparty/python/Markdown-2.0.3-py2.6.egg
  5. BIN  3rdparty/python/Markdown-2.1.1-py2.6.egg
  6. BIN  3rdparty/python/Pygments-1.4-py2.6.egg
  7. BIN  3rdparty/python/pystachio-0.4.0-py2.6.egg
  8. BIN  3rdparty/python/pystachio-0.4.2-py2.6.egg
  9. +9 −9 BUILD
  10. +25 −15 BUILD.commons
  11. +6 −11 build-support/bootstrap/bootstrap_pants.py
  12. +89 −91 build-support/commons/ivy/publish.properties
  13. +1 −1  build-support/profiles/junit.ivy.xml
  14. +1 −1  build-support/profiles/scala-specs-2.8.1.ivy.xml
  15. +30 −0 build-support/profiles/xalan.ivy.xml
  16. +46 −0 build-support/python/setup.sh
  17. +4 −4 pants
  18. +22 −1 pants.ini
  19. +1 −1  src/java/com/twitter/common/application/modules/AppLauncherModule.java
  20. +97 −264 src/java/com/twitter/common/args/ArgScanner.java
  21. +22 −38 src/java/com/twitter/common/args/Args.java
  22. +163 −0 src/java/com/twitter/common/args/ArgumentInfo.java
  23. +2 −1  src/java/com/twitter/common/args/BUILD
  24. +0 −1  src/java/com/twitter/common/args/CmdLine.java
  25. +151 −0 src/java/com/twitter/common/args/OptionInfo.java
  26. +4 −2 src/java/com/twitter/common/args/ParserOracle.java
  27. +10 −4 src/java/com/twitter/common/args/Parsers.java
  28. +109 −0 src/java/com/twitter/common/args/PositionalInfo.java
  29. +4 −29 src/java/com/twitter/common/args/TypeUtil.java
  30. +1 −4 src/java/com/twitter/common/args/Verifier.java
  31. +19 −9 src/java/com/twitter/common/args/Verifiers.java
  32. +4 −3 src/java/com/twitter/common/args/constraints/CanExecuteFileVerifier.java
  33. +4 −3 src/java/com/twitter/common/args/constraints/CanReadFileVerifier.java
  34. +4 −3 src/java/com/twitter/common/args/constraints/CanWriteFileVerifier.java
  35. +4 −3 src/java/com/twitter/common/args/constraints/ExistsFileVerifier.java
  36. +4 −3 src/java/com/twitter/common/args/constraints/IsDirectoryFileVerifier.java
  37. +4 −3 src/java/com/twitter/common/args/constraints/NotEmptyIterableVerifier.java
  38. +4 −3 src/java/com/twitter/common/args/constraints/NotEmptyStringVerifier.java
  39. +4 −3 src/java/com/twitter/common/args/constraints/NotNegativeNumberVerifier.java
  40. +4 −3 src/java/com/twitter/common/args/constraints/NotNullVerifier.java
  41. +4 −3 src/java/com/twitter/common/args/constraints/PositiveNumberVerifier.java
  42. +1 −1  src/java/com/twitter/common/args/constraints/RangeNumberVerifier.java
  43. +9 −4 src/java/com/twitter/common/args/parsers/AmountParser.java
  44. +2 −3 src/java/com/twitter/common/args/parsers/ListParser.java
  45. +3 −3 src/java/com/twitter/common/args/parsers/MapParser.java
  46. +3 −3 src/java/com/twitter/common/args/parsers/PairParser.java
  47. +2 −2 src/java/com/twitter/common/args/parsers/SetParser.java
  48. +1 −1  src/java/com/twitter/common/args/parsers/TimeDurationParser.java
  49. +28 −0 src/java/com/twitter/common/reflect/TypeToken.java
  50. +3 −3 src/java/com/twitter/common/testing/EasyMockTest.java
  51. +20 −2 src/java/com/twitter/common/testing/runner/JUnitConsoleRunner.java
  52. +11 −5 src/python/twitter/common/app/__init__.py
  53. +32 −14 src/python/twitter/common/app/application.py
  54. +6 −5 src/python/twitter/common/app/inspection.py
  55. +2 −2 src/python/twitter/common/app/module.py
  56. +3 −2 src/python/twitter/common/app/modules/BUILD
  57. +1 −1  src/python/twitter/common/app/modules/exception_handler.py
  58. +7 −7 src/python/twitter/common/app/modules/varz.py
  59. +6 −2 src/python/twitter/common/collections/__init__.py
  60. +3 −0  src/python/twitter/common/config/BUILD
  61. +1 −1  src/python/twitter/common/config/__init__.py
  62. +4 −4 src/python/twitter/common/config/properties.py
  63. +28 −17 src/python/twitter/common/confluence/confluence.py
  64. +77 −69 src/python/twitter/common/contextutil/__init__.py
  65. +2 −1  src/python/twitter/common/dirutil/__init__.py
  66. +2 −1  src/python/twitter/common/dirutil/chroot.py
  67. +1 −1  src/python/twitter/common/http/mirror_file.py
  68. +1 −1  src/python/twitter/common/java/bin/jar_inspect.py
  69. +56 −5 src/python/twitter/common/lang/__init__.py
  70. +0 −14 src/python/twitter/common/lang/compatibility.py
  71. +6 −1 src/python/twitter/common/log/__init__.py
  72. +45 −13 src/python/twitter/common/log/initialize.py
  73. +66 −25 src/python/twitter/common/log/options.py
  74. +4 −1 src/python/twitter/common/metrics/BUILD
  75. +11 −4 src/python/twitter/common/metrics/metrics.py
  76. +5 −2 src/python/twitter/common/process/process_handle_procfs.py
  77. +3 −2 src/python/twitter/common/python/BUILD
  78. +33 −33 src/python/twitter/common/python/dependency.py
  79. +49 −5 src/python/twitter/common/python/dirwrapper.py
  80. +3 −3 src/python/twitter/common/python/eggcache.py
  81. +11 −6 src/python/twitter/common/python/environment.py
  82. +166 −0 src/python/twitter/common/python/interpreter.py
  83. +36 −27 src/python/twitter/common/python/launcher.py
  84. +7 −4 src/python/twitter/common/python/pexbuilder.py
  85. +31 −14 src/python/twitter/common/python/reqbuilder.py
  86. +20 −16 src/python/twitter/common/python/reqfetcher.py
  87. +4 −1 src/python/twitter/common/quantity/BUILD
  88. +2 −2 src/python/twitter/common/quantity/__init__.py
  89. +2 −1  src/python/twitter/common/quantity/parse_simple.py
  90. +4 −2 src/python/twitter/common/recordio/thrift_recordio.py
  91. +9 −8 src/python/twitter/common/rpc/finagle/BUILD
  92. +4 −1 src/python/twitter/common/string/BUILD
  93. +4 −2 src/python/twitter/common/string/scanf.py
  94. +2 −1  src/python/twitter/common/util/__init__.py
  95. +3 −3 src/python/twitter/common/zookeeper/client.py
  96. +63 −5 src/python/twitter/pants/BUILD
  97. +59 −0 src/python/twitter/pants/README.md
  98. +18 −3 src/python/twitter/pants/__init__.py
  99. +25 −0 src/python/twitter/pants/addendum.markdown
  100. +1 −1  src/python/twitter/pants/ant/__init__.py
  101. +3 −3 src/python/twitter/pants/ant/bang.py
  102. +39 −39 src/python/twitter/pants/ant/ide.py
  103. +18 −15 src/python/twitter/pants/ant/lib.py
  104. +7 −5 src/python/twitter/pants/base/__init__.py
  105. +1 −1  src/python/twitter/pants/base/address.py
  106. +9 −6 src/python/twitter/pants/base/build_cache.py
  107. +13 −7 src/python/twitter/pants/base/build_file.py
  108. +7 −3 src/python/twitter/pants/{tasks → base}/config.py
  109. +4 −2 src/python/twitter/pants/base/fileset.py
  110. +4 −2 src/python/twitter/pants/base/generator.py
  111. +5 −2 src/python/twitter/pants/base/parse_context.py
  112. +9 −8 src/python/twitter/pants/base/target.py
  113. +16 −10 src/python/twitter/pants/bin/pants_exe.py
  114. +6 −5 src/python/twitter/pants/commands/__init__.py
  115. +6 −5 src/python/twitter/pants/commands/build.py
  116. +9 −7 src/python/twitter/pants/commands/depmap.py
  117. +14 −11 src/python/twitter/pants/commands/doc.py
  118. +5 −3 src/python/twitter/pants/commands/eclipse.py
  119. +3 −1 src/python/twitter/pants/commands/filemap.py
  120. +6 −4 src/python/twitter/pants/commands/files.py
  121. +42 −25 src/python/twitter/pants/commands/goal.py
  122. +2 −3 src/python/twitter/pants/commands/ide.py
  123. +1 −1  src/python/twitter/pants/commands/idea.py
  124. +8 −8 src/python/twitter/pants/commands/ivy_resolve.py
  125. +1 −1  src/python/twitter/pants/commands/list.py
  126. +4 −2 src/python/twitter/pants/commands/py.py
  127. +110 −0 src/python/twitter/pants/goal/__init__.py
  128. +81 −0 src/python/twitter/pants/goal/context.py
  129. +105 −0 src/python/twitter/pants/goal/group.py
  130. +186 −0 src/python/twitter/pants/goal/phase.py
  131. +67 −0 src/python/twitter/pants/goal/products.py
  132. +2 −1  src/python/twitter/pants/java/manifest.py
  133. +3 −1 src/python/twitter/pants/java/nailgun_client.py
  134. +23 −16 src/python/twitter/pants/pants_doc/doc_builder.py
  135. +8 −6 src/python/twitter/pants/python/antlr_builder.py
  136. +4 −2 src/python/twitter/pants/python/binary_builder.py
  137. BIN  src/python/twitter/pants/python/bootstrap/distribute-0.6.21-py2.6.egg
  138. +8 −7 src/python/twitter/pants/python/egg_builder.py
  139. +5 −4 src/python/twitter/pants/python/lint_builder.py
  140. +3 −3 src/python/twitter/pants/python/python_builder.py
  141. +176 −83 src/python/twitter/pants/python/python_chroot.py
  142. +16 −27 src/python/twitter/pants/python/test_builder.py
  143. +8 −7 src/python/twitter/pants/python/thrift_builder.py
  144. +33 −29 src/python/twitter/pants/targets/__init__.py
  145. +1 −3 src/python/twitter/pants/targets/annotation_processor.py
  146. +46 −3 src/python/twitter/pants/targets/doc.py
  147. +1 −2  src/python/twitter/pants/targets/exportable_jvm_library.py
  148. +2 −1  src/python/twitter/pants/targets/internal.py
  149. +8 −3 src/python/twitter/pants/targets/jar_dependency.py
  150. +1 −3 src/python/twitter/pants/targets/java_library.py
  151. +2 −5 src/python/twitter/pants/targets/java_protobuf_library.py
  152. +1 −4 src/python/twitter/pants/targets/java_tests.py
  153. +2 −6 src/python/twitter/pants/targets/java_thrift_library.py
  154. +23 −14 src/python/twitter/pants/targets/jvm_binary.py
  155. +3 −4 src/python/twitter/pants/targets/jvm_target.py
  156. +19 −0 src/python/twitter/pants/targets/pants_target.py
  157. +2 −2 src/python/twitter/pants/targets/python_antlr_library.py
  158. +1 −1  src/python/twitter/pants/targets/python_binary.py
  159. +1 −1  src/python/twitter/pants/targets/python_egg.py
  160. +2 −5 src/python/twitter/pants/targets/python_library.py
  161. +38 −0 src/python/twitter/pants/targets/python_requirement.py
  162. +2 −13 src/python/twitter/pants/targets/python_target.py
  163. +1 −1  src/python/twitter/pants/targets/python_tests.py
  164. +1 −4 src/python/twitter/pants/targets/scala_library.py
  165. +1 −3 src/python/twitter/pants/targets/scala_tests.py
  166. +2 −2 src/python/twitter/pants/targets/with_sources.py
  167. +10 −515 src/python/twitter/pants/tasks/__init__.py
  168. +15 −40 src/python/twitter/pants/tasks/binary_create.py
  169. +65 −9 src/python/twitter/pants/tasks/binary_utils.py
  170. +18 −42 src/python/twitter/pants/tasks/bundle_create.py
  171. +121 −0 src/python/twitter/pants/tasks/code_gen.py
  172. +120 −0 src/python/twitter/pants/tasks/confluence_publish.py
  173. +83 −82 src/python/twitter/pants/tasks/ivy_resolve.py
  174. +1 −0  src/python/twitter/pants/tasks/ivy_resolve/ivy.mk
  175. +6 −5 src/python/twitter/pants/tasks/jar_create.py
  176. +90 −41 src/python/twitter/pants/tasks/jar_publish.py
  177. +23 −17 src/python/twitter/pants/tasks/java_compile.py
  178. +16 −11 src/python/twitter/pants/tasks/junit_run.py
  179. +60 −0 src/python/twitter/pants/tasks/jvm_binary_task.py
  180. +0 −2  src/python/twitter/pants/tasks/jvm_run.py
  181. +222 −0 src/python/twitter/pants/tasks/markdown_to_html.py
  182. +22 −22 src/python/twitter/pants/tasks/nailgun_task.py
  183. +48 −93 src/python/twitter/pants/tasks/protobuf_gen.py
  184. +16 −0 src/python/twitter/pants/tasks/python/__init__.py
  185. +156 −0 src/python/twitter/pants/tasks/python/setup.py
  186. +29 −22 src/python/twitter/pants/tasks/scala_compile.py
  187. +22 −21 src/python/twitter/pants/tasks/specs_run.py
  188. +40 −86 src/python/twitter/pants/tasks/thrift_gen.py
  189. +28 −0 src/scala/com/twitter/common/args/BUILD
  190. +52 −0 src/scala/com/twitter/common/args/Flags.scala
  191. +7 −0 src/scala/com/twitter/common/testing/BUILD
  192. +22 −8 src/scala/com/twitter/common/testing/ExplicitSpecsRunnerMain.scala
  193. +7 −5 tests/java/com/twitter/common/args/ArgScannerTest.java
  194. +5 −4 tests/java/com/twitter/common/args/ParsersTest.java
  195. +1 −2  tests/java/com/twitter/common/net/loadbalancing/LeastConnectedStrategyTest.java
  196. +10 −9 tests/java/com/twitter/common/net/loadbalancing/RandomStrategyTest.java
  197. +1 −0  tests/python/twitter/common/app/test_app.py
  198. +3 −3 tests/python/twitter/common/contextutil/test_environment_as.py
  199. +12 −5 tests/python/twitter/common/dirutil/tail_test.py
  200. +7 −1 tests/python/twitter/common/java/BUILD
  201. 0  tests/python/twitter/common/java/{ → resources}/example_class
  202. +8 −4 tests/python/twitter/common/java/test_class_file.py
  203. +5 −18 tests/python/twitter/common/lang/singleton_test.py
  204. +0 −1  tests/python/twitter/common/quantity/test_quantity.py
  205. +2 −1  tests/python/twitter/common/rpc/BUILD
  206. +7 −6 tests/python/twitter/common/rpc/finagle/BUILD
  207. +0 −1  tests/python/twitter/common/string/test_basic_scanf.py
  208. +4 −4 tests/python/twitter/common/util/topological_sort_test.py
  209. +4 −2 tests/python/twitter/pants/ant/test-ide.py
  210. +5 −1 tests/python/twitter/pants/base/BUILD
  211. +5 −8 tests/python/twitter/pants/base/test_build_file.py
  212. +6 −5 tests/python/twitter/pants/base/test_parse_context.py
  213. +2 −1  tests/python/twitter/pants/python/BUILD
  214. +4 −2 tests/python/twitter/pants/python/resources/eggdrop_soup.py
  215. +1 −0  tests/python/twitter/pants/python/test_python_chroot_deps.py
  216. +1 −1  tests/python/twitter/pants/tasks/test_config.py
  217. +2 −1  tests/python/twitter/pants/tasks/test_context.py
  218. +6 −4 tests/python/twitter/thrift/descriptors/test_thrift_parser.py
  219. +3 −1 tests/python/twitter/thrift/text/test_thrift_json_encoder.py
  220. +24 −0 tests/scala/com/twitter/common/args/BUILD
  221. +14 −13 ...tter/common/args/constraints/ScalarVerifier.java → tests/scala/com/twitter/common/args/FlagsSpec.scala
View
1  .gitignore
@@ -11,7 +11,6 @@
.classpath
.factorypath
.python
-.python-eggs
.pydevproject
bin/
build/
View
119 3rdparty/BUILD
@@ -29,12 +29,12 @@ jar_library(name = 'antlr3',
jar_library(name = 'aopalliance',
dependencies = [
- jar(org = 'aopalliance', name = 'aopalliance', rev = '1.0').withSources()
+ jar(org = 'aopalliance', name = 'aopalliance', rev = '1.0').with_sources()
]
)
jar_library(name = 'args4j',
- dependencies = [ jar(org = 'args4j', name = 'args4j', rev = '2.0.16').withSources() ])
+ dependencies = [ jar(org = 'args4j', name = 'args4j', rev = '2.0.16').with_sources() ])
jar_library(name = 'cascading-core',
@@ -49,24 +49,35 @@ Notice: force is NOT transitive, so any indirectly depended package will not hav
jar_library(name = 'cascading2-core',
- dependencies = [ jar(org = 'cascading', name = 'cascading-core', rev = '2.0.0-wip-215') ]
- )
+ dependencies = [
+ jar(org = 'cascading', name = 'cascading-core', rev = '2.0.0-wip-236')
+ ])
jar_library(name = 'cascading-kryo',
- dependencies = [ jar(org = 'cascading.kryo', name = 'cascading.kryo', rev = '0.2.0') ]
- )
+ dependencies = [
+ jar(org = 'cascading.kryo', name = 'cascading.kryo', rev = '0.2.0')
+ ])
jar_library(name = 'cascading2-local',
- dependencies = [ jar(org = 'cascading', name = 'cascading-local', rev = '2.0.0-wip-215') ]
- )
+ dependencies = [
+ jar(org = 'cascading', name = 'cascading-local', rev = '2.0.0-wip-236')
+ ])
jar_library(name = 'cascading2-hadoop',
- dependencies = [ jar(org = 'cascading', name = 'cascading-hadoop', rev = '2.0.0-wip-215') ]
- )
+ dependencies = [
+ jar(org = 'cascading', name = 'cascading-hadoop', rev = '2.0.0-wip-236')
+ ])
+
+
+jar_library(name = 'cascading-thrift',
+ dependencies = [
+ jar(org = 'backtype', name = 'cascading-thrift', rev = '0.2.2')
+ .exclude(org = 'org.apache.thrift')
+ ])
jar_library(name = 'cascading2-test',
- dependencies = [ jar(org = 'cascading', name = 'cascading-test', rev = '2.0.0-wip-215') ]
- )
+ dependencies = [ jar(org = 'cascading', name = 'cascading-test', rev = '2.0.0-wip-236') ]
+ )
jar_library(name = 'cascading.jdbc',
dependencies = [ jar(org = 'r0man', name = 'cascading.jdbc', rev = '1.2') ]
@@ -76,7 +87,7 @@ jar_library(name = 'checkstyle',
dependencies = [
jar(org = 'com.puppycrawl.tools', name = 'checkstyle', rev = '5.5')
.exclude(org = 'com.google.collections', name = 'google-collections')
- .withSources(),
+ .with_sources(),
# Needs this as the replacement for the excluded google-collections.
pants(':guava'),
]
@@ -84,32 +95,33 @@ jar_library(name = 'checkstyle',
jar_library(name = 'cloud9',
dependencies = [
- jar(org = 'edu.umd', name = 'cloud9', rev = '1.2.2').withSources()
+ jar(org = 'edu.umd', name = 'cloud9', rev = '1.2.2').with_sources()
.exclude(org = 'fastutil', name = 'fastutil')
]
)
jar_library(name = 'commons-beanutils',
dependencies = [
- jar(org = 'commons-beanutils', name = 'commons-beanutils', rev = '1.8.3').withSources()
+ jar(org = 'commons-beanutils', name = 'commons-beanutils', rev = '1.8.3')
+ .with_sources()
]
)
jar_library(name = 'commons-codec',
dependencies = [
- jar(org = 'commons-codec', name = 'commons-codec', rev = '1.4').withSources()
+ jar(org = 'commons-codec', name = 'commons-codec', rev = '1.4').with_sources()
]
)
jar_library(name = 'commons-io',
dependencies = [
- jar(org = 'commons-io', name = 'commons-io', rev = '2.1').withSources()
+ jar(org = 'commons-io', name = 'commons-io', rev = '2.1').with_sources()
]
)
jar_library(name = 'commons-lang',
dependencies = [
- jar(org = 'commons-lang', name = 'commons-lang', rev = '2.4').withSources()
+ jar(org = 'commons-lang', name = 'commons-lang', rev = '2.4').with_sources()
]
)
@@ -120,7 +132,7 @@ jar_library(name = 'commons-logging',
)
# common rev for all com.twitter%finagle* artifacts
-FINAGLE_REV = '1.9.12'
+FINAGLE_REV = '2.0.0'
jar_library(name = 'finagle-core',
dependencies = [ jar(org = 'com.twitter', name = 'finagle-core', rev = FINAGLE_REV),
@@ -139,13 +151,13 @@ jar_library(name = 'gson',
jar_library(name = 'guava',
dependencies = [
jar(
- org = 'com.google.guava', name = 'guava', rev = '11.0.1',
- apidocs = 'http://docs.guava-libraries.googlecode.com/git-history/v11.0.1/javadoc/'
- ).withSources(),
+ org = 'com.google.guava', name = 'guava', rev = '11.0.2',
+ apidocs = 'http://docs.guava-libraries.googlecode.com/git-history/v11.0.2/javadoc/'
+ ).with_sources(),
# This dependency should not need to be explicit but its currently required to work
# around a doc generation bug (RTS-524).
- jar(org = 'javax.inject', name = 'javax.inject', rev = '1').withSources(),
+ jar(org = 'javax.inject', name = 'javax.inject', rev = '1').with_sources(),
]
)
@@ -154,21 +166,21 @@ jar_library(name = 'guice',
jar(
org = 'com.google.inject', name = 'guice', rev = '3.0',
apidocs = 'http://google-guice.googlecode.com/svn/tags/3.0/javadoc/'
- ).withSources()
+ ).with_sources()
]
)
jar_library(name = 'guice-multibindings',
dependencies = [
jar(org = 'com.google.inject.extensions', name = 'guice-multibindings', rev = '3.0')
- .withSources()
+ .with_sources()
]
)
jar_library(name = 'guice-servlet',
dependencies = [
jar(org = 'com.google.inject.extensions', name = 'guice-servlet', rev = '3.0')
- .withSources()
+ .with_sources()
]
)
@@ -177,7 +189,7 @@ jar_library(name = 'hsqldb',
jar_library(name = 'jetty',
dependencies = [
- jar(org = 'org.mortbay.jetty', name = 'jetty', rev = '6.1.25').withSources()
+ jar(org = 'org.mortbay.jetty', name = 'jetty', rev = '6.1.25').with_sources()
]
)
@@ -200,33 +212,33 @@ jar_library(name = 'kryo-serializers',
jar_library(name = 'lucene-analyzers',
dependencies = [
jar(org = 'org.apache.lucene', name = 'lucene-analyzers', rev = '3.0.2',
- apidocs = 'http://lucene.apache.org/java/3_0_2/api/all/').withSources()
+ apidocs = 'http://lucene.apache.org/java/3_0_2/api/all/').with_sources()
]
)
jar_library(name = 'lucene-smartcn',
dependencies = [
jar(org = 'org.apache.lucene', name = 'lucene-smartcn', rev = '3.0.2',
- apidocs = 'http://lucene.apache.org/java/3_0_2/api/all/').withSources()
+ apidocs = 'http://lucene.apache.org/java/3_0_2/api/all/').with_sources()
]
)
jar_library(name = 'lucene-core',
dependencies = [
jar(org = 'org.apache.lucene', name = 'lucene-core', rev = '3.0.2',
- apidocs = 'http://lucene.apache.org/java/3_0_2/api/all/').withSources()
+ apidocs = 'http://lucene.apache.org/java/3_0_2/api/all/').with_sources()
]
)
jar_library(name = 'lucene-snowball',
dependencies = [
jar(org = 'org.apache.lucene', name = 'lucene-snowball', rev = '3.0.2',
- apidocs = 'http://lucene.apache.org/java/3_0_2/api/all/').withSources()
+ apidocs = 'http://lucene.apache.org/java/3_0_2/api/all/').with_sources()
]
)
jar_library(name = 'meat-locker',
- dependencies = [ jar(org='meat-locker', name='meat-locker', rev='0.1.3-SNAPSHOT') ]
+ dependencies = [ jar(org='com.twitter', name='meat-locker', rev='0.1.6') ]
)
jar_library(name = 'ostrich',
@@ -243,37 +255,37 @@ jar_library(name = 'protobuf-java',
jar_library(name = 'scala-library',
dependencies = [
- jar(org='org.scala-lang', name='scala-library', rev='2.8.1').withSources()
+ jar(org='org.scala-lang', name='scala-library', rev='2.8.1').with_sources()
]
)
jar_library(name = 'servlet-api',
dependencies = [
- jar(org = 'javax.servlet', name = 'servlet-api', rev = '2.5').withSources()
+ jar(org = 'javax.servlet', name = 'servlet-api', rev = '2.5').with_sources()
]
)
jar_library(name = 'slf4j-api',
dependencies = [
- jar(org = 'org.slf4j', name = 'slf4j-api', rev = '1.6.1').withSources()
+ jar(org = 'org.slf4j', name = 'slf4j-api', rev = '1.6.1').with_sources()
]
)
jar_library(name = 'slf4j-jdk14',
dependencies = [
- jar(org = 'org.slf4j', name = 'slf4j-jdk14', rev = '1.6.1').withSources()
+ jar(org = 'org.slf4j', name = 'slf4j-jdk14', rev = '1.6.1').with_sources()
]
)
jar_library(name = 'spy-memcached',
dependencies = [
- jar(org = 'spy', name = 'spymemcached', rev = '2.7.1').withSources()
+ jar(org = 'spy', name = 'spymemcached', rev = '2.7.1').with_sources()
]
)
jar_library(name = 'stringtemplate',
dependencies = [
- jar(org = 'org.antlr', name = 'stringtemplate', rev = '3.2.1').withSources()
+ jar(org = 'org.antlr', name = 'stringtemplate', rev = '3.2.1').with_sources()
]
)
@@ -316,10 +328,25 @@ jar_library(name = 'twitter4j',
)
jar_library(name = 'twitter-text',
- dependencies = [ jar(org = 'com.twitter', name = 'twitter-text', rev = '1.4.0') ])
+ dependencies = [ jar(org = 'com.twitter', name = 'twitter-text', rev = '1.4.8') ])
jar_library(name = 'twitter-search-common',
- dependencies = [ jar(org = 'com.twitter.search', name = 'common' , rev = '1.5.2.2') ])
+ dependencies = [
+ jar(org = 'com.twitter.search', name = 'common' , rev = '1.5.6.1')
+ .exclude(org = 'org.apache', name="hadoop-core")
+ .exclude(org = 'org.apache.lucene', name="lucene-modules")
+ .exclude(org = 'com.twitter', name='metastore-enhanced-client')
+ .exclude(org = 'com.twitter', name='metastore-thrift')
+ .exclude(org = 'com.twitter', name='pheasant-thrift')
+ .exclude(org = 'com.twitter', name='science-distributed-search')
+ .exclude(org = 'com.twitter', name='science-distributed-search-thrift')
+ .exclude(org = 'com.twitter', name='trends-service-thrift')
+ .exclude(org = 'com.twitter.common')
+ .exclude(org = 'com.twitter.common_internal')
+ .exclude(org = 'com.twitter.search', name = 'blender-thrift')
+ .exclude(org = 'com.twitter.search', name = 'common-thrift')
+ .exclude(org = 'com.twitter.search', name = 'common-web')
+ ])
# common rev for all com.twitter%util* artifacts
UTIL_REV = '1.8.18'
@@ -334,14 +361,14 @@ jar_library(name = 'vertica',
jar_library(name = 'visualization-datasource',
dependencies = [
- jar(org = 'com.google.visualization', name = 'visualization-datasource', rev = '1.0.2')
- .exclude(org = 'com.google.collections', name = 'google-collections')
- ]
- )
+ jar(org = 'com.google.visualization', name = 'visualization-datasource',
+ rev = '1.0.2')
+ .exclude(org = 'com.google.collections', name = 'google-collections')
+ ])
jar_library(name = 'zookeeper',
dependencies = [
- jar(org = 'org.apache.zookeeper', name = 'zookeeper', rev = '3.3.4').withSources()
+ jar(org = 'org.apache.zookeeper', name = 'zookeeper', rev = '3.3.4').with_sources()
.exclude(org = 'jline', name = 'jline')
.exclude(org = 'javax.jms', name = 'jms')
.exclude(org = 'com.sun.jdmk', name = 'jmxtools')
@@ -370,7 +397,7 @@ jar_library(name = 'hamcrest-core',
jar_library(name = 'junit',
dependencies = [
- jar(org = 'junit', name = 'junit-dep', rev = '4.10').withSources(),
+ jar(org = 'junit', name = 'junit-dep', rev = '4.10').with_sources(),
pants(':hamcrest-core')
]
)
View
6 3rdparty/python/BUILD
@@ -198,7 +198,7 @@ python_library(
python_library(
name = 'pystachio',
- dependencies = [egg("pystachio-0.4.0-py2.*.egg")])
+ dependencies = [egg("pystachio-0.4.2-py2.*.egg")])
python_library(
name = 'cherrypy',
@@ -214,3 +214,7 @@ python_library(
python_library(
name = 'tornado',
dependencies = [egg("tornado-2.2-py2.6.egg")])
+
+python_library(
+ name = 'pygments',
+ dependencies = [egg("Pygments-1.4-py2.6.egg")])
View
BIN  3rdparty/python/Markdown-2.0.3-py2.6.egg
Binary file not shown
View
BIN  3rdparty/python/Markdown-2.1.1-py2.6.egg
Binary file not shown
View
BIN  3rdparty/python/Pygments-1.4-py2.6.egg
Binary file not shown
View
BIN  3rdparty/python/pystachio-0.4.0-py2.6.egg
Binary file not shown
View
BIN  3rdparty/python/pystachio-0.4.2-py2.6.egg
Binary file not shown
View
18 BUILD
@@ -1,12 +1,12 @@
# Define the repository layout
-source_root('src/antlr', doc, python_antlr_library)
-source_root('src/java', annotation_processor, doc, jvm_binary, java_library)
-source_root('src/protobuf', doc, java_protobuf_library)
-source_root('src/python', doc, python_binary, python_library)
-source_root('src/scala', doc, jvm_binary, scala_library)
-source_root('src/thrift', doc, java_thrift_library, python_thrift_library)
+source_root('src/antlr', doc, page, python_antlr_library)
+source_root('src/java', annotation_processor, doc, jvm_binary, java_library, page)
+source_root('src/protobuf', doc, java_protobuf_library, page)
+source_root('src/python', doc, page, python_binary, python_library)
+source_root('src/scala', doc, jvm_binary, page, scala_library)
+source_root('src/thrift', doc, java_thrift_library, page, python_thrift_library)
-source_root('tests/java', doc, java_library, java_tests)
-source_root('tests/python', doc, python_library, python_tests, python_test_suite)
-source_root('tests/scala', doc, scala_library, scala_tests)
+source_root('tests/java', doc, java_library, java_tests, page)
+source_root('tests/python', doc, page, python_library, python_tests, python_test_suite)
+source_root('tests/scala', doc, page, scala_library, scala_tests)
View
40 BUILD.commons
@@ -14,6 +14,8 @@
# limitations under the License.
# ==================================================================================================
+from __future__ import print_function
+
import os
import sys
@@ -22,11 +24,11 @@ from zipfile import ZipFile
from twitter.common.python.pexbuilder import PexBuilder
-from twitter.pants import goal, is_internal, is_java
+from twitter.pants import goal, is_internal
from twitter.pants.base.build_file import BuildFile
from twitter.pants.base.parse_context import ParseContext
from twitter.pants.python.python_chroot import PythonChroot
-from twitter.pants.targets import JavaLibrary, JvmBinary
+from twitter.pants.targets import JavaLibrary, JvmBinary, ScalaLibrary
from twitter.pants.tasks import Task
def reinstall():
@@ -37,7 +39,7 @@ def reinstall():
PexBuilder(chroot.dump()).write(pex)
ParseContext(BuildFile(ROOT_DIR, os.path.basename(__file__))).do_in_context(build_pex)
- print '\nPants reinstalled from live local source.'
+ print('\nPants reinstalled from live local source.')
# TODO(John Sirois): remove 'goal' when pants.new -> pants
args = ['pants.pex', 'goal']
@@ -45,7 +47,7 @@ def reinstall():
# When we re-run, pass on the remaining goals and flags so we can pick up where we leave off here.
index = sys.argv.index('reinstall')
args.extend(sys.argv[index+1:])
- print 'Respawning with: %s\n' % ' '.join(args)
+ print('Respawning with: %s\n' % ' '.join(args))
sys.stdout.flush()
sys.stderr.flush()
@@ -91,6 +93,8 @@ class ArgsResourceMapper(Task):
self.resource_index = 0 if main else 1
context.products.require('jars', self.select_targets)
+ context.products.require('classes')
+
self.classdirs = context.config.getlist('args-resource-mapper', 'classdirs')
self.include_all = context.options.args_resource_mapper_include_all
@@ -98,9 +102,13 @@ class ArgsResourceMapper(Task):
if self.classdirs:
jarmap = self.context.products.get('jars')
for target in filter(self.select_targets, targets):
- for basedir, jars in jarmap.get(target).items():
- for jar in jars:
- self._addargsresources(os.path.join(basedir, jar), target)
+ mapping = jarmap.get(target)
+ if mapping:
+ for basedir, jars in mapping.items():
+ for jar in jars:
+ self._addargsresources(os.path.join(basedir, jar), target)
+ else:
+ self.context.log.warn('No classes found for target %s' % target)
def _addargsresources(self, jar, target):
lines = set()
@@ -113,15 +121,14 @@ class ArgsResourceMapper(Task):
if lines:
class Args(object):
- def __init__(self, transitive):
+ def __init__(self, transitive, class_genmap):
self.classnames = set()
def add_clasnames(target):
- # TODO(John Sirois): this does not handle scala - re-use the
- # twitter.pants.tasks.scala_compile.ScalaCompiler#findclasses scanner to map sources to
- # classes?
- if is_java(target):
- self.classnames.update(src.replace('/', '.').replace('.java', '')
- for src in target.sources)
+ if isinstance(target, JavaLibrary) or isinstance(target, ScalaLibrary):
+ for base, classes in class_genmap.get(target).items():
+ for cls in classes:
+ self.classnames.add(cls.replace('.class', '').replace('/', '.'))
+
if transitive:
target.walk(add_clasnames, is_internal)
else:
@@ -147,7 +154,10 @@ class ArgsResourceMapper(Task):
return True
self._addargs(lines if self.include_all
- else filter(Args(self.transitive).matches, lines), jar, target)
+ else filter(Args(self.transitive,
+ self.context.products.get('classes')).matches, lines),
+ jar,
+ target)
@contextmanager
def _open_jar(self, path):
View
17 build-support/bootstrap/bootstrap_pants.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python2.6
-
import os
import sys
import subprocess
@@ -8,21 +6,20 @@
import tempfile
cwd = os.path.dirname(os.path.abspath(sys.argv[0]))
-print 'CWD is %s' % cwd
# detect BUILD_ROOT
build_root = os.path.abspath(os.path.dirname(sys.argv[0]))
while not os.path.exists(os.path.join(build_root, '.git')):
build_root = os.path.dirname(build_root)
if not os.path.exists(os.path.join(build_root, '.git')):
- print >> sys.stderr, 'Could not bootstrap sane environment.'
+ sys.stderr.write('Could not bootstrap sane environment.\n')
sys.exit(1)
-print 'BUILD_ROOT detected as %s' % build_root
+sys.stdout.write('BUILD_ROOT detected as %s\n' % build_root)
# set new USER_SITE
-virtualenv = os.path.join(build_root, '.python')
-print 'Installing virtualenv in %s' % virtualenv
+virtualenv = os.path.join(build_root, '.python', 'bootstrap')
+sys.stdout.write('Installing virtualenv in %s\n' % virtualenv)
# perform the build work in a temp dir
tempdir = tempfile.mkdtemp(prefix = '.python.bootstrap')
@@ -33,7 +30,6 @@
os.path.join(cwd, 'virtualenv.py'),
"--no-site-packages",
"--distribute",
- "--prompt=pants>> ",
"-v",
virtualenv
]
@@ -41,11 +37,10 @@
po = subprocess.Popen(virtualenv_install_args)
rv = po.wait()
if rv != 0:
- print >> sys.stderr, 'Eek, looks like we failed to install!'
+ sys.stderr.write('Eek, looks like we failed to install!\n')
sys.exit(1)
os.chdir(cwd)
-print 'Cleaning up staging directory: %s' % tempdir
+sys.stdout.write('Cleaning up staging directory: %s\n' % tempdir)
shutil.rmtree(tempdir)
-
sys.exit(0)
View
180 build-support/commons/ivy/publish.properties
@@ -1,75 +1,71 @@
-#Publish of com.twitter.common.tools%java-compiler initiated by jsirois (autoinc)
-#Thu, 16 Feb 2012 02:44:18 -0700
-#Publish of com.twitter.common%application-action initiated by billg (autoinc)
-#Tue, 14 Feb 2012 22:17:22 -0800
revision.major.com.twitter.common%base=0
revision.minor.com.twitter.common%base=0
-revision.patch.com.twitter.common%base=35
-revision.sha.com.twitter.common%base=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%base=36
+revision.sha.com.twitter.common%base=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%collections=0
revision.minor.com.twitter.common%collections=0
-revision.patch.com.twitter.common%collections=31
-revision.sha.com.twitter.common%collections=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%collections=32
+revision.sha.com.twitter.common%collections=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%quantity=0
revision.minor.com.twitter.common%quantity=0
-revision.patch.com.twitter.common%quantity=27
-revision.sha.com.twitter.common%quantity=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%quantity=28
+revision.sha.com.twitter.common%quantity=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%stats-util=0
revision.minor.com.twitter.common%stats-util=0
-revision.patch.com.twitter.common%stats-util=9
-revision.sha.com.twitter.common%stats-util=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%stats-util=10
+revision.sha.com.twitter.common%stats-util=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%util-system-mocks=0
revision.minor.com.twitter.common%util-system-mocks=0
-revision.patch.com.twitter.common%util-system-mocks=22
-revision.sha.com.twitter.common%util-system-mocks=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%util-system-mocks=24
+revision.sha.com.twitter.common%util-system-mocks=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%util-sampler=0
revision.minor.com.twitter.common%util-sampler=0
-revision.patch.com.twitter.common%util-sampler=18
-revision.sha.com.twitter.common%util-sampler=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%util-sampler=19
+revision.sha.com.twitter.common%util-sampler=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%stats=0
revision.minor.com.twitter.common%stats=0
-revision.patch.com.twitter.common%stats=37
-revision.sha.com.twitter.common%stats=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%stats=38
+revision.sha.com.twitter.common%stats=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%util=0
revision.minor.com.twitter.common%util=0
-revision.patch.com.twitter.common%util=35
-revision.sha.com.twitter.common%util=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%util=36
+revision.sha.com.twitter.common%util=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%util-caching=0
revision.minor.com.twitter.common%util-caching=0
-revision.patch.com.twitter.common%util-caching=7
-revision.sha.com.twitter.common%util-caching=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%util-caching=8
+revision.sha.com.twitter.common%util-caching=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%dynamic-host-set=0
revision.minor.com.twitter.common%dynamic-host-set=0
-revision.patch.com.twitter.common%dynamic-host-set=15
-revision.sha.com.twitter.common%dynamic-host-set=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%dynamic-host-set=16
+revision.sha.com.twitter.common%dynamic-host-set=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%net-pool=0
revision.minor.com.twitter.common%net-pool=0
revision.patch.com.twitter.common%net-pool=21
revision.sha.com.twitter.common%net-pool=db8240259e4d8bb84717afd21b15b617eda1c200
revision.major.com.twitter.common%io=0
revision.minor.com.twitter.common%io=0
-revision.patch.com.twitter.common%io=17
-revision.sha.com.twitter.common%io=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%io=18
+revision.sha.com.twitter.common%io=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%io-thrift=0
revision.minor.com.twitter.common%io-thrift=0
-revision.patch.com.twitter.common%io-thrift=15
-revision.sha.com.twitter.common%io-thrift=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%io-thrift=16
+revision.sha.com.twitter.common%io-thrift=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%service-thrift=0
revision.minor.com.twitter.common%service-thrift=0
-revision.patch.com.twitter.common%service-thrift=20
-revision.sha.com.twitter.common%service-thrift=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%service-thrift=21
+revision.sha.com.twitter.common%service-thrift=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%zookeeper=0
revision.minor.com.twitter.common%zookeeper=0
revision.patch.com.twitter.common%zookeeper=35
revision.sha.com.twitter.common%zookeeper=f71d964930dbaf33857576aafe04a3c4c7a48de0
revision.major.com.twitter.common%args=0
revision.minor.com.twitter.common%args=1
-revision.patch.com.twitter.common%args=31
-revision.sha.com.twitter.common%args=1e16d63a5708df19ccdf9bf8c62a22a41622b72c
+revision.patch.com.twitter.common%args=32
+revision.sha.com.twitter.common%args=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%application=0
revision.minor.com.twitter.common%application=0
-revision.patch.com.twitter.common%application=20
-revision.sha.com.twitter.common%application=db8240259e4d8bb84717afd21b15b617eda1c200
+revision.patch.com.twitter.common%application=21
+revision.sha.com.twitter.common%application=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%thrift=0
revision.minor.com.twitter.common%thrift=0
revision.patch.com.twitter.common%thrift=25
@@ -88,60 +84,60 @@ revision.patch.org.apache.scribe%scribe_client=7
revision.sha.org.apache.scribe%scribe_client=11271591a637e2b531c494258b41e055eb7dede0
revision.major.com.twitter.common%net-http-handlers-text=0
revision.minor.com.twitter.common%net-http-handlers-text=0
-revision.patch.com.twitter.common%net-http-handlers-text=15
-revision.sha.com.twitter.common%net-http-handlers-text=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%net-http-handlers-text=16
+revision.sha.com.twitter.common%net-http-handlers-text=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%net-http=0
revision.minor.com.twitter.common%net-http=0
-revision.patch.com.twitter.common%net-http=16
-revision.sha.com.twitter.common%net-http=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%net-http=17
+revision.sha.com.twitter.common%net-http=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%stats-time-series=0
revision.minor.com.twitter.common%stats-time-series=0
-revision.patch.com.twitter.common%stats-time-series=18
-revision.sha.com.twitter.common%stats-time-series=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%stats-time-series=19
+revision.sha.com.twitter.common%stats-time-series=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%stats-jvm=0
revision.minor.com.twitter.common%stats-jvm=0
-revision.patch.com.twitter.common%stats-jvm=17
-revision.sha.com.twitter.common%stats-jvm=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%stats-jvm=18
+revision.sha.com.twitter.common%stats-jvm=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%net-http-handlers-time-series=0
revision.minor.com.twitter.common%net-http-handlers-time-series=0
-revision.patch.com.twitter.common%net-http-handlers-time-series=13
-revision.sha.com.twitter.common%net-http-handlers-time-series=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%net-http-handlers-time-series=14
+revision.sha.com.twitter.common%net-http-handlers-time-series=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%inject=0
revision.minor.com.twitter.common%inject=0
-revision.patch.com.twitter.common%inject=14
-revision.sha.com.twitter.common%inject=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%inject=15
+revision.sha.com.twitter.common%inject=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%net-http-handlers-string-template=0
revision.minor.com.twitter.common%net-http-handlers-string-template=0
-revision.patch.com.twitter.common%net-http-handlers-string-template=16
-revision.sha.com.twitter.common%net-http-handlers-string-template=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%net-http-handlers-string-template=17
+revision.sha.com.twitter.common%net-http-handlers-string-template=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%net-http-handlers-thrift=0
revision.minor.com.twitter.common%net-http-handlers-thrift=0
revision.patch.com.twitter.common%net-http-handlers-thrift=14
revision.sha.com.twitter.common%net-http-handlers-thrift=db8240259e4d8bb84717afd21b15b617eda1c200
revision.major.com.twitter.common%logging=0
revision.minor.com.twitter.common%logging=0
-revision.patch.com.twitter.common%logging=14
-revision.sha.com.twitter.common%logging=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%logging=15
+revision.sha.com.twitter.common%logging=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%net-http-handlers=0
revision.minor.com.twitter.common%net-http-handlers=0
-revision.patch.com.twitter.common%net-http-handlers=21
-revision.sha.com.twitter.common%net-http-handlers=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%net-http-handlers=22
+revision.sha.com.twitter.common%net-http-handlers=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%io-hdfs=0
revision.minor.com.twitter.common%io-hdfs=0
revision.patch.com.twitter.common%io-hdfs=6
revision.sha.com.twitter.common%io-hdfs=92d8755ca2489f71398ceea8d96e03977a22f3c8
revision.major.com.twitter.common%stats-provider=0
revision.minor.com.twitter.common%stats-provider=0
-revision.patch.com.twitter.common%stats-provider=18
-revision.sha.com.twitter.common%stats-provider=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%stats-provider=19
+revision.sha.com.twitter.common%stats-provider=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%util-hdfs=0
revision.minor.com.twitter.common%util-hdfs=0
revision.patch.com.twitter.common%util-hdfs=1
revision.sha.com.twitter.common%util-hdfs=92d8755ca2489f71398ceea8d96e03977a22f3c8
revision.major.com.twitter.common%net-util=0
revision.minor.com.twitter.common%net-util=0
-revision.patch.com.twitter.common%net-util=26
-revision.sha.com.twitter.common%net-util=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%net-util=27
+revision.sha.com.twitter.common%net-util=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%zookeeper-testing=0
revision.minor.com.twitter.common%zookeeper-testing=0
revision.patch.com.twitter.common%zookeeper-testing=10
@@ -152,40 +148,40 @@ revision.patch.com.twitter.common%serverset=3
revision.sha.com.twitter.common%serverset=1bf67c85c195ab040acf4c9a4ec84bbf086a7ef2
revision.major.com.twitter.common%application-http=0
revision.minor.com.twitter.common%application-http=0
-revision.patch.com.twitter.common%application-http=14
-revision.sha.com.twitter.common%application-http=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%application-http=15
+revision.sha.com.twitter.common%application-http=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%jdk-logging=0
revision.minor.com.twitter.common%jdk-logging=0
-revision.patch.com.twitter.common%jdk-logging=14
-revision.sha.com.twitter.common%jdk-logging=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%jdk-logging=15
+revision.sha.com.twitter.common%jdk-logging=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%application-action=0
revision.minor.com.twitter.common%application-action=0
-revision.patch.com.twitter.common%application-action=22
-revision.sha.com.twitter.common%application-action=ed0c74bd4a44d694686d8abed5a055250b48a9bd
+revision.patch.com.twitter.common%application-action=23
+revision.sha.com.twitter.common%application-action=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%application-modules=0
revision.minor.com.twitter.common%application-modules=0
revision.patch.com.twitter.common%application-modules=1
revision.sha.com.twitter.common%application-modules=819707d084f415a0eff7421a0e8c695775d6480f
revision.major.com.twitter.common%application-module-applauncher=0
revision.minor.com.twitter.common%application-module-applauncher=0
-revision.patch.com.twitter.common%application-module-applauncher=9
-revision.sha.com.twitter.common%application-module-applauncher=db8240259e4d8bb84717afd21b15b617eda1c200
+revision.patch.com.twitter.common%application-module-applauncher=10
+revision.sha.com.twitter.common%application-module-applauncher=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%application-module-lifecycle=0
revision.minor.com.twitter.common%application-module-lifecycle=0
-revision.patch.com.twitter.common%application-module-lifecycle=11
-revision.sha.com.twitter.common%application-module-lifecycle=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%application-module-lifecycle=12
+revision.sha.com.twitter.common%application-module-lifecycle=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%application-module-http=0
revision.minor.com.twitter.common%application-module-http=0
revision.patch.com.twitter.common%application-module-http=9
revision.sha.com.twitter.common%application-module-http=db8240259e4d8bb84717afd21b15b617eda1c200
revision.major.com.twitter.common%application-module-log=0
revision.minor.com.twitter.common%application-module-log=0
-revision.patch.com.twitter.common%application-module-log=7
-revision.sha.com.twitter.common%application-module-log=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%application-module-log=8
+revision.sha.com.twitter.common%application-module-log=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%application-module-stats=0
revision.minor.com.twitter.common%application-module-stats=0
-revision.patch.com.twitter.common%application-module-stats=8
-revision.sha.com.twitter.common%application-module-stats=db8240259e4d8bb84717afd21b15b617eda1c200
+revision.patch.com.twitter.common%application-module-stats=9
+revision.sha.com.twitter.common%application-module-stats=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%application-module-stats_export=0
revision.minor.com.twitter.common%application-module-stats_export=0
revision.patch.com.twitter.common%application-module-stats_export=4
@@ -208,28 +204,28 @@ revision.patch.com.twitter.common%adserver_rpc=2
revision.sha.com.twitter.common%adserver_rpc=2ac6c967dcd2b8a3f1a190f345d4d0971847dc34
revision.major.com.twitter.common%io-json=0
revision.minor.com.twitter.common%io-json=0
-revision.patch.com.twitter.common%io-json=7
-revision.sha.com.twitter.common%io-json=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%io-json=8
+revision.sha.com.twitter.common%io-json=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%text=0
revision.minor.com.twitter.common%text=0
revision.patch.com.twitter.common%text=11
revision.sha.com.twitter.common%text=11271591a637e2b531c494258b41e055eb7dede0
revision.major.com.twitter.common%args-apt=0
revision.minor.com.twitter.common%args-apt=0
-revision.patch.com.twitter.common%args-apt=19
-revision.sha.com.twitter.common%args-apt=40c6e18a9a5a9341f1c76430ca685df9369054da
+revision.patch.com.twitter.common%args-apt=20
+revision.sha.com.twitter.common%args-apt=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%thrift-text=0
revision.minor.com.twitter.common%thrift-text=0
-revision.patch.com.twitter.common%thrift-text=4
-revision.sha.com.twitter.common%thrift-text=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%thrift-text=5
+revision.sha.com.twitter.common%thrift-text=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%service-thrift-finagle=0
revision.minor.com.twitter.common%service-thrift-finagle=0
revision.patch.com.twitter.common%service-thrift-finagle=9
revision.sha.com.twitter.common%service-thrift-finagle=53f4d78a6258efdd87a7617825c250f8def12022
revision.major.com.twitter.common%util-executor-service-shutdown=0
revision.minor.com.twitter.common%util-executor-service-shutdown=0
-revision.patch.com.twitter.common%util-executor-service-shutdown=9
-revision.sha.com.twitter.common%util-executor-service-shutdown=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%util-executor-service-shutdown=10
+revision.sha.com.twitter.common%util-executor-service-shutdown=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%objectsize=0
revision.minor.com.twitter.common%objectsize=0
revision.patch.com.twitter.common%objectsize=3
@@ -244,28 +240,28 @@ revision.patch.org.apache.scribe%scribe_client_finagle=1
revision.sha.org.apache.scribe%scribe_client_finagle=4d4308e89712d3d6c61105c41bdee313ea4d4440
revision.major.com.twitter.common%args-core=0
revision.minor.com.twitter.common%args-core=0
-revision.patch.com.twitter.common%args-core=8
-revision.sha.com.twitter.common%args-core=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%args-core=9
+revision.sha.com.twitter.common%args-core=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%checkstyle=0
revision.minor.com.twitter.common%checkstyle=0
revision.patch.com.twitter.common%checkstyle=2
revision.sha.com.twitter.common%checkstyle=11271591a637e2b531c494258b41e055eb7dede0
revision.major.com.twitter.common%specs-testing=0
revision.minor.com.twitter.common%specs-testing=0
-revision.patch.com.twitter.common%specs-testing=2
-revision.sha.com.twitter.common%specs-testing=d503f93d83ae0c0b7da12e8a7cc3490726d37cc9
+revision.patch.com.twitter.common%specs-testing=3
+revision.sha.com.twitter.common%specs-testing=03e66026874bbaec9775c3e00ac7d60b051067c9
revision.major.com.twitter.common%reflect=0
revision.minor.com.twitter.common%reflect=0
-revision.patch.com.twitter.common%reflect=4
-revision.sha.com.twitter.common%reflect=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common%reflect=5
+revision.sha.com.twitter.common%reflect=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common%junit-runner=0
revision.minor.com.twitter.common%junit-runner=0
-revision.patch.com.twitter.common%junit-runner=4
-revision.sha.com.twitter.common%junit-runner=a98359a74198541641386694856c545371e4c250
+revision.patch.com.twitter.common%junit-runner=5
+revision.sha.com.twitter.common%junit-runner=03e66026874bbaec9775c3e00ac7d60b051067c9
revision.major.com.twitter.common.zookeeper%client=0
revision.minor.com.twitter.common.zookeeper%client=0
-revision.patch.com.twitter.common.zookeeper%client=4
-revision.sha.com.twitter.common.zookeeper%client=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common.zookeeper%client=5
+revision.sha.com.twitter.common.zookeeper%client=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common.zookeeper%node=0
revision.minor.com.twitter.common.zookeeper%node=0
revision.patch.com.twitter.common.zookeeper%node=4
@@ -276,8 +272,8 @@ revision.patch.com.twitter.common.zookeeper%map=5
revision.sha.com.twitter.common.zookeeper%map=db8240259e4d8bb84717afd21b15b617eda1c200
revision.major.com.twitter.common.zookeeper%lock=0
revision.minor.com.twitter.common.zookeeper%lock=0
-revision.patch.com.twitter.common.zookeeper%lock=4
-revision.sha.com.twitter.common.zookeeper%lock=11271591a637e2b531c494258b41e055eb7dede0
+revision.patch.com.twitter.common.zookeeper%lock=5
+revision.sha.com.twitter.common.zookeeper%lock=608f5c041dde99bcce09a059877ea6b44e4a5248
revision.major.com.twitter.common.zookeeper%group=0
revision.minor.com.twitter.common.zookeeper%group=0
revision.patch.com.twitter.common.zookeeper%group=4
@@ -321,4 +317,6 @@ revision.sha.com.twitter.common%application-module-thrift=db8240259e4d8bb84717af
revision.major.com.twitter.common.tools%java-compiler=0
revision.minor.com.twitter.common.tools%java-compiler=0
revision.patch.com.twitter.common.tools%java-compiler=3
-revision.sha.com.twitter.common.tools%java-compiler=9fb2cb80a82030f8cb94234875d454bdde5f8f64
+revision.sha.com.twitter.common.tools%java-compiler=9fb2cb80a82030f8cb94234875d454bdde5f8f64
+revision.fingerprint.com.twitter.common%junit-runner=1aba807b10ef900b3a71fea8f52cbfb0276809b8
+revision.fingerprint.com.twitter.common%specs-testing=c1f1e562086630deb7ef83d169325ebd91105d2e
View
2  build-support/profiles/junit.ivy.xml
@@ -27,6 +27,6 @@ limitations under the License.
<dependencies>
<dependency org="junit" name="junit-dep" rev="4.10"/>
<dependency org="org.hamcrest" name="hamcrest-core" rev="1.2"/>
- <dependency org="com.twitter.common" name="junit-runner" rev="0.0.4"/>
+ <dependency org="com.twitter.common" name="junit-runner" rev="0.0.5"/>
</dependencies>
</ivy-module>
View
2  build-support/profiles/scala-specs-2.8.1.ivy.xml
@@ -31,6 +31,6 @@ limitations under the License.
<!-- work around transitive SNAPSHOT dep of specs_2.8.0 on scalatest in some maven repos -->
<dependency org="org.scalatest" name="scalatest" rev="1.2" force="true"/>
- <dependency org="com.twitter.common" name="specs-testing" rev="0.0.2"/>
+ <dependency org="com.twitter.common" name="specs-testing" rev="0.0.3"/>
</dependencies>
</ivy-module>
View
30 build-support/profiles/xalan.ivy.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+
+<!--
+=================================================================================================
+Copyright 2011 Twitter, Inc.
+_________________________________________________________________________________________________
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this work except in compliance with the License.
+You may obtain a copy of the License in the LICENSE file, or at:
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+=================================================================================================
+-->
+
+<ivy-module version="2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://ant.apache.org/ivy/schemas/ivy.xsd">
+
+ <info organisation="com.twitter" module="pants-libs"/>
+
+ <dependencies>
+ <dependency org="xalan" name="xalan" rev="2.7.1"/>
+ </dependencies>
+</ivy-module>
View
46 build-support/python/setup.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+
+BASE_DIR=$(dirname $0)/../..
+BOOTSTRAP_BIN=$BASE_DIR/.python/bin
+BOOTSTRAP_ENVIRONMENT=$BASE_DIR/.python/bootstrap
+CACHE=$BASE_DIR/.pants.d/.pip.cache
+
+mkdir -p $BOOTSTRAP_BIN
+mkdir -p $BOOTSTRAP_ENVIRONMENT
+mkdir -p $CACHE
+
+if ! which python; then
+ echo No python interpreter found on the path. Python will not work\!
+ exit 1
+fi
+
+if ! test -f $BOOTSTRAP_BIN/bootstrap; then
+ ln -s $(which python) $BOOTSTRAP_BIN/bootstrap
+fi
+
+PYTHON=$BOOTSTRAP_BIN/bootstrap
+
+pushd $CACHE
+ if ! test -f virtualenv-1.7.tar.gz; then
+ for url in \
+ http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.7.tar.gz \
+ https://svn.twitter.biz/science-binaries/home/third_party/python/virtualenv-1.7.tar.gz; do
+ if curl --connect-timeout 10 -O $url; then
+ break
+ fi
+ done
+ fi
+ gzip -cd virtualenv-1.7.tar.gz | tar -xvf -
+popd
+
+if $PYTHON $CACHE/virtualenv-1.7/virtualenv.py --distribute $BOOTSTRAP_ENVIRONMENT; then
+ source $BOOTSTRAP_ENVIRONMENT/bin/activate
+ for pkg in mako distribute; do
+ pip install \
+ --download-cache=$CACHE \
+ -f https://svn.twitter.biz/science-binaries/home/third_party/python \
+ -f http://pypi.python.org/simple \
+ -U --no-index $pkg
+ done
+ deactivate
+fi
View
8 pants
@@ -16,16 +16,16 @@
# ==================================================================================================
MY_DIR=$(dirname $0)
-VIRTUAL_PYTHON=$MY_DIR/.python
+VIRTUAL_PYTHON=$MY_DIR/.python/bootstrap
PANTS_EXE=$MY_DIR/src/python/twitter/pants/bin/pants_exe.py
MAKO_EGG=$MY_DIR/3rdparty/python/Mako-0.4.0-py2.6.egg
-MARKDOWN_EGG=$MY_DIR/3rdparty/python/Markdown-2.0.3-py2.6.egg
-ELEMENTTREE_EGG=$MY_DIR/3rdparty/python/elementtree-1.2.7_20070827_preview-py2.6.egg
+MARKDOWN_EGG=$MY_DIR/3rdparty/python/Markdown-2.1.1-py2.6.egg
+PYGMENTS_EGG=$MY_DIR/3rdparty/python/Pygments-1.4-py2.6.egg
function run_pants_bare() {
source $VIRTUAL_PYTHON/bin/activate
- PYTHONPATH=$MAKO_EGG:$MARKDOWN_EGG:$ELEMENTTREE_EGG:$MY_DIR/src/python python $PANTS_EXE "$@"
+ PYTHONPATH=$MAKO_EGG:$MARKDOWN_EGG:$PYGMENTS_EGG:$MY_DIR/src/python python $PANTS_EXE "$@"
deactivate
}
View
23 pants.ini
@@ -4,7 +4,9 @@
pants_workdir: %(buildroot)s/.pants.d
pants_supportdir: %(buildroot)s/build-support
pants_distdir: %(buildroot)s/dist
+pants_pythons: %(buildroot)s/.python
confs: ['default']
+max_subprocess_args: 100
scala_workdir: %(pants_workdir)s/scalac
java_workdir: %(pants_workdir)s/javac
@@ -42,9 +44,10 @@ workdir: %(pants_supportdir)s/profiles
[ivy-resolve]
workdir: %(pants_workdir)s/classpath
nailgun_dir: %(pants_workdir)s/ng/ivy
+profile: xalan
cache_dir: %(homedir)s/.ivy2/twitter-commons
transitive: True
-args: ['-warn']
+args: []
[thrift-gen]
@@ -159,6 +162,12 @@ args: ['-Xmx1g', '-XX:MaxPermSize=256m']
workdir: %(pants_workdir)s/javadoc
+[markdown-to-html]
+workdir: %(pants_workdir)s/markdown
+code-style: friendly
+extensions: ['.md', '.markdown']
+
+
[jar-create]
workdir: %(pants_workdir)s/jars
@@ -173,3 +182,15 @@ classdirs: [ '%(java_workdir)s/classes', '%(scala_workdir)s' ]
[bundle-create]
outdir: %(pants_distdir)s
+
+
+[python-setup]
+cache: %(pants_workdir)s/.pip.cache
+artifact_cache: %(pants_workdir)s/py_artifact_cache
+virtualenv_target: %(cache)s/virtualenv-1.7
+virtualenv_urls: ['http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.7.tar.gz']
+repos: ['http://pypi.python.org/simple']
+indices: ['http://pypi.python.org/simple']
+bootstrap_packages: [
+ 'pip',
+ 'mako']
View
2  src/java/com/twitter/common/application/modules/AppLauncherModule.java
@@ -43,7 +43,7 @@ protected void configure() {
public static class LoggingExceptionHandler implements UncaughtExceptionHandler {
@Override public void uncaughtException(Thread t, Throwable e) {
- LOG.log(Level.SEVERE, "Uncaught exception from " + t, e);
+ LOG.log(Level.SEVERE, "Uncaught exception from " + t + ":" + e, e);
}
}
}
View
361 src/java/com/twitter/common/args/ArgScanner.java
@@ -18,11 +18,7 @@
import java.io.IOException;
import java.io.PrintStream;
-import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Type;
-import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -35,7 +31,6 @@
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
-import com.google.common.base.Functions;
import com.google.common.base.Joiner;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
@@ -52,13 +47,8 @@
import com.google.common.collect.Ordering;
import com.google.common.collect.Sets;
-import com.twitter.common.args.Args.ArgumentInfo;
-import com.twitter.common.args.Args.OptionInfo;
-import com.twitter.common.args.Args.PositionalInfo;
import com.twitter.common.args.apt.Configuration;
-import com.twitter.common.args.constraints.NotNull;
import com.twitter.common.collections.Pair;
-import com.twitter.common.reflect.TypeToken;
import static com.google.common.base.Preconditions.checkArgument;
@@ -93,18 +83,10 @@
* @author William Farner
*/
public final class ArgScanner {
-
- private static final Function<OptionInfo, CmdLine> GET_CMD_LINE =
- new Function<OptionInfo, CmdLine>() {
- @Override public CmdLine apply(OptionInfo optionInfo) {
- return optionInfo.cmdLine;
- }
- };
-
- private static final Function<OptionInfo, Field> GET_FIELD =
- new Function<OptionInfo, Field>() {
- @Override public Field apply(OptionInfo optionInfo) {
- return optionInfo.field;
+ private static final Predicate<OptionInfo> IS_BOOLEAN =
+ new Predicate<OptionInfo>() {
+ @Override public boolean apply(OptionInfo optionInfo) {
+ return optionInfo.isBoolean();
}
};
@@ -119,18 +101,9 @@ public ArgScanException(Throwable cause) {
private static final Logger LOG = Logger.getLogger(ArgScanner.class.getName());
- // Negation prefix for booleans.
- private static final String NEGATE_BOOLEAN = "no_";
-
- // Regular expression that defines the name format for an argument.
- private static final String ARG_NAME_RE = "[\\w\\-\\.]+";
- private static final Pattern ARG_NAME_PATTERN = Pattern.compile(ARG_NAME_RE);
- private static final Pattern NEGATED_BOOLEAN_PATTERN = Pattern.compile(
- String.format("(%s)?%s(%s)", ARG_NAME_RE, NEGATE_BOOLEAN, ARG_NAME_RE));
-
// Pattern for the required argument format.
private static final Pattern ARG_PATTERN =
- Pattern.compile(String.format("-(%s)(?:(?:=| +)(.*))?", ARG_NAME_RE));
+ Pattern.compile(String.format("-(%s)(?:(?:=| +)(.*))?", OptionInfo.ARG_NAME_RE));
private final PrintStream out;
@@ -169,8 +142,8 @@ public boolean parse(Iterable<String> args) {
}
/**
- * Applies the provided argument values to any {@literal @CmdLine} {@code Arg} fields discovered
- * on the classpath and accepted by the given {@code filter}.
+ * Applies the provided argument values to any {@literal @CmdLine} or {@literal @Positional} {@code Arg} fields
+ * discovered on the classpath and accepted by the given {@code filter}.
*
* @param filter A predicate that selects or rejects scanned {@literal @CmdLine} fields for
* argument application.
@@ -184,7 +157,29 @@ public boolean parse(Iterable<String> args) {
*/
public boolean parse(Predicate<Field> filter, Iterable<String> args) {
Configuration configuration = load();
- ArgumentInfo argumentInfo = Args.fromConfiguration(configuration, filter);
+ Args.ArgumentInfo argumentInfo = Args.fromConfiguration(configuration, filter);
+ return parse(argumentInfo, configuration, args);
+ }
+
+ /**
+ * Parse command line arguments given a {@link Args.ArgumentInfo}
+ *
+ * @param argumentInfo A description of any optional and positional arguments
+ * @param args A sequence of strings from the command-line
+ * @return {@code true} if the given {@code args} were successfully applied to their corresponding
+ * {@link Arg} fields.
+ * @throws ArgScanException if there was a problem loading {@literal @CmdLine} argument
+ * definitions
+ * @throws IllegalArgumentException If the arguments provided are invalid based on the declared
+ * arguments found.
+ */
+ public boolean parse(Args.ArgumentInfo argumentInfo, Iterable<String> args) {
+ Configuration configuration = load();
+ return parse(argumentInfo, configuration, args);
+ }
+
+ private boolean parse(Args.ArgumentInfo argumentInfo, Configuration configuration,
+ Iterable<String> args) {
ParserOracle parserOracle = Parsers.fromConfiguration(configuration);
Verifiers verifiers = Verifiers.fromConfiguration(configuration);
Pair<ImmutableMap<String, String>, List<String>> results = mapArguments(args);
@@ -205,7 +200,7 @@ private Configuration load() {
// end up in different command line arg array elements.
// - The command line is using the short form for a boolean argument,
// such as -use_feature, or -no_use_feature.
- private static final String DANGLING_ASSIGNMENT_RE = String.format("^-%s", ARG_NAME_RE);
+ private static final String DANGLING_ASSIGNMENT_RE = String.format("^-%s", OptionInfo.ARG_NAME_RE);
private static final Pattern DANGLING_ASSIGNMENT_PATTERN =
Pattern.compile(DANGLING_ASSIGNMENT_RE);
@@ -288,38 +283,21 @@ private static String stripQuotes(String str) {
return Pair.of(argMap.build(), positionalArgs);
}
- private static final ImmutableSet<String> HELP_ARGS = ImmutableSet.of("h", "help");
-
- // TODO(John Sirois): Support these checks at compile time.
- private static void checkArgDef(ParserOracle parserOracle, Field field, CmdLine cmdLine) {
- checkArgDef(parserOracle, field, cmdLine.parser());
-
- String argName = cmdLine.name();
- checkArgument(!HELP_ARGS.contains(argName),
- String.format("Argument name '%s' is reserved for builtin argument help", argName));
- checkArgument(ARG_NAME_PATTERN.matcher(argName).matches(),
- String.format("Argument name '%s' on %s does not match required pattern %s",
- argName, field, ARG_NAME_RE));
- }
-
- // TODO(John Sirois): Support these checks at compile time.
- private static void checkArgDef(ParserOracle parserOracle, Field field,
- Class<? extends Parser> custom) {
-
- checkArgument(Modifier.isStatic(field.getModifiers()),
- "Non-static argument fields are not supported, found " + field);
-
- checkArgument(getParser(parserOracle, custom, field) != null,
- "No parser found for type " + TypeUtil.getTypeParamClass(field)
- + ", for arg field " + field.getName());
- }
+ /**
+ * Extracts the name from an @OptionInfo.
+ */
+ private static final Function<OptionInfo, String> GET_OPTIONINFO_NAME = new Function<OptionInfo, String>() {
+ @Override public String apply(OptionInfo optionInfo) {
+ return optionInfo.getName();
+ }
+ };
/**
- * Extracts the name from an @Arg.
+ * Extracts the name from an @OptionInfo.
*/
- private static final Function<CmdLine, String> GET_ARG_NAME = new Function<CmdLine, String>() {
- @Override public String apply(CmdLine cmdLine) {
- return cmdLine.name();
+ private static final Function<OptionInfo, String> GET_OPTIONINFO_NEGATED_NAME = new Function<OptionInfo, String>() {
+ @Override public String apply(OptionInfo optionInfo) {
+ return optionInfo.getNegatedName();
}
};
@@ -329,8 +307,7 @@ private static void checkArgDef(ParserOracle parserOracle, Field field,
private static final Function<OptionInfo, String> GET_CANONICAL_ARG_NAME =
new Function<OptionInfo, String>() {
@Override public String apply(OptionInfo optionInfo) {
- return optionInfo.field.getDeclaringClass().getCanonicalName()
- + "." + optionInfo.cmdLine.name();
+ return optionInfo.getCanonicalName();
}
};
@@ -340,17 +317,10 @@ private static void checkArgDef(ParserOracle parserOracle, Field field,
private static final Function<OptionInfo, String> GET_CANONICAL_NEGATED_ARG_NAME =
new Function<OptionInfo, String>() {
@Override public String apply(OptionInfo optionInfo) {
- return optionInfo.field.getDeclaringClass().getCanonicalName()
- + "." + NEGATE_BOOLEAN + optionInfo.cmdLine.name();
+ return optionInfo.getCanonicalNegatedName();
}
};
- private static final Function<String, String> PREPEND_NEGATION = new Function<String, String>() {
- @Override public String apply(String name) {
- return NEGATE_BOOLEAN + name;
- }
- };
-
private static <T> Set<T> dropCollisions(Iterable<T> input) {
Set<T> copy = Sets.newHashSet();
Set<T> collisions = Sets.newHashSet();
@@ -364,9 +334,6 @@ private static void checkArgDef(ParserOracle parserOracle, Field field,
return copy;
}
- private static final Function<OptionInfo, String> GET_FIELD_ARG_NAME =
- Functions.compose(GET_ARG_NAME, GET_CMD_LINE);
-
/**
* Applies argument values to fields based on their annotations.
*
@@ -379,57 +346,45 @@ private static void checkArgDef(ParserOracle parserOracle, Field field,
* corresponding {@link com.twitter.common.args.Arg} fields.
*/
private boolean process(final ParserOracle parserOracle, Verifiers verifiers,
- ArgumentInfo argumentInfo, Map<String, String> args,
+ Args.ArgumentInfo argumentInfo, Map<String, String> args,
List<String> positionalArgs) {
- if (!Sets.intersection(args.keySet(), HELP_ARGS).isEmpty()) {
+ if (!Sets.intersection(args.keySet(), ArgumentInfo.HELP_ARGS).isEmpty()) {
printHelp(verifiers, argumentInfo);
return false;
}
- Optional<PositionalInfo> positionalInfo = argumentInfo.positionalInfo;
- checkArgument(positionalInfo.isPresent() || positionalArgs.isEmpty(),
+ Optional<? extends PositionalInfo<?>> positionalInfoOptional = argumentInfo.positionalInfo;
+ checkArgument(positionalInfoOptional.isPresent() || positionalArgs.isEmpty(),
"Positional arguments have been supplied but there is no Arg annotated to received them.");
- if (positionalInfo.isPresent()) {
- PositionalInfo info = positionalInfo.get();
- checkArgDef(parserOracle, info.field, info.positional.parser());
- }
- Iterable<OptionInfo> optionInfos = argumentInfo.optionInfos;
- for (OptionInfo optionInfo : optionInfos) {
- checkArgDef(parserOracle, optionInfo.field, optionInfo.cmdLine);
- }
+ Iterable<? extends OptionInfo<?>> optionInfos = argumentInfo.optionInfos;
final Set<String> argsFailedToParse = Sets.newHashSet();
final Set<String> argsConstraintsFailed = Sets.newHashSet();
- Iterable<String> argShortNames = Iterables.transform(optionInfos,
- Functions.compose(GET_ARG_NAME, GET_CMD_LINE));
+ Iterable<String> argShortNames = Iterables.transform(optionInfos, GET_OPTIONINFO_NAME);
Set<String> argShortNamesNoCollisions = dropCollisions(argShortNames);
Set<String> collisionsDropped = Sets.difference(ImmutableSet.copyOf(argShortNames),
- argShortNamesNoCollisions);
+ argShortNamesNoCollisions);
if (!collisionsDropped.isEmpty()) {
LOG.warning("Found argument name collisions, args must be referenced by canonical names: "
+ collisionsDropped);
}
- Predicate<OptionInfo> isBoolean = Predicates.compose(
- Predicates.<Class>equalTo(Boolean.class),
- Functions.compose(TypeUtil.GET_TYPE_PARAM_CLASS, GET_FIELD));
-
final Map<String, OptionInfo> argsByName =
ImmutableMap.<String, OptionInfo>builder()
// Map by short arg name -> arg def.
.putAll(Maps.uniqueIndex(Iterables.filter(optionInfos,
- Predicates.compose(Predicates.in(argShortNamesNoCollisions), GET_FIELD_ARG_NAME)),
- GET_FIELD_ARG_NAME))
+ Predicates.compose(Predicates.in(argShortNamesNoCollisions), GET_OPTIONINFO_NAME)),
+ GET_OPTIONINFO_NAME))
// Map by canonical arg name -> arg def.
.putAll(Maps.uniqueIndex(optionInfos, GET_CANONICAL_ARG_NAME))
// Map by negated short arg name (for booleans)
- .putAll(Maps.uniqueIndex(Iterables.filter(optionInfos, isBoolean),
- Functions.compose(PREPEND_NEGATION, GET_FIELD_ARG_NAME)))
+ .putAll(Maps.uniqueIndex(Iterables.filter(optionInfos, IS_BOOLEAN),
+ GET_OPTIONINFO_NEGATED_NAME))
// Map by negated canonical arg name (for booleans)
- .putAll(Maps.uniqueIndex(Iterables.filter(optionInfos, isBoolean),
+ .putAll(Maps.uniqueIndex(Iterables.filter(optionInfos, IS_BOOLEAN),
GET_CANONICAL_NEGATED_ARG_NAME))
.build();
@@ -444,82 +399,39 @@ private boolean process(final ParserOracle parserOracle, Verifiers verifiers,
for (String argName : recognizedArgs) {
String argValue = args.get(argName);
OptionInfo optionInfo = argsByName.get(argName);
- Field argField = optionInfo.field;
- Class<? extends Parser> parser = optionInfo.cmdLine.parser();
- Object assignmentValue;
try {
- assignmentValue =
- getParser(parserOracle, parser, argField)
- .parse(parserOracle, TypeUtil.getTypeParam(argField), argValue);
+ optionInfo.load(parserOracle, argName, argValue);
} catch (IllegalArgumentException e) {
argsFailedToParse.add(argName + " - " + e.getMessage());
- continue;
}
-
- // If the arg type is boolean, check if the command line uses the negated boolean form.
- if (TypeUtil.getTypeParamClass(argField) == Boolean.class) {
- Matcher negatedNameMatcher = NEGATED_BOOLEAN_PATTERN.matcher(argName);
- if (negatedNameMatcher.matches()) {
- String argShortName = negatedNameMatcher.group(negatedNameMatcher.groupCount());
- String argCanonicalName = negatedNameMatcher.groupCount() == 2 ?
- negatedNameMatcher.group(1) + argShortName : null;
- if (Iterables.any(argsByName.keySet(),
- Predicates.in(Arrays.asList(argShortName, argCanonicalName)))) {
- assignmentValue = (!(Boolean) assignmentValue);
- }
- }
- }
-
- setField(argField, assignmentValue);
}
- if (positionalInfo.isPresent()) {
- PositionalInfo info = positionalInfo.get();
- final Field argField = info.field;
- Class<? extends Parser> custom = info.positional.parser();
-
- // We're trying to extract T 2 levels down in: Arg<List<T>>
- final Type elementType = TypeToken.extractTypeToken(TypeUtil.getTypeParam(argField));
-
- final Parser<?> parser = getParser(parserOracle, custom, TypeUtil.getRawType(elementType));
- List<?> assignmentValue = Lists.newArrayList(Iterables.transform(positionalArgs,
- new Function<String, Object>() {
- @Override public Object apply(String argValue) {
- return parser.parse(parserOracle, elementType, argValue);
- }
- }));
-
- setField(argField, assignmentValue);
+ if (positionalInfoOptional.isPresent()) {
+ PositionalInfo<?> positionalInfo = positionalInfoOptional.get();
+ positionalInfo.load(parserOracle, positionalArgs);
}
Set<String> commandLineArgumentInfos = Sets.newTreeSet();
- Iterable<Pair<String, Field>> argFields = Iterables.transform(optionInfos,
- new Function<OptionInfo, Pair<String, Field>>() {
- @Override public Pair<String, Field> apply(OptionInfo optionInfo) {
- return Pair.of(optionInfo.cmdLine.name(), optionInfo.field);
- }
- });
- if (positionalInfo.isPresent()){
- PositionalInfo info = positionalInfo.get();
- argFields = Iterables.concat(argFields,
- ImmutableList.of(Pair.of("[positional args]", info.field)));
+ Iterable<? extends ArgumentInfo<?>> allArguments = argumentInfo.optionInfos;
+
+ if (positionalInfoOptional.isPresent()){
+ PositionalInfo<?> positionalInfo = positionalInfoOptional.get();
+ allArguments = Iterables.concat(optionInfos, ImmutableList.of(positionalInfo));
}
- for (Pair<String, Field> argInfo : argFields) {
- Field argField = argInfo.getSecond();
- Arg arg = getArg(argField);
+ for (ArgumentInfo<?> anArgumentInfo : allArguments) {
+ Arg<?> arg = anArgumentInfo.getArg();
- commandLineArgumentInfos.add(String.format("%s (%s.%s): %s",
- argInfo.getFirst(), argField.getDeclaringClass().getName(), argField.getName(),
+ commandLineArgumentInfos.add(String.format("%s (%s): %s",
+ anArgumentInfo.getName(), anArgumentInfo.getCanonicalName(),
arg.uncheckedGet()));
try {
- checkConstraints(verifiers, TypeUtil.getTypeParamClass(argField), arg.uncheckedGet(),
- argField.getAnnotations());
+ anArgumentInfo.verify(verifiers);
} catch (IllegalArgumentException e) {
- argsConstraintsFailed.add(argInfo.getFirst() + " - " + e.getMessage());
+ argsConstraintsFailed.add(anArgumentInfo.getName() + " - " + e.getMessage());
}
}
@@ -556,18 +468,16 @@ private boolean process(final ParserOracle parserOracle, Verifiers verifiers,
};
public static final Ordering<OptionInfo> ORDER_BY_NAME =
- Ordering.natural().onResultOf(GET_FIELD_ARG_NAME);
+ Ordering.natural().onResultOf(GET_OPTIONINFO_NAME);
- private void printHelp(Verifiers verifiers, ArgumentInfo argumentInfo) {
+ private void printHelp(Verifiers verifiers, Args.ArgumentInfo argumentInfo) {
ImmutableList.Builder<String> requiredHelps = ImmutableList.builder();
ImmutableList.Builder<String> optionalHelps = ImmutableList.builder();
- for (OptionInfo optionInfo : ORDER_BY_NAME.immutableSortedCopy(argumentInfo.optionInfos)) {
- Field field = optionInfo.field;
- CmdLine cmdLine = optionInfo.cmdLine;
- Arg arg = getArg(field);
+ for (OptionInfo<?> optionInfo : ORDER_BY_NAME.immutableSortedCopy(argumentInfo.optionInfos)) {
+ Arg<?> arg = optionInfo.getArg();
Object defaultValue = arg.uncheckedGet();
- ImmutableList<String> constraints = collectConstraints(verifiers, field);
- String help = formatHelp(cmdLine, field, constraints, defaultValue);
+ ImmutableList<String> constraints = collectConstraints(verifiers, optionInfo);
+ String help = formatHelp(optionInfo, constraints, defaultValue);
if (!arg.hasDefault()) {
requiredHelps.add(help);
} else {
@@ -577,23 +487,21 @@ private void printHelp(Verifiers verifiers, ArgumentInfo argumentInfo) {
infoLog("-------------------------------------------------------------------------");
infoLog(String.format("%s to print this help message",
- Joiner.on(" or ").join(Iterables.transform(HELP_ARGS, ARG_NAME_TO_FLAG))));
- Optional<PositionalInfo> positionalInfo = argumentInfo.positionalInfo;
- if (positionalInfo.isPresent()) {
+ Joiner.on(" or ").join(Iterables.transform(ArgumentInfo.HELP_ARGS, ARG_NAME_TO_FLAG))));
+ Optional<? extends PositionalInfo<?>> positionalInfoOptional = argumentInfo.positionalInfo;
+ if (positionalInfoOptional.isPresent()) {
infoLog("\nPositional args:");
- PositionalInfo info = positionalInfo.get();
- Field field = info.field;
- Arg arg = getArg(field);
+ PositionalInfo<?> positionalInfo = positionalInfoOptional.get();
+ Arg<?> arg = positionalInfo.getArg();
Object defaultValue = arg.uncheckedGet();
- ImmutableList<String> constraints = collectConstraints(verifiers, field);
- infoLog(String.format("%s%s\n\t%s\n\t(%s.%s)",
+ ImmutableList<String> constraints = collectConstraints(verifiers, positionalInfo);
+ infoLog(String.format("%s%s\n\t%s\n\t(%s)",
defaultValue != null ? "default " + defaultValue : "",
Iterables.isEmpty(constraints)
? ""
: " [" + Joiner.on(", ").join(constraints) + "]",
- info.positional.help(),
- field.getDeclaringClass().getName(),
- field.getName()));
+ positionalInfo.getHelp(),
+ positionalInfo.getCanonicalName()));
}
ImmutableList<String> required = requiredHelps.build();
if (!required.isEmpty()) {
@@ -608,102 +516,27 @@ private void printHelp(Verifiers verifiers, ArgumentInfo argumentInfo) {
infoLog("-------------------------------------------------------------------------");
}
- private ImmutableList<String> collectConstraints(Verifiers verifiers, Field field) {
- Builder<String> constraints = ImmutableList.builder();
- for (Annotation annotation : field.getAnnotations()) {
- Class<?> argType = TypeUtil.getTypeParamClass(field);
- @SuppressWarnings("unchecked")
- Verifier verifier = verifiers.get(argType, annotation);
- if (verifier != null) {
- @SuppressWarnings("unchecked")
- String constraint = verifier.toString(argType, annotation);
- constraints.add(constraint);
- }
- }
- return constraints.build();
+ private ImmutableList<String> collectConstraints(Verifiers verifierOracle,
+ ArgumentInfo<?> argumentInfo) {
+ Builder<String> builder = ImmutableList.builder();
+ argumentInfo.collectConstraints(verifierOracle, builder);
+ return builder.build();
}
- private String formatHelp(CmdLine cmdLine, Field field, Iterable<String> constraints,
+ private String formatHelp(ArgumentInfo<?> argumentInfo, Iterable<String> constraints,
@Nullable Object defaultValue) {
- return String.format("-%s%s%s\n\t%s\n\t(%s.%s)",
- cmdLine.name(),
+ return String.format("-%s%s%s\n\t%s\n\t(%s)",
+ argumentInfo.getName(),
defaultValue != null ? "=" + defaultValue : "",
Iterables.isEmpty(constraints)
? ""
: " [" + Joiner.on(", ").join(constraints) + "]",
- cmdLine.help(),
- field.getDeclaringClass().getName(),
- field.getName());
+ argumentInfo.getHelp(),
+ argumentInfo.getCanonicalName());
}
private void infoLog(String msg) {
out.println(msg);
}
-
- private void checkConstraints(Verifiers verifiers, Class<?> fieldClass, Object value,
- Annotation[] annotations) {
- for (Annotation annotation : maybeFilterNullable(verifiers, fieldClass, value, annotations)) {
- verify(verifiers, fieldClass, value, annotation);
- }
- }
-
- private Iterable<Annotation> maybeFilterNullable(Verifiers verifiers, Class<?> fieldClass,
- Object value, Annotation[] annotations) {
-
- // Apply all the normal constraint annotations
- if (value != null) {
- return Arrays.asList(annotations);
- }
-
- // The value is null so skip verifications unless a @NotNull was specified as a constraint
- for (Annotation annotation: annotations) {
- if (annotation instanceof NotNull) {
- verify(verifiers, fieldClass, value, annotation); // will throw
- }
- }
- return ImmutableList.of();
- }
-
- @SuppressWarnings("unchecked")
- private void verify(Verifiers verifiers, Class<?> fieldClass, Object value,
- Annotation annotation) {
- Verifier verifier = verifiers.get(fieldClass, annotation);
- if (verifier != null) {
- verifier.verify(value, annotation);
- }
- }
-
- private static Parser<?> getParser(ParserOracle parserOracle, Class<? extends Parser> custom,
- Field argField) {
-
- Preconditions.checkArgument(argField.getType() == Arg.class,
- "Field is annotated for argument parsing but is not of Arg type: " + argField);
- return getParser(parserOracle, custom, TypeUtil.getTypeParamClass(argField));
- }
-
- private static Parser<?> getParser(ParserOracle parserOracle, Class<? extends Parser> custom,
- Class<?> cls) {
- try {
- return (custom == Parser.class) ? parserOracle.get(cls) : custom.newInstance();
- } catch (InstantiationException e) {
- throw new RuntimeException("Failed to instantiate parser " + custom);
- } catch (IllegalAccessException e) {
- throw new RuntimeException("No access to instantiate parser " + custom);
- }
- }
-
- @SuppressWarnings("unchecked")
- private static void setField(Field field, Object value) {
- getArg(field).set(value);
- }
-
- private static Arg getArg(Field field) {
- field.setAccessible(true);
- try {
- return ((Arg) field.get(null));
- } catch (IllegalAccessException e) {
- throw new RuntimeException("Failed to set value for " + field);
- }
- }
}
View
60 src/java/com/twitter/common/args/Args.java
@@ -44,25 +44,25 @@
}
};
- private static final Function<Field, OptionInfo> TO_OPTIONINFO =
- new Function<Field, OptionInfo>() {
- @Override public OptionInfo apply(Field field) {
- CmdLine cmdLineDef = field.getAnnotation(CmdLine.class);
- if (cmdLineDef == null) {
+ private static final Function<Field, OptionInfo<?>> TO_OPTIONINFO =
+ new Function<Field, OptionInfo<?>>() {
+ @Override public OptionInfo<?> apply(Field field) {
+ CmdLine cmdLine = field.getAnnotation(CmdLine.class);
+ if (cmdLine == null) {
throw new ConfigurationException("No @CmdLine Arg annotation for field " + field);
}
- return new OptionInfo(cmdLineDef, field);
+ return OptionInfo.createFromField(field);
}
};
- private static final Function<Field, PositionalInfo> TO_POSITIONALINFO =
- new Function<Field, PositionalInfo>() {
- @Override public PositionalInfo apply(Field field) {
+ private static final Function<Field, PositionalInfo<?>> TO_POSITIONALINFO =
+ new Function<Field, PositionalInfo<?>>() {
+ @Override public PositionalInfo<?> apply(Field field) {
Positional positional = field.getAnnotation(Positional.class);
if (positional == null) {