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,117 @@
1
+ ---
2
+ layout: default
3
+ title: Releasing
4
+ ---
5
+
6
+ Now that we built and tested our awesome software, let's tell the world and release it.
7
+
8
+ Each buildfile can specify the current version with a constant named @VERSION_NUMBER@ or @THIS_VERSION@.
9
+
10
+ {% highlight ruby %}
11
+ THIS_VERSION = "1.0.0-SNAPSHOT"
12
+
13
+ define 'killer-app' do
14
+
15
+ project.version = THIS_VERSION
16
+
17
+ # ...
18
+ end
19
+ {% endhighlight %}
20
+
21
+
22
+ h2(#default). What does a release do?
23
+
24
+ The default behavior of the @Release@ task is the following:
25
+ # Check that the version to be released and the next version are different
26
+ # Check that the project is being tracked by Git or Subversion
27
+ # Package, test and deploy the artifacts using @THIS_VERSION@ value minus the @-SNAPSHOT@ suffix (if any)
28
+ # Tag the repository with the released version number
29
+ # Update the value of @THIS_VERSION@ in the buildfile with the next version number
30
+
31
+ Buildr will increment the last digit of the 3-digit versioni number if @THIS_VERSION@ ends with @-SNAPSHOT@.
32
+ So, at the end of a release, the buildfile now looks like this:
33
+
34
+ {% highlight ruby %}
35
+ THIS_VERSION = "1.0.1-SNAPSHOT"
36
+
37
+ define 'killer-app' do
38
+
39
+ project.version = THIS_VERSION
40
+
41
+ # ...
42
+ end
43
+ {% endhighlight %}
44
+
45
+ And the Git repository now contains two new commits and a new tag.
46
+
47
+ {% highlight sh %}
48
+ ~/w/killer-app[master]$git ol -4
49
+ c1af3d5 (HEAD, origin/master, master) Changed version number to 1.0.1-SNAPSHOT
50
+ dd35015 (tag: 1.0.0) Changed version number to 1.0.0
51
+ 76c96e7 Last fix before the release
52
+ {% endhighlight %}
53
+
54
+
55
+ h2(#custom_version). How to specify my own version number scheme?
56
+
57
+ If @THIS_VERSION@ does not contain @-SNAPSHOT@, Buildr delegates the resolution of the next version number to the user which has 2 differents ways to express her wishes: @Release.next_version@ or the environment variable @NEXT_VERSION@.
58
+
59
+ h3(#next_version_proc). Using Release.next_version
60
+
61
+ The @Release@ class can receive the next version of the buildfile. This could be a string or a proc that would receive the current version and return the next version.
62
+
63
+ {% highlight ruby %}
64
+ THIS_VERSION = "1.0.0-SNAPSHOT"
65
+
66
+ # a string
67
+ Release.next_version = "2.0.0-SNAPSHOT"
68
+
69
+ # or a proc
70
+ Release.next_version = lambda do |this_version| # 1.0.0-SNAPSHOT
71
+ new_version = @THIS_VERSION@.split(/\./)
72
+ new_version[0] = new_version[0] + 1
73
+ new_version
74
+ end
75
+
76
+ define 'killer-app' do
77
+
78
+ project.version = THIS_VERSION
79
+
80
+ # ...
81
+ end
82
+ {% endhighlight %}
83
+
84
+
85
+ h3(#next_version_envvar). Using the environment variable NEXT_VERSION
86
+
87
+ If the environment variable @NEXT_VERSION@ is set, Buildr will use this value to update @THIS_VERSION@ at the end of the release.
88
+
89
+ For conveniency, this variable is case insensitive.
90
+
91
+ So, all 3 following commands will run a release with a custom new version:
92
+
93
+ {% highlight sh %}
94
+ $ buildr release next_version="1.0.0-rc1"
95
+ $ env next_version="1.0.0-rc1" buildr release
96
+ $ env NEXT_VERSION="1.0.0-rc1" buildr release
97
+ {% endhighlight %}
98
+
99
+ Those commands will generate the Buildfile below:
100
+
101
+ {% highlight ruby %}
102
+ THIS_VERSION = "1.0.0-rc1"
103
+
104
+ define 'killer-app' do
105
+
106
+ project.version = THIS_VERSION
107
+
108
+ # ...
109
+ end
110
+ {% endhighlight %}
111
+
112
+ The environment variable @NEXT_VERSION@ has precedence over Release.next_version.
113
+
114
+ h2(#custom_tag_and_msg). How to specify my own tag name and commit message?
115
+
116
+ As explained earlier, Buildr will create two new commits and a new tag in the version control system. Similarly to @Release.next_version@, the commit message and the tag name can be customized with @Release.message@ and @Release.tag_name@. Both could be strings or procs that would receive the released version @THIS_VERSION@ without @-SNAPSHOT@.
117
+
@@ -0,0 +1,512 @@
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
+
18
+ # This script helps buildr developers to obtain their own git clone from
19
+ # github, and also provides GitFlow commands to keep the git mirror in sync
20
+ # with Apache SVN.
21
+ #
22
+ # If you already have a buildr clone, just do the following:
23
+ #
24
+ # git config alias.apache '!'"ruby $PWD/doc/scripts/buildr-git.rb"
25
+ #
26
+ # After this, you have a 'git apache' command and you can try (be sure to read the help)
27
+ #
28
+ # git apache help
29
+ # git apache setup svn --help
30
+ # git apache sync --help
31
+ #
32
+ # To configure your local repo for svn synchronization,
33
+ #
34
+ # git apache update-authors
35
+ # git remote add upstream git@github.com:buildr/buildr.git
36
+ # git apache setup svn --username apacheLogin --apache-git upstream
37
+ # git apache sync
38
+ #
39
+ # This script can also be run without having a local buildr clone:
40
+ #
41
+ # ruby -ropen-uri -e 'eval(open("http://svn.apache.org/viewvc/buildr/trunk/doc/scripts/buildr-git.rb?view=co").read)' help
42
+
43
+
44
+
45
+ require 'yaml'
46
+ require 'open-uri'
47
+
48
+ if $0 == '-e' # invoked from open-uri
49
+ gitflow = "http://svn.apache.org/viewvc/buildr/trunk/doc/scripts/gitflow.rb?view=co"
50
+ eval(open(gitflow).read)
51
+ else
52
+ require File.expand_path('gitflow', File.dirname(__FILE__))
53
+ end
54
+
55
+ GitFlow.program = 'buildr-git'
56
+
57
+ module BuildrGit
58
+
59
+ class UpdateUsersCommand < GitFlow/'update-users'
60
+
61
+ @help = "Update list of Apache SVN committers from Jukka's list."
62
+ @@url = 'http://people.apache.org/~jukka/authors.txt'
63
+
64
+ def self.authors_file
65
+ File.expand_path('.git/authors.txt', Dir.pwd)
66
+ end
67
+
68
+ def self.user_email(apache_login, authors_file = nil)
69
+ authors_file ||= self.authors_file
70
+ authors = YAML.load(File.read(authors_file).gsub!(/\s+=\s+/, ': '))
71
+ contact = authors[apache_login]
72
+ fail "You are not listed as apache commiter on #{authors_file}" unless contact
73
+ fail "Not a valid contact line: #{contact}" unless contact =~ /\s+<(.*)>/
74
+ [$`, $1]
75
+ end
76
+
77
+ def options(opts)
78
+ opts.url = @@url
79
+ opts.file = self.class.authors_file
80
+ [['-u', '--url URL',
81
+ "From URL. defaults to: #{opts.url}", lambda { |url|
82
+ opts.url = url
83
+ }],
84
+ ['-f', '--file FILE',
85
+ "Write to FILE, defaults to #{opts.file}", lambda { |path|
86
+ opts.file = path
87
+ }]
88
+ ]
89
+ end
90
+
91
+ def execute(opts, argv)
92
+ FileUtils.mkdir_p(File.dirname(opts.file))
93
+ content = open(opts.url).read
94
+ File.open(opts.file, "w") { |f| f.print content }
95
+ end
96
+ end
97
+
98
+ class CloneCommand < GitFlow/:clone
99
+ @help = "Create a clone from github.com/buildr repository."
100
+
101
+ def options(opts)
102
+ opts.origin = 'git://github.com/buildr/buildr.git'
103
+ opts.svn_prefix = 'apache'
104
+ opts.project = 'buildr'
105
+ opts.local = expand_path(opts.project)
106
+ [['--prefix SVN_PREFIX', opts.svn_prefix, lambda { |p|
107
+ opts.svn_prefix = p }],
108
+ ['--origin GIT_ORIGIN', opts.origin, lambda { |o|
109
+ opts.origin = o }],
110
+ ['-d', '--dir DIR', opts.local, lambda { |d| opts.local = d }]
111
+ ]
112
+ end
113
+
114
+ def execute(opts, argv)
115
+ git 'clone', opts.origin, opts.local
116
+ Dir.chdir(opts.local) do
117
+ run 'update-users'
118
+ run 'setup'
119
+ end
120
+ end
121
+ end
122
+
123
+ class SetupCommand < GitFlow/:setup
124
+ @help = "Setup your buildr clone to be used with git mirror."
125
+ def options(opt)
126
+ []
127
+ end
128
+
129
+ def execute(opt, argv)
130
+ run 'setup', 'alias'
131
+ run 'setup', 'svn'
132
+ end
133
+ end
134
+
135
+ class SetupAliasCommand < SetupCommand/:alias
136
+ def execute(opt, argv)
137
+ me = expand_path('doc/scripts/buildr-git.rb')
138
+ git 'config', 'alias.apache', "!ruby #{me}"
139
+ end
140
+ end
141
+
142
+ class SetupSvnCommand < SetupCommand/:svn
143
+ @help = "Setup for getting changes from Apache SVN."
144
+
145
+ def options(opt)
146
+ opt.svn_prefix = 'apache'
147
+ opt.svn_path = 'buildr'
148
+ opt.townhall = 'origin'
149
+ [['--username SVN_USER', 'Use Apache svn username for this svn remote',
150
+ lambda { |e| opt.apache_login = e }],
151
+ ['--svn-prefix PREFIX', 'The name of svn remote to use for project.',
152
+ "Defaults to #{opt.svn_prefix}",
153
+ lambda{|p| opt.svn_prefix = p }],
154
+ ['--svn-uri URI', lambda {|p| opt.svn_uri = p }],
155
+ ['--svn-rev REVISION', lambda {|p| opt.svn_rev = p }],
156
+ ['--svn-path PATH', 'The path to append to svn-uri.',
157
+ "Defaults to #{opt.svn_path}", lambda {|p| opt.svn_path = p }],
158
+ ['--apache-git REMOTE', 'The name of remote you are using as town-hall git repo.',
159
+ "Defaults to #{opt.townhall}",
160
+ lambda {|p| opt.townhall = p }]
161
+ ]
162
+ end
163
+
164
+ def execute(opt, argv)
165
+ authors_file = UpdateUsersCommand.authors_file
166
+ git 'config', 'svn.authorsfile', authors_file
167
+ git 'config', 'apache.svn', opt.svn_prefix
168
+ git 'config', 'apache.git', opt.townhall
169
+
170
+ if opt.apache_login
171
+ user, email = UpdateUsersCommand.user_email(opt.apache_login, authors_file)
172
+ puts "You claim to be #{user} <#{email}> with apache login: #{opt.apache_login}"
173
+ git('config', 'user.name', user)
174
+ git('config', 'user.email', email)
175
+ end
176
+
177
+ if opt.svn_rev
178
+ revision = opt.svn_rev
179
+ else
180
+ location, revision = svn_loc_rev
181
+ revision = opt.svn_rev || revision
182
+ end
183
+
184
+ if opt.svn_uri
185
+ repo = opt.svn_uri
186
+ else
187
+ fail "No #{opt.svn_path} directory on #{location}" unless
188
+ location =~ /\/#{opt.svn_path}/
189
+ repo = $`
190
+ end
191
+
192
+ # Tell git where the svn repository is
193
+ git('config', "svn-remote.#{opt.svn_prefix}.url", repo)
194
+ git('config', "svn-remote.#{opt.svn_prefix}.fetch",
195
+ "#{opt.svn_path}/trunk:refs/remotes/#{opt.svn_prefix}/trunk")
196
+ git('config', "svn-remote.#{opt.svn_prefix}.branches",
197
+ "#{opt.svn_path}/branches/*:refs/remotes/#{opt.svn_prefix}/*")
198
+ git('config', "svn-remote.#{opt.svn_prefix}.tags",
199
+ "#{opt.svn_path}/tags/*:refs/remotes/#{opt.svn_prefix}/tags/*")
200
+
201
+ # Store the user for svn dcommit
202
+ if opt.apache_login
203
+ git('config', "svn-remote.#{opt.svn_prefix}.username", opt.apache_login)
204
+ end
205
+
206
+ # Create the svn branch, do this instead of pulling the full svn history
207
+ git('update-ref', "refs/remotes/#{opt.svn_prefix}/trunk",
208
+ 'refs/remotes/origin/master')
209
+ # create tags from git
210
+ git('tag').split.each do |tag|
211
+ git('update-ref', "refs/remotes/#{opt.svn_prefix}/tags/#{tag}",
212
+ "refs/tags/#{tag}")
213
+ end
214
+ # update svn metadata
215
+ mkdir_p(expand_path('.git/svn'))
216
+ svn_meta = expand_path('.git/svn/.metadata')
217
+ git('config', '--file', svn_meta,
218
+ "svn-remote.#{opt.svn_prefix}.branches-maxRev", revision)
219
+ git('config', '--file', svn_meta,
220
+ "svn-remote.#{opt.svn_prefix}.tags-maxRev", revision)
221
+ end
222
+
223
+ def svn_loc_rev
224
+ meta = sh('git log -n 10 | grep git-svn-id | head -n 1').chomp
225
+ fail "No svn metadata on last 10 commits" if meta.empty?
226
+ meta.split[1].split('@')
227
+ end
228
+ end
229
+
230
+ class FetchCommand < GitFlow/:fetch
231
+ @help = "Get changes from svn, creating tags, branches on townhall"
232
+ @documentation = <<-DOC
233
+ This command can be used to fetch changes from Apache\'s SVN repo.
234
+
235
+ GIT CONFIG VALUES:
236
+
237
+ apache.svn - The svn remote using to get changes from Apache SVN.
238
+ Set by setup-svn --svn-prefix.
239
+ DOC
240
+
241
+ def options(opt)
242
+ opt.apache_svn = git('config', '--get', 'apache.svn').chomp rescue nil
243
+ [['--apache-svn SVN_REMOTE', 'The SVN remote used to get changes from Apache',
244
+ "Current value: #{opt.apache_svn}",
245
+ lambda { |r| opt.apache_svn = r }]
246
+ ]
247
+ end
248
+
249
+ def execute(opt, argv)
250
+ fail "Missing apache.svn config value" unless opt.apache_svn
251
+ git('svn', 'fetch', opt.apache_svn)
252
+ end
253
+ end
254
+
255
+ class SyncCommand < GitFlow/:sync
256
+ @help = "Synchronizes between Apache svn and git townhall."
257
+ @documentation = <<-DOC
258
+ This command will perform the following actions:
259
+ * fetch changes from apache svn.
260
+ * rebase them on the current branch or on the one specified with --onto
261
+ * dcommit (this will push your changes to Apache trunk)
262
+
263
+ GIT CONFIG VALUES:
264
+
265
+ apache.svn
266
+ The svn remote using to get changes from Apache SVN.
267
+ Set by setup-svn --svn-prefix.
268
+
269
+ apache.git
270
+ The git remote used as townhall repository.
271
+ Set by setup-svn --townhall.
272
+
273
+ svn-remote.APACHE_GIT.username
274
+ If configured, sync will use this svn username while dcommiting.
275
+ DOC
276
+
277
+ def options(opt)
278
+ git('branch').split.tap { |n| opt.current = n[n.index('*')+1] }
279
+ opt.branch = opt.current
280
+ opt.svn_branch = 'trunk'
281
+ opt.git_branch = 'master'
282
+ opt.apache_git = git('config', '--get', 'apache.git').chomp rescue nil
283
+ opt.apache_svn = git('config', '--get', 'apache.svn').chomp rescue nil
284
+ opt.svn_username = git('config', '--get',
285
+ "svn-remote.#{opt.apache_svn}.username").chomp rescue nil
286
+ [['--apache-svn SVN_REMOTE', 'The SVN remote used to get changes from Apache',
287
+ "Current value: #{opt.apache_svn}",
288
+ lambda { |r| opt.apache_svn = r }],
289
+ ['--apache-git REMOTE', 'The git remote used as town-hall repository.',
290
+ "Current value: #{opt.apache_git}",
291
+ lambda { |r| opt.apache_git = r }],
292
+ ['--username SVN_USER',
293
+ 'Specify the SVN username for dcommit',
294
+ "Defaults to: #{opt.svn_username}",
295
+ lambda { |b| opt.svn_username = b }],
296
+ ['--svn-branch SVN_BRANCH',
297
+ 'Specify the SVN branch to rebase changes from, and where to dcommit',
298
+ "Defaults to: #{opt.svn_branch}",
299
+ lambda { |b| opt.svn_branch = b }],
300
+ ['--git-branch REMOTE_BRANCH',
301
+ 'Specify the remote town-hall branch (on apache.git) to update',
302
+ "Defaults to: #{opt.git_branch}",
303
+ lambda { |b| opt.git_branch = b }],
304
+ ['--branch BRANCH', 'Specify the local branch to take changes from',
305
+ "Current branch: #{opt.branch}",
306
+ lambda { |b| opt.branch = b }]
307
+ ]
308
+ end
309
+
310
+ def execute(opt, argv)
311
+ # obtain the svn url
312
+ url = git('config', '--get', "svn-remote.#{opt.apache_svn}.url").chomp
313
+ # obtain the path for project
314
+ path = git('config', '--get', "svn-remote.#{opt.apache_svn}.branches").
315
+ chomp.split('/branches').first
316
+ commit_url = "#{url}/#{path}/#{opt.svn_branch}"
317
+
318
+ # obtain latest changes from svn
319
+ git('svn', 'fetch', '--svn-remote', opt.apache_svn)
320
+ # obtain latest changes from git
321
+ git('fetch', opt.apache_git,
322
+ "#{opt.git_branch}:refs/remotes/#{opt.apache_git}/#{opt.git_branch}")
323
+
324
+ # rebase svn changes in the desired branch
325
+ git('rebase', "#{opt.apache_svn}/#{opt.svn_branch}", opt.branch)
326
+ git('rebase', "#{opt.apache_git}/#{opt.git_branch}", opt.branch)
327
+
328
+ # dcommit to the specific svn branch
329
+ ['svn', 'dcommit',
330
+ '--svn-remote', opt.apache_svn, '--commit-url', commit_url].tap do |cmd|
331
+ if opt.svn_username
332
+ cmd << '--username' << opt.svn_username
333
+ end
334
+ git(*cmd)
335
+ end
336
+
337
+ # update townhall remote ref
338
+ git('update-ref',
339
+ "refs/remotes/#{opt.apache_git}/#{opt.git_branch}",
340
+ "refs/remotes/#{opt.apache_svn}/#{opt.svn_branch}")
341
+
342
+ # forward the remote townhall/master to apache/trunk
343
+ git('push', opt.apache_git,
344
+ "refs/remotes/#{opt.apache_git}/#{opt.git_branch}:#{opt.git_branch}")
345
+
346
+ # get back to the original branch
347
+ git('checkout', opt.current)
348
+ end
349
+ end
350
+
351
+
352
+ # This one is displayed when the user executes this script using
353
+ # open-uri -e
354
+ HEADER = <<HEADER
355
+
356
+ Buildr official commit channel is Apache's svn repository, however some
357
+ developers may prefer to use git while working on several features and
358
+ merging other's changes.
359
+
360
+ This script will configure a gitflow copy on so you can commit to svn.
361
+
362
+ Enter <-h> to see options, <-H> to see notes about configured aliases
363
+ and recommended workflow, or any other option.
364
+
365
+ Ctrl+D or an invalid option to abort
366
+ HEADER
367
+
368
+ # When fork is completed, we display the following notice on a
369
+ # pager, giving the user a brief overview of git aliases used
370
+ # to keep the mirror in sync.
371
+ NOTICE = <<NOTICE
372
+ ALIASES:
373
+
374
+ Some git aliases have been created for developer convenience:
375
+
376
+ git apache fetch # get changes from apache/trunk without merging them
377
+ # you can inspect what's happening on trunk without
378
+ # having to worry about merging conflicts.
379
+ # Inspect the remote branch with `git log apache/trunk`
380
+ # Or if you have a git-ui like `tig` you can use that.
381
+
382
+ git apache merge # Merge already fetched changes on the current branch
383
+ # Use this command to get up to date with trunk changes
384
+ # you can always cherry-pick from the apache/trunk
385
+ # branch.
386
+
387
+ git apache pull # get apache-fetch && git apache-merge
388
+
389
+ git apache push # Push to Apache's SVN. Only staged changes (those
390
+ # recorded using `git commit`) will be sent to SVN.
391
+ # You need not to be on the master branch.
392
+ # Actually you can work on a tiny-feature branch and
393
+ # commit directly from it.
394
+ #
395
+ # VERY IMPORTANT:
396
+ #
397
+ # Missing commits on Apache's SVN will be sent using
398
+ # your apache svn account. This means that you can
399
+ # make some commits on behalf of others (like patches
400
+ # comming from JIRA issues or casual contributors)
401
+ # Review the apache-push alias on .git/config if you
402
+ # want to change login-name used for commit to SVN.
403
+ #
404
+ # See the recommended workflow to avoid commiting
405
+ # other developers' changes and the following section.
406
+
407
+ THE GITHUB MIRROR:
408
+
409
+ Buildr has an unofficial git mirror on github, maintained by Apache committers:
410
+
411
+ http://github.com/buildr/buildr
412
+
413
+ This mirror DOES NOT replace Apache's SVN repository. We really care about
414
+ using Apache infrastructure and following Apache project guidelines for
415
+ contributions. This git mirror is provided only for developers convenience,
416
+ allowing them to easily create experimental branches or review code from
417
+ other committers.
418
+
419
+ All code that wants to make it to the official Apache Buildr repository needs
420
+ to be committed to the Apache SVN repository by using the command:
421
+
422
+ git synchronize
423
+
424
+ This command will synchronize both ways svn<->git to keep trunk upto date.
425
+ You need to be an Apache committer and have permissions on the SVN repo.
426
+
427
+ It's VERY IMPORTANT for Buildr committers to remember that contributions from
428
+ external entities wanting to be accepted will require them to sign the Apache ICLA.
429
+ We provide the git mirror to make it easier for people to experiment and
430
+ contribute back to Buildr, before merging their code in, please remember they
431
+ have to create create a JIRA issue granting ASF permission to include their code,
432
+ just like any other contribution following Apache's guidelines.
433
+
434
+ So, it's very important - if you care about meritocracy - to follow or at
435
+ least that you get an idea of the recommended workflow.
436
+
437
+ RECOMMENDED WORKFLOW:
438
+
439
+ So now that you have your local buildr copy you can create topic branches
440
+ to work on independent features, and still merge easily with head changes.
441
+
442
+ They may seem lots of things to consider, but it's all for Buildr's healt.
443
+ As all things git, you can always follow your own workflow and even create
444
+ aliases on you .git/config file to avoid typing much. So, here they are:
445
+
446
+ 1) get your gitflow configured
447
+ (you have already do so, this was the most difficult part)
448
+
449
+ 2) create a topic branch to work on, say.. you want to add cool-feature:
450
+
451
+ git checkout -b cool-feature master
452
+ # now on branch cool-feature
453
+
454
+ 3) hack hack hack.. use the source luke.
455
+ every time you feel you have something important like added failing
456
+ spec, added part of feature, or resolved some conflict from merges,
457
+ you can commit your current progress. If you want to be selective, use:
458
+
459
+ git commit --interactive
460
+
461
+ 3) review your changes, get ALL specs passing, repeat step 3 as needed
462
+
463
+ 4) let's see what are they doing on trunk
464
+
465
+ git apache-fetch
466
+ # You can inspect the upstream changes without having to merge them
467
+ git log apache/trunk # what are they doing!!
468
+
469
+ 5) integrate mainstream changes to your cool-feature branch, you can always
470
+ use `git cherry-pick` to select only some commits.
471
+
472
+ git merge apache/trunk cool-feature
473
+
474
+ 6) Go to 3 unless ALL specs are passing.
475
+
476
+ 7.a) (Skip to 7.b you have commit bit on Apache's SVN)
477
+ Create a patch using `git format-patch`
478
+ Promote your changes, create a JIRA issue and upload it granting Apache
479
+ license to include your code:
480
+
481
+ https://issues.apache.org/jira/browse/BUILDR
482
+ dev@buildr.apache.org
483
+
484
+ 7.b) Now you have everyhing on staging area and merged important changes
485
+ from apache/trunk, it's time to commit them to Apache's SVN.
486
+
487
+ git apache-push
488
+
489
+ 8) Optional. If you are a buildr committer you may want to synchronize
490
+ the github mirror for helping others to get changes without having to
491
+ wait on Victor's cronjob to run every hour (useful for urgent changes).
492
+
493
+ git synchronize
494
+
495
+ 9) Pull changes from origin frequently.
496
+
497
+ git fetch origin
498
+ git rebase --onto origin/master master master
499
+
500
+ 10) Unconditionally, Go to step 2 ;)
501
+ Share your gitflow workflow, git tips, etc.
502
+
503
+ RESOURCES:
504
+
505
+ http://github.com/buildr/buildr/tree/master
506
+ http://git.or.cz/gitwiki/GitCheatSheet
507
+ http://groups.google.com/group/git-users/web/git-references
508
+
509
+ NOTICE
510
+ #' for emacs
511
+
512
+ end