buildr-gemjar 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (252) hide show
  1. data/.braids +8 -0
  2. data/.gitignore +5 -0
  3. data/.rvmrc +1 -0
  4. data/CHANGELOG.md +4 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE +20 -0
  7. data/README.md +98 -0
  8. data/Rakefile +8 -0
  9. data/buildr-gemjar.gemspec +42 -0
  10. data/lib/buildr-gemjar.rb +162 -0
  11. data/lib/buildr-gemjar/version.rb +3 -0
  12. data/meta.rakefile +30 -0
  13. data/spec/buildr-gemjar/version_spec.rb +11 -0
  14. data/spec/buildr-gemjar_spec.rb +179 -0
  15. data/spec/repo_builder.rb +59 -0
  16. data/spec/spec_helper.rb +44 -0
  17. data/vendor/buildr/.gitignore +17 -0
  18. data/vendor/buildr/CHANGELOG +1283 -0
  19. data/vendor/buildr/Gemfile +4 -0
  20. data/vendor/buildr/LICENSE +176 -0
  21. data/vendor/buildr/NOTICE +26 -0
  22. data/vendor/buildr/README.rdoc +134 -0
  23. data/vendor/buildr/Rakefile +44 -0
  24. data/vendor/buildr/_buildr +35 -0
  25. data/vendor/buildr/_jbuildr +35 -0
  26. data/vendor/buildr/addon/buildr/antlr.rb +65 -0
  27. data/vendor/buildr/addon/buildr/bnd.rb +147 -0
  28. data/vendor/buildr/addon/buildr/cobertura.rb +22 -0
  29. data/vendor/buildr/addon/buildr/drb.rb +281 -0
  30. data/vendor/buildr/addon/buildr/emma.rb +22 -0
  31. data/vendor/buildr/addon/buildr/hibernate.rb +149 -0
  32. data/vendor/buildr/addon/buildr/javacc.rb +85 -0
  33. data/vendor/buildr/addon/buildr/jaxb_xjc.rb +72 -0
  34. data/vendor/buildr/addon/buildr/jdepend.rb +60 -0
  35. data/vendor/buildr/addon/buildr/jetty.rb +248 -0
  36. data/vendor/buildr/addon/buildr/jibx.rb +86 -0
  37. data/vendor/buildr/addon/buildr/nailgun.rb +221 -0
  38. data/vendor/buildr/addon/buildr/openjpa.rb +88 -0
  39. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  40. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  41. data/vendor/buildr/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
  42. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  43. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  44. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  45. data/vendor/buildr/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
  46. data/vendor/buildr/addon/buildr/protobuf.rb +88 -0
  47. data/vendor/buildr/addon/buildr/xmlbeans.rb +93 -0
  48. data/vendor/buildr/all-in-one/_buildr +19 -0
  49. data/vendor/buildr/all-in-one/buildr +368 -0
  50. data/vendor/buildr/all-in-one/buildr.cmd +1 -0
  51. data/vendor/buildr/bin/buildr +19 -0
  52. data/vendor/buildr/buildr.buildfile +58 -0
  53. data/vendor/buildr/buildr.gemspec +74 -0
  54. data/vendor/buildr/doc/_config.yml +1 -0
  55. data/vendor/buildr/doc/_layouts/default.html +90 -0
  56. data/vendor/buildr/doc/_layouts/preface.html +22 -0
  57. data/vendor/buildr/doc/artifacts.textile +217 -0
  58. data/vendor/buildr/doc/building.textile +276 -0
  59. data/vendor/buildr/doc/contributing.textile +268 -0
  60. data/vendor/buildr/doc/css/default.css +236 -0
  61. data/vendor/buildr/doc/css/print.css +101 -0
  62. data/vendor/buildr/doc/css/syntax.css +23 -0
  63. data/vendor/buildr/doc/download.textile +138 -0
  64. data/vendor/buildr/doc/extending.textile +212 -0
  65. data/vendor/buildr/doc/images/1442160941-frontcover.jpg +0 -0
  66. data/vendor/buildr/doc/images/asf-logo.gif +0 -0
  67. data/vendor/buildr/doc/images/asf-logo.png +0 -0
  68. data/vendor/buildr/doc/images/buildr-hires.png +0 -0
  69. data/vendor/buildr/doc/images/buildr.png +0 -0
  70. data/vendor/buildr/doc/images/favicon.png +0 -0
  71. data/vendor/buildr/doc/images/growl-icon.tiff +0 -0
  72. data/vendor/buildr/doc/images/note.png +0 -0
  73. data/vendor/buildr/doc/images/project-structure.png +0 -0
  74. data/vendor/buildr/doc/images/tip.png +0 -0
  75. data/vendor/buildr/doc/images/zbuildr.png +0 -0
  76. data/vendor/buildr/doc/images/zbuildr.tif +0 -0
  77. data/vendor/buildr/doc/index.textile +69 -0
  78. data/vendor/buildr/doc/installing.textile +284 -0
  79. data/vendor/buildr/doc/languages.textile +599 -0
  80. data/vendor/buildr/doc/mailing_lists.textile +29 -0
  81. data/vendor/buildr/doc/more_stuff.textile +845 -0
  82. data/vendor/buildr/doc/packaging.textile +618 -0
  83. data/vendor/buildr/doc/preface.textile +54 -0
  84. data/vendor/buildr/doc/projects.textile +276 -0
  85. data/vendor/buildr/doc/quick_start.textile +210 -0
  86. data/vendor/buildr/doc/releasing.textile +117 -0
  87. data/vendor/buildr/doc/scripts/buildr-git.rb +512 -0
  88. data/vendor/buildr/doc/scripts/gitflow.rb +296 -0
  89. data/vendor/buildr/doc/scripts/install-jruby.sh +44 -0
  90. data/vendor/buildr/doc/scripts/install-linux.sh +73 -0
  91. data/vendor/buildr/doc/scripts/install-osx.sh +52 -0
  92. data/vendor/buildr/doc/settings_profiles.textile +287 -0
  93. data/vendor/buildr/doc/testing.textile +247 -0
  94. data/vendor/buildr/etc/KEYS +189 -0
  95. data/vendor/buildr/lib/buildr.rb +44 -0
  96. data/vendor/buildr/lib/buildr/clojure.rb +34 -0
  97. data/vendor/buildr/lib/buildr/clojure/shell.rb +52 -0
  98. data/vendor/buildr/lib/buildr/core.rb +34 -0
  99. data/vendor/buildr/lib/buildr/core/application.rb +700 -0
  100. data/vendor/buildr/lib/buildr/core/build.rb +516 -0
  101. data/vendor/buildr/lib/buildr/core/cc.rb +166 -0
  102. data/vendor/buildr/lib/buildr/core/checks.rb +253 -0
  103. data/vendor/buildr/lib/buildr/core/common.rb +151 -0
  104. data/vendor/buildr/lib/buildr/core/compile.rb +622 -0
  105. data/vendor/buildr/lib/buildr/core/doc.rb +276 -0
  106. data/vendor/buildr/lib/buildr/core/environment.rb +129 -0
  107. data/vendor/buildr/lib/buildr/core/filter.rb +404 -0
  108. data/vendor/buildr/lib/buildr/core/generate.rb +197 -0
  109. data/vendor/buildr/lib/buildr/core/help.rb +119 -0
  110. data/vendor/buildr/lib/buildr/core/jrebel.rb +42 -0
  111. data/vendor/buildr/lib/buildr/core/linux.rb +30 -0
  112. data/vendor/buildr/lib/buildr/core/osx.rb +46 -0
  113. data/vendor/buildr/lib/buildr/core/progressbar.rb +161 -0
  114. data/vendor/buildr/lib/buildr/core/project.rb +975 -0
  115. data/vendor/buildr/lib/buildr/core/run.rb +43 -0
  116. data/vendor/buildr/lib/buildr/core/shell.rb +137 -0
  117. data/vendor/buildr/lib/buildr/core/test.rb +843 -0
  118. data/vendor/buildr/lib/buildr/core/transports.rb +565 -0
  119. data/vendor/buildr/lib/buildr/core/util.rb +537 -0
  120. data/vendor/buildr/lib/buildr/groovy.rb +20 -0
  121. data/vendor/buildr/lib/buildr/groovy/bdd.rb +106 -0
  122. data/vendor/buildr/lib/buildr/groovy/compiler.rb +153 -0
  123. data/vendor/buildr/lib/buildr/groovy/doc.rb +76 -0
  124. data/vendor/buildr/lib/buildr/groovy/shell.rb +57 -0
  125. data/vendor/buildr/lib/buildr/ide.rb +19 -0
  126. data/vendor/buildr/lib/buildr/ide/eclipse.rb +427 -0
  127. data/vendor/buildr/lib/buildr/ide/eclipse/java.rb +53 -0
  128. data/vendor/buildr/lib/buildr/ide/eclipse/plugin.rb +71 -0
  129. data/vendor/buildr/lib/buildr/ide/eclipse/scala.rb +68 -0
  130. data/vendor/buildr/lib/buildr/ide/idea.rb +576 -0
  131. data/vendor/buildr/lib/buildr/java.rb +25 -0
  132. data/vendor/buildr/lib/buildr/java/ant.rb +94 -0
  133. data/vendor/buildr/lib/buildr/java/bdd.rb +460 -0
  134. data/vendor/buildr/lib/buildr/java/cobertura.rb +297 -0
  135. data/vendor/buildr/lib/buildr/java/commands.rb +223 -0
  136. data/vendor/buildr/lib/buildr/java/compiler.rb +135 -0
  137. data/vendor/buildr/lib/buildr/java/deprecated.rb +141 -0
  138. data/vendor/buildr/lib/buildr/java/doc.rb +86 -0
  139. data/vendor/buildr/lib/buildr/java/ecj.rb +69 -0
  140. data/vendor/buildr/lib/buildr/java/emma.rb +244 -0
  141. data/vendor/buildr/lib/buildr/java/external.rb +73 -0
  142. data/vendor/buildr/lib/buildr/java/jruby.rb +122 -0
  143. data/vendor/buildr/lib/buildr/java/jtestr_result.rb +295 -0
  144. data/vendor/buildr/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  145. data/vendor/buildr/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  146. data/vendor/buildr/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +142 -0
  147. data/vendor/buildr/lib/buildr/java/packaging.rb +734 -0
  148. data/vendor/buildr/lib/buildr/java/pom.rb +178 -0
  149. data/vendor/buildr/lib/buildr/java/rjb.rb +154 -0
  150. data/vendor/buildr/lib/buildr/java/test_result.rb +101 -0
  151. data/vendor/buildr/lib/buildr/java/tests.rb +362 -0
  152. data/vendor/buildr/lib/buildr/java/version_requirement.rb +172 -0
  153. data/vendor/buildr/lib/buildr/packaging.rb +25 -0
  154. data/vendor/buildr/lib/buildr/packaging/archive.rb +535 -0
  155. data/vendor/buildr/lib/buildr/packaging/artifact.rb +903 -0
  156. data/vendor/buildr/lib/buildr/packaging/artifact_namespace.rb +984 -0
  157. data/vendor/buildr/lib/buildr/packaging/artifact_search.rb +140 -0
  158. data/vendor/buildr/lib/buildr/packaging/gems.rb +105 -0
  159. data/vendor/buildr/lib/buildr/packaging/package.rb +249 -0
  160. data/vendor/buildr/lib/buildr/packaging/tar.rb +189 -0
  161. data/vendor/buildr/lib/buildr/packaging/version_requirement.rb +192 -0
  162. data/vendor/buildr/lib/buildr/packaging/zip.rb +178 -0
  163. data/vendor/buildr/lib/buildr/packaging/ziptask.rb +356 -0
  164. data/vendor/buildr/lib/buildr/resources/buildr.icns +0 -0
  165. data/vendor/buildr/lib/buildr/resources/completed.png +0 -0
  166. data/vendor/buildr/lib/buildr/resources/failed.png +0 -0
  167. data/vendor/buildr/lib/buildr/resources/icons-license.txt +17 -0
  168. data/vendor/buildr/lib/buildr/run.rb +195 -0
  169. data/vendor/buildr/lib/buildr/scala.rb +26 -0
  170. data/vendor/buildr/lib/buildr/scala/bdd.rb +118 -0
  171. data/vendor/buildr/lib/buildr/scala/compiler.rb +242 -0
  172. data/vendor/buildr/lib/buildr/scala/doc.rb +142 -0
  173. data/vendor/buildr/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  174. data/vendor/buildr/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  175. data/vendor/buildr/lib/buildr/scala/shell.rb +52 -0
  176. data/vendor/buildr/lib/buildr/scala/tests.rb +171 -0
  177. data/vendor/buildr/lib/buildr/shell.rb +185 -0
  178. data/vendor/buildr/lib/buildr/version.rb +18 -0
  179. data/vendor/buildr/rakelib/all-in-one.rake +113 -0
  180. data/vendor/buildr/rakelib/checks.rake +57 -0
  181. data/vendor/buildr/rakelib/doc.rake +137 -0
  182. data/vendor/buildr/rakelib/metrics.rake +39 -0
  183. data/vendor/buildr/rakelib/package.rake +73 -0
  184. data/vendor/buildr/rakelib/release.rake +161 -0
  185. data/vendor/buildr/rakelib/rspec.rake +101 -0
  186. data/vendor/buildr/rakelib/setup.rake +66 -0
  187. data/vendor/buildr/rakelib/stage.rake +220 -0
  188. data/vendor/buildr/spec/addon/bnd_spec.rb +330 -0
  189. data/vendor/buildr/spec/addon/drb_spec.rb +328 -0
  190. data/vendor/buildr/spec/addon/jaxb_xjc_spec.rb +125 -0
  191. data/vendor/buildr/spec/core/application_spec.rb +631 -0
  192. data/vendor/buildr/spec/core/build_spec.rb +837 -0
  193. data/vendor/buildr/spec/core/cc_spec.rb +224 -0
  194. data/vendor/buildr/spec/core/checks_spec.rb +519 -0
  195. data/vendor/buildr/spec/core/common_spec.rb +725 -0
  196. data/vendor/buildr/spec/core/compile_spec.rb +658 -0
  197. data/vendor/buildr/spec/core/doc_spec.rb +195 -0
  198. data/vendor/buildr/spec/core/extension_spec.rb +201 -0
  199. data/vendor/buildr/spec/core/generate_spec.rb +33 -0
  200. data/vendor/buildr/spec/core/project_spec.rb +772 -0
  201. data/vendor/buildr/spec/core/run_spec.rb +93 -0
  202. data/vendor/buildr/spec/core/shell_spec.rb +146 -0
  203. data/vendor/buildr/spec/core/test_spec.rb +1320 -0
  204. data/vendor/buildr/spec/core/transport_spec.rb +544 -0
  205. data/vendor/buildr/spec/core/util_spec.rb +141 -0
  206. data/vendor/buildr/spec/groovy/bdd_spec.rb +80 -0
  207. data/vendor/buildr/spec/groovy/compiler_spec.rb +251 -0
  208. data/vendor/buildr/spec/groovy/doc_spec.rb +65 -0
  209. data/vendor/buildr/spec/ide/eclipse_spec.rb +739 -0
  210. data/vendor/buildr/spec/ide/idea_spec.rb +1144 -0
  211. data/vendor/buildr/spec/java/ant_spec.rb +37 -0
  212. data/vendor/buildr/spec/java/bdd_spec.rb +374 -0
  213. data/vendor/buildr/spec/java/cobertura_spec.rb +112 -0
  214. data/vendor/buildr/spec/java/commands_spec.rb +93 -0
  215. data/vendor/buildr/spec/java/compiler_spec.rb +252 -0
  216. data/vendor/buildr/spec/java/doc_spec.rb +56 -0
  217. data/vendor/buildr/spec/java/ecj_spec.rb +115 -0
  218. data/vendor/buildr/spec/java/emma_spec.rb +121 -0
  219. data/vendor/buildr/spec/java/external_spec.rb +56 -0
  220. data/vendor/buildr/spec/java/java_spec.rb +132 -0
  221. data/vendor/buildr/spec/java/packaging_spec.rb +1270 -0
  222. data/vendor/buildr/spec/java/run_spec.rb +78 -0
  223. data/vendor/buildr/spec/java/test_coverage_helper.rb +257 -0
  224. data/vendor/buildr/spec/java/tests_spec.rb +497 -0
  225. data/vendor/buildr/spec/packaging/archive_spec.rb +775 -0
  226. data/vendor/buildr/spec/packaging/artifact_namespace_spec.rb +743 -0
  227. data/vendor/buildr/spec/packaging/artifact_spec.rb +1066 -0
  228. data/vendor/buildr/spec/packaging/packaging_helper.rb +63 -0
  229. data/vendor/buildr/spec/packaging/packaging_spec.rb +719 -0
  230. data/vendor/buildr/spec/sandbox.rb +165 -0
  231. data/vendor/buildr/spec/scala/bdd_spec.rb +124 -0
  232. data/vendor/buildr/spec/scala/compiler_spec.rb +289 -0
  233. data/vendor/buildr/spec/scala/doc_spec.rb +88 -0
  234. data/vendor/buildr/spec/scala/scala.rb +38 -0
  235. data/vendor/buildr/spec/scala/tests_spec.rb +283 -0
  236. data/vendor/buildr/spec/spec_helpers.rb +369 -0
  237. data/vendor/buildr/spec/version_requirement_spec.rb +143 -0
  238. data/vendor/buildr/spec/xpath_matchers.rb +121 -0
  239. data/vendor/buildr/tests/BUILDR-320/Buildfile +29 -0
  240. data/vendor/buildr/tests/JavaSystemProperty/Buildfile +18 -0
  241. data/vendor/buildr/tests/JavaSystemProperty/src/test/java/FooTest.java +24 -0
  242. data/vendor/buildr/tests/compile_with_parent/Buildfile +18 -0
  243. data/vendor/buildr/tests/compile_with_parent/child/src/main/java/Foo.java +23 -0
  244. data/vendor/buildr/tests/helloWorld/Buildfile +20 -0
  245. data/vendor/buildr/tests/helloWorld/src/main/java/HelloWorld.java +23 -0
  246. data/vendor/buildr/tests/integration_testing.rb +56 -0
  247. data/vendor/buildr/tests/junit3/Buildfile +9 -0
  248. data/vendor/buildr/tests/junit3/src/main/java/Foo.java +23 -0
  249. data/vendor/buildr/tests/junit3/src/test/java/FooTest.java +28 -0
  250. data/vendor/buildr/tests/package_war_as_jar/Buildfile +15 -0
  251. data/vendor/buildr/tests/package_war_as_jar/src/main/java/Foo.java +19 -0
  252. metadata +524 -0
@@ -0,0 +1,296 @@
1
+ #!/usr/bin/env ruby
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with this
4
+ # work for additional information regarding copyright ownership. The ASF
5
+ # licenses this file to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+
17
+ require 'optparse'
18
+ require 'ostruct'
19
+ require 'fileutils'
20
+
21
+ module GitFlow
22
+ extend self
23
+
24
+ attr_accessor :should_run, :trace, :program
25
+
26
+ self.program = 'gitflow'
27
+ self.should_run = true # should we run at exit?
28
+
29
+ HELP = <<-HELP
30
+
31
+ GitFlow is a tool to create custom git commands implemented in ruby.
32
+ It is generic enougth to be used on any git based project besides Apache Buildr.
33
+
34
+ OVERVIEW:
35
+
36
+ gitflow is intended to help developers with their daily git workflow,
37
+ performing repetitive git commands for them. It is implemented in
38
+ ruby so you can do anything, from invoking rake tasks to telling
39
+ people on twitter you are having trouble with their code :P.
40
+
41
+ To get help for a specific command use:
42
+ gitflow.rb help command
43
+ gitflow.rb command --help
44
+
45
+ For convenience you can create an alias to be execute using git.
46
+ The following example registers buildr-git.rb, which provides apache
47
+ svn and git synchronization commands:
48
+
49
+ git config alias.apache '!'"ruby $PWD/doc/scripts/buildr-git.rb"
50
+
51
+ After that you can use
52
+ git apache command --help
53
+
54
+ EXTENDING YOUR WORKFLOW:
55
+
56
+ You can create your own gitflow commands, to adapt your development
57
+ workflow.
58
+
59
+ Simply create a ruby script somewhere say ~/.buildr/gitflow.rb
60
+ And alias it in your local repo:
61
+
62
+ git config alias.flow '!'"ruby ~/.buildr/gitflow.rb"
63
+ git config alias.work '!'"ruby ~/.buildr/gitflow.rb my-flow sub-work"
64
+
65
+ A sample command would look like this.. (you may want to look at buildr-git.rb)
66
+
67
+ #!/usr/bin/env ruby
68
+ require /path/to/gitflow.rb
69
+
70
+ class MyCommand < GitFlow/'my-flow'
71
+
72
+ @help = "Summary to be displayed when listing commands"
73
+ @documentation = "Very long help that will be paged if necessary. (for --help)"
74
+
75
+ # takes an openstruct to place default values and option values.
76
+ # returns an array of arguments given to optparse.on
77
+ def options(opts)
78
+ opts.something = 'default'
79
+ [
80
+ ['--name NAME', lambda { |n| opts.name = n }],
81
+ ['--yes', lambda { |n| opts.yes = true }]
82
+ ]
83
+ end
84
+
85
+ # takes the opts openstruct after options have been parsed and
86
+ # an argv array with non-option arguments.
87
+ def execute(opts, argv)
88
+ # you can run another command using
89
+ run('other-command', '--using-this', 'arg')
90
+ some = git('config', '--get', 'some.property').chomp rescue nil
91
+ page { puts "This will be paged on terminal if needed" }
92
+ end
93
+
94
+ class SubCommand < MyCommand/'sub-work'
95
+ ... # implement a subcommand
96
+ end
97
+
98
+ end
99
+
100
+ You would then get help for your command with
101
+
102
+ git flow my-flow --help
103
+ git work --help
104
+
105
+ Using gitflow you can customize per-project git interface.
106
+
107
+ HELP
108
+
109
+ # Pager from http://nex-3.com/posts/73-git-style-automatic-paging-in-ruby
110
+ def pager
111
+ return if RUBY_PLATFORM =~ /win32/
112
+ return unless STDOUT.tty?
113
+
114
+ read, write = IO.pipe
115
+
116
+ unless Kernel.fork # Child process
117
+ STDOUT.reopen(write)
118
+ STDERR.reopen(write) if STDERR.tty?
119
+ read.close
120
+ write.close
121
+ return
122
+ end
123
+
124
+ # Parent process, become pager
125
+ STDIN.reopen(read)
126
+ read.close
127
+ write.close
128
+
129
+ ENV['LESS'] = 'FSRX' # Don't page if the input is short enough
130
+
131
+ Kernel.select [STDIN] # Wait until we have input before we start the pager
132
+ pager = ENV['PAGER'] || 'less'
133
+ exec pager rescue exec '/bin/sh', '-c', pager
134
+ end
135
+
136
+ # Return a class to be extended in order to register a GitFlow command
137
+ # if command name is nil, it will be registered as the top level command.
138
+ # Classes implementing commands also provide this method, allowing for
139
+ # sub-command creation.
140
+ def /(command_name)
141
+ command_name = command_name.to_s unless command_name.nil?
142
+ cls = Class.new { include GitFlow::Mixin }
143
+ (class << cls; self; end).module_eval do
144
+ attr_accessor :help, :documentation, :command
145
+ define_method(:/) do |subcommand|
146
+ raise "Subcommand cannot be nil" unless subcommand
147
+ GitFlow/([command_name, subcommand].compact.join(' '))
148
+ end
149
+ define_method(:inherited) do |subclass|
150
+ subclass.command = command_name
151
+ GitFlow.commands[command_name] = subclass
152
+ end
153
+ end
154
+ cls
155
+ end
156
+
157
+ def commands
158
+ @commands ||= Hash.new
159
+ end
160
+
161
+ def optparse
162
+ optparse = opt = OptionParser.new
163
+ opt.separator ' '
164
+ opt.separator 'OPTIONS'
165
+ opt.separator ' '
166
+ opt.on('-h', '--help', 'Display this help') do
167
+ GitFlow.pager; puts opt; throw :exit
168
+ end
169
+ opt.on('--trace', 'Display traces') { GitFlow.trace = true }
170
+ optparse
171
+ end
172
+
173
+ def command(argv)
174
+ cmds = []
175
+ argv.each_with_index do |arg, i|
176
+ arg = argv[0..i].join(' ')
177
+ cmds << commands[arg] if commands.key?(arg)
178
+ end
179
+ cmds.last || commands[nil]
180
+ end
181
+
182
+ def run(*argv)
183
+ catch :exit do
184
+ command = self.command(argv).new
185
+ argv = argv[command.class.command.split.length..-1] if command.class.command
186
+ parser = optparse
187
+ parser.banner = "Usage: #{GitFlow.program} #{command.class.command} [options]"
188
+ options = OpenStruct.new
189
+ if command.respond_to?(:options)
190
+ command.options(options).each { |args| parser.on(*args) }
191
+ end
192
+ if command.class.documentation && command.class.documentation != ''
193
+ parser.separator ' '
194
+ parser.separator command.class.documentation.split(/\n/)
195
+ end
196
+ parser.parse!(argv)
197
+ command.execute(options, argv)
198
+ end
199
+ end
200
+
201
+ module Mixin
202
+ include FileUtils
203
+
204
+ # Override this method in your command class if it
205
+ # needs to parse command line options.
206
+ #
207
+ # This method takes an openstruct object as argument
208
+ # allowing you to store default values on it, and
209
+ # set option values.
210
+ #
211
+ # The return value must be an array of arguments
212
+ # given to optparse.on
213
+ def options(opt)
214
+ []
215
+ end
216
+
217
+ # Override this method in your command class to implement
218
+ # the command.
219
+ # First argument is the openstruct object after
220
+ # it has been populated by the option parser.
221
+ # Second argument is the array of non-option arguments.
222
+ def execute(opt, argv)
223
+ fail "#{self.class.command} not implemented"
224
+ end
225
+
226
+ # Run the command line given on argv
227
+ def run(*argv, &block)
228
+ GitFlow.run(*argv, &block)
229
+ end
230
+
231
+ # Yield paging the blocks output if necessary.
232
+ def page
233
+ GitFlow.pager
234
+ yield
235
+ end
236
+
237
+ def trace(*str)
238
+ STDERR.puts(*str) if GitFlow.trace
239
+ end
240
+
241
+ def git(*args)
242
+ cmd = 'git ' + args.map { |arg| arg[' '] ? %Q{"#{arg}"} : arg }.join(' ')
243
+ trace cmd
244
+ `#{cmd}`.tap {
245
+ fail "GIT command `#{cmd}` failed with status #{$?.exitstatus}" unless $?.exitstatus == 0
246
+ }
247
+ end
248
+
249
+ def sh(*args)
250
+ `#{args.join(' ')}`.tap {
251
+ fail "Shell command `#{args.join(' ')}` failed with status #{$?.exitstatus}" unless $?.exitstatus == 0
252
+ }
253
+ end
254
+
255
+ def expand_path(path, dir=Dir.pwd)
256
+ File.expand_path(path, dir)
257
+ end
258
+ end
259
+
260
+ class NoSuchCommand < GitFlow/nil
261
+ @documentation = HELP
262
+
263
+ def execute(opts, argv)
264
+ page do
265
+ puts "Command not found: #{argv.join(' ').inspect}"
266
+ puts "Try `#{GitFlow.program} help` to obtain a list of commands."
267
+ end
268
+ end
269
+ end
270
+
271
+ class HelpCommand < GitFlow/:help
272
+ @help = "Display help for a command or show command list"
273
+ @documentation = "Displays help for the command given as argument"
274
+
275
+ def execute(opts, argv)
276
+ if argv.empty?
277
+ opt = GitFlow.optparse
278
+ opt.banner = "Usage: #{GitFlow.program} command [options]"
279
+ opt.separator ' '
280
+ opt.separator 'COMMANDS'
281
+ opt.separator ' '
282
+ commands = GitFlow.commands.map { |name, cls| [nil, name, cls.help] }.
283
+ sort_by { |a| a[1] || '' }
284
+ commands.each { |a| opt.separator("%-2s%-25s%s" % a) if a[1] }
285
+ opt.separator ' '
286
+ opt.separator 'You can also obtain help for any command giving it --help.'
287
+ page { puts opt }
288
+ else
289
+ run(*(argv + ['--help']))
290
+ end
291
+ end
292
+ end
293
+
294
+ end
295
+
296
+ at_exit { GitFlow.run(*ARGV) if GitFlow.should_run }
@@ -0,0 +1,44 @@
1
+ #!/bin/sh
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with this
4
+ # work for additional information regarding copyright ownership. The ASF
5
+ # licenses this file to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+ if [ -z `which jruby` ] ; then
17
+ version=1.1.6
18
+ target=/opt/jruby
19
+ echo "Installing JRuby ${version} in ${target}"
20
+ sudo mkdir -p $(dirname ${target})
21
+ wget http://dist.codehaus.org/jruby/${version}/jruby-bin-${version}.tar.gz
22
+ tar -xz < jruby-bin-${version}.tar.gz
23
+ sudo mv jruby-${version} ${target}
24
+ rm jruby-bin-${version}.tar.gz
25
+ export PATH=$PATH:${target}
26
+ if [ -e ~/.bash_profile ] ; then
27
+ echo "export PATH=${target}/bin:\$PATH" >> ~/.bash_profile
28
+ elif [ -e ~/.profile ] ; then
29
+ echo "export PATH=${target}/bin:\$PATH" >> ~/.profile
30
+ else
31
+ echo "You need to add ${target}/bin to the PATH"
32
+ fi
33
+ fi
34
+
35
+ if [ `which buildr` ] ; then
36
+ echo "Updating to the latest version of Buildr"
37
+ sudo jruby -S gem update buildr
38
+ else
39
+ echo "Installing the latest version of Buildr"
40
+ sudo jruby -S gem install buildr
41
+ fi
42
+ echo
43
+
44
+ jruby -S buildr --version
@@ -0,0 +1,73 @@
1
+ #!/bin/sh
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with this
4
+ # work for additional information regarding copyright ownership. The ASF
5
+ # licenses this file to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+ if [ -z `which ruby` ] ; then
17
+ echo "You do not have Ruby 1.8.6 ..."
18
+ # yum comes first since some people have apt-get installed in addition to yum.
19
+ # urpmi is added in case of mandriva : apt-get or yum are working for mandriva too
20
+ if [ `which yum` ] ; then
21
+ echo "Installing Ruby using yum"
22
+ sudo yum install ruby rubygems ruby-devel gcc
23
+ elif [ `which apt-get` ] ; then
24
+ echo "Installing Ruby using apt-get"
25
+ # ruby package does not contain RDoc, IRB, etc; ruby-full is a meta-package.
26
+ # build-essentials not installed by default in Ubuntu, required for C extensions.
27
+ sudo apt-get install ruby-full ruby1.8-dev libopenssl-ruby build-essential
28
+ # RubyGems broken on Ubuntu, installing directly from source.
29
+ echo "Installing RubyGems from RubyForge"
30
+ wget http://production.cf.rubygems.org/rubygems/rubygems-1.3.7.tgz
31
+ tar xzf rubygems-1.3.7.tgz
32
+ cd rubygems-1.3.7
33
+ sudo ruby setup.rb
34
+ cd ..
35
+ rm -rf rubygems-1.3.7
36
+ # ruby is same as ruby1.8, we need gem that is same as gem1.8
37
+ sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
38
+ elif [ `which urpmi` ] ; then
39
+ echo "Installing Ruby using urpmi"
40
+ sudo urpmi ruby rubygems ruby-devel gcc
41
+ if [ $? -ne 0 ] ; then
42
+ echo "URPMI install error"
43
+ exit 1
44
+ fi
45
+ else
46
+ echo "Can only install Ruby 1.8.6 using apt-get, yum or urpmi, and can't find any of them"
47
+ exit 1
48
+ fi
49
+ echo
50
+ fi
51
+
52
+ if [ -z $JAVA_HOME ] ; then
53
+ echo "Please set JAVA_HOME before proceeding"
54
+ exit 1
55
+ fi
56
+
57
+ if [ $(gem --version) \< '1.3.7' ] ; then
58
+ echo "Upgrading to latest version of RubyGems"
59
+ sudo gem update --system
60
+ sudo update_rubygems
61
+ echo
62
+ fi
63
+
64
+ if [ `which buildr` ] ; then
65
+ echo "Updating to the latest version of Buildr"
66
+ sudo env JAVA_HOME=$JAVA_HOME gem update buildr
67
+ else
68
+ echo "Installing the latest version of Buildr"
69
+ sudo env JAVA_HOME=$JAVA_HOME gem install buildr
70
+ fi
71
+ echo
72
+
73
+ buildr --version
@@ -0,0 +1,52 @@
1
+ #!/bin/sh
2
+ # Licensed to the Apache Software Foundation (ASF) under one or more
3
+ # contributor license agreements. See the NOTICE file distributed with this
4
+ # work for additional information regarding copyright ownership. The ASF
5
+ # licenses this file to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ # License for the specific language governing permissions and limitations under
15
+ # the License.
16
+ version=$(ruby --version)
17
+ if [ ${version:5:5} \< '1.8.6' ] ; then
18
+ echo "You do not have Ruby 1.8.6 or later, attempting to install a newer version."
19
+ if [ `which port` ] ; then
20
+ echo "Installing Ruby using MacPorts"
21
+ sudo port install ruby rb-rubygems
22
+ elif [ `which fink` ] ; then
23
+ echo "Installing Ruby using Fink"
24
+ sudo fink install ruby ruby18-dev rubygems-rb18
25
+ else
26
+ echo "Can only upgrade to Ruby 1.8.6 using either MacPorts or Fink, and can't find either one"
27
+ exit 1
28
+ fi
29
+ echo
30
+ fi
31
+
32
+ if [ -z $JAVA_HOME ] ; then
33
+ echo "Setting JAVA_HOME"
34
+ export JAVA_HOME=/Library/Java/Home
35
+ fi
36
+
37
+ if [ $(gem --version) \< '1.3.1' ] ; then
38
+ echo "Upgrading to latest version of RubyGems"
39
+ sudo gem update --system
40
+ echo
41
+ fi
42
+
43
+ if [ `which buildr` ] ; then
44
+ echo "Updating to the latest version of Buildr"
45
+ sudo env JAVA_HOME=$JAVA_HOME gem update buildr
46
+ else
47
+ echo "Installing the latest version of Buildr"
48
+ sudo env JAVA_HOME=$JAVA_HOME gem install buildr
49
+ fi
50
+ echo
51
+
52
+ buildr --version