buildr 1.2.10 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. data/CHANGELOG +566 -268
  2. data/DISCLAIMER +7 -1
  3. data/KEYS +151 -0
  4. data/NOTICE +23 -8
  5. data/README +122 -22
  6. data/Rakefile +49 -229
  7. data/{lib → addon}/buildr/antlr.rb +23 -10
  8. data/addon/buildr/cobertura.rb +232 -0
  9. data/{lib → addon}/buildr/hibernate.rb +20 -4
  10. data/{lib → addon}/buildr/javacc.rb +27 -12
  11. data/addon/buildr/jdepend.rb +60 -0
  12. data/{lib → addon}/buildr/jetty.rb +34 -18
  13. data/addon/buildr/nailgun.rb +892 -0
  14. data/{lib → addon}/buildr/openjpa.rb +23 -6
  15. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  16. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  17. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  18. data/{lib/buildr/jetty → addon/buildr/org/apache/buildr}/JettyWrapper.java +19 -0
  19. data/{lib → addon}/buildr/xmlbeans.rb +39 -14
  20. data/bin/buildr +21 -7
  21. data/buildr.gemspec +50 -0
  22. data/doc/css/default.css +225 -0
  23. data/doc/css/print.css +95 -0
  24. data/doc/css/syntax.css +43 -0
  25. data/doc/images/apache-incubator-logo.png +0 -0
  26. data/doc/images/buildr-hires.png +0 -0
  27. data/doc/images/buildr.png +0 -0
  28. data/doc/images/note.png +0 -0
  29. data/doc/images/tip.png +0 -0
  30. data/doc/images/zbuildr.tif +0 -0
  31. data/doc/pages/artifacts.textile +317 -0
  32. data/doc/pages/building.textile +501 -0
  33. data/doc/pages/contributing.textile +178 -0
  34. data/doc/pages/download.textile +25 -0
  35. data/doc/pages/extending.textile +229 -0
  36. data/doc/pages/getting_started.textile +337 -0
  37. data/doc/pages/index.textile +63 -0
  38. data/doc/pages/mailing_lists.textile +17 -0
  39. data/doc/pages/more_stuff.textile +367 -0
  40. data/doc/pages/packaging.textile +592 -0
  41. data/doc/pages/projects.textile +449 -0
  42. data/doc/pages/recipes.textile +127 -0
  43. data/doc/pages/settings_profiles.textile +339 -0
  44. data/doc/pages/testing.textile +475 -0
  45. data/doc/pages/troubleshooting.textile +121 -0
  46. data/doc/pages/whats_new.textile +389 -0
  47. data/doc/print.haml +52 -0
  48. data/doc/print.toc.yaml +28 -0
  49. data/doc/scripts/buildr-git.rb +411 -0
  50. data/doc/scripts/install-jruby.sh +44 -0
  51. data/doc/scripts/install-linux.sh +64 -0
  52. data/doc/scripts/install-osx.sh +52 -0
  53. data/doc/site.haml +55 -0
  54. data/doc/site.toc.yaml +44 -0
  55. data/lib/buildr.rb +28 -45
  56. data/lib/buildr/core.rb +27 -0
  57. data/lib/buildr/core/application.rb +373 -0
  58. data/lib/buildr/core/application_cli.rb +134 -0
  59. data/lib/{core → buildr/core}/build.rb +91 -77
  60. data/lib/{core → buildr/core}/checks.rb +116 -95
  61. data/lib/buildr/core/common.rb +155 -0
  62. data/lib/buildr/core/compile.rb +594 -0
  63. data/lib/buildr/core/environment.rb +120 -0
  64. data/lib/buildr/core/filter.rb +258 -0
  65. data/lib/{core → buildr/core}/generate.rb +22 -5
  66. data/lib/buildr/core/help.rb +118 -0
  67. data/lib/buildr/core/progressbar.rb +156 -0
  68. data/lib/{core → buildr/core}/project.rb +468 -213
  69. data/lib/buildr/core/test.rb +690 -0
  70. data/lib/{core → buildr/core}/transports.rb +107 -127
  71. data/lib/buildr/core/util.rb +235 -0
  72. data/lib/buildr/ide.rb +19 -0
  73. data/lib/{java → buildr/ide}/eclipse.rb +86 -60
  74. data/lib/{java → buildr/ide}/idea.ipr.template +16 -0
  75. data/lib/buildr/ide/idea.rb +194 -0
  76. data/lib/buildr/ide/idea7x.ipr.template +290 -0
  77. data/lib/buildr/ide/idea7x.rb +210 -0
  78. data/lib/buildr/java.rb +26 -0
  79. data/lib/buildr/java/ant.rb +71 -0
  80. data/lib/buildr/java/bdd_frameworks.rb +267 -0
  81. data/lib/buildr/java/commands.rb +210 -0
  82. data/lib/buildr/java/compilers.rb +432 -0
  83. data/lib/buildr/java/deprecated.rb +141 -0
  84. data/lib/buildr/java/groovyc.rb +137 -0
  85. data/lib/buildr/java/jruby.rb +99 -0
  86. data/lib/buildr/java/org/apache/buildr/BuildrNail$Main.class +0 -0
  87. data/lib/buildr/java/org/apache/buildr/BuildrNail.class +0 -0
  88. data/lib/buildr/java/org/apache/buildr/BuildrNail.java +41 -0
  89. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  90. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +116 -0
  91. data/lib/buildr/java/packaging.rb +706 -0
  92. data/lib/{java → buildr/java}/pom.rb +20 -4
  93. data/lib/buildr/java/rjb.rb +142 -0
  94. data/lib/buildr/java/test_frameworks.rb +290 -0
  95. data/lib/buildr/java/version_requirement.rb +172 -0
  96. data/lib/buildr/packaging.rb +21 -0
  97. data/lib/{java → buildr/packaging}/artifact.rb +170 -179
  98. data/lib/buildr/packaging/artifact_namespace.rb +957 -0
  99. data/lib/buildr/packaging/artifact_search.rb +140 -0
  100. data/lib/buildr/packaging/gems.rb +102 -0
  101. data/lib/buildr/packaging/package.rb +233 -0
  102. data/lib/{tasks → buildr/packaging}/tar.rb +18 -1
  103. data/lib/{tasks → buildr/packaging}/zip.rb +153 -105
  104. data/rakelib/apache.rake +126 -0
  105. data/rakelib/changelog.rake +56 -0
  106. data/rakelib/doc.rake +103 -0
  107. data/rakelib/package.rake +44 -0
  108. data/rakelib/release.rake +53 -0
  109. data/rakelib/rspec.rake +81 -0
  110. data/rakelib/rubyforge.rake +45 -0
  111. data/rakelib/scm.rake +49 -0
  112. data/rakelib/setup.rake +59 -0
  113. data/rakelib/stage.rake +45 -0
  114. data/spec/application_spec.rb +316 -0
  115. data/spec/archive_spec.rb +494 -0
  116. data/spec/artifact_namespace_spec.rb +635 -0
  117. data/spec/artifact_spec.rb +738 -0
  118. data/spec/build_spec.rb +193 -0
  119. data/spec/checks_spec.rb +537 -0
  120. data/spec/common_spec.rb +579 -0
  121. data/spec/compile_spec.rb +561 -0
  122. data/spec/groovy_compilers_spec.rb +239 -0
  123. data/spec/java_bdd_frameworks_spec.rb +238 -0
  124. data/spec/java_compilers_spec.rb +446 -0
  125. data/spec/java_packaging_spec.rb +1042 -0
  126. data/spec/java_test_frameworks_spec.rb +414 -0
  127. data/spec/packaging_helper.rb +63 -0
  128. data/spec/packaging_spec.rb +589 -0
  129. data/spec/project_spec.rb +739 -0
  130. data/spec/sandbox.rb +116 -0
  131. data/spec/scala_compilers_spec.rb +239 -0
  132. data/spec/spec.opts +6 -0
  133. data/spec/spec_helpers.rb +283 -0
  134. data/spec/test_spec.rb +871 -0
  135. data/spec/transport_spec.rb +300 -0
  136. data/spec/version_requirement_spec.rb +115 -0
  137. metadata +188 -77
  138. data/lib/buildr/cobertura.rb +0 -89
  139. data/lib/buildr/jdepend.rb +0 -40
  140. data/lib/buildr/jetty/JettyWrapper$1.class +0 -0
  141. data/lib/buildr/jetty/JettyWrapper$BuildrHandler.class +0 -0
  142. data/lib/buildr/jetty/JettyWrapper.class +0 -0
  143. data/lib/buildr/scala.rb +0 -368
  144. data/lib/core/application.rb +0 -188
  145. data/lib/core/common.rb +0 -562
  146. data/lib/core/help.rb +0 -72
  147. data/lib/core/rake_ext.rb +0 -81
  148. data/lib/java/ant.rb +0 -71
  149. data/lib/java/compile.rb +0 -589
  150. data/lib/java/idea.rb +0 -159
  151. data/lib/java/java.rb +0 -432
  152. data/lib/java/packaging.rb +0 -581
  153. data/lib/java/test.rb +0 -795
  154. data/lib/tasks/concat.rb +0 -35
@@ -0,0 +1,120 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require 'yaml'
18
+
19
+
20
+ module Buildr
21
+
22
+ # Collection of options for controlling Buildr.
23
+ class Options
24
+
25
+ # We use this to present environment variable as arrays.
26
+ class EnvArray < Array #:nodoc:
27
+
28
+ def initialize(name)
29
+ @name = name.upcase
30
+ replace((ENV[@name] || ENV[@name.downcase] || '').split(/\s*,\s*/).reject(&:empty?))
31
+ end
32
+
33
+ (Array.instance_methods - Object.instance_methods - Enumerable.instance_methods).sort.each do |method|
34
+ class_eval %{def #{method}(*args, &block) ; result = super ; write ; result ; end}
35
+ end
36
+
37
+ private
38
+
39
+ def write
40
+ ENV[@name.downcase] = nil
41
+ ENV[@name] = map(&:to_s).join(',')
42
+ end
43
+
44
+ end
45
+
46
+
47
+ # Wraps around the proxy environment variables:
48
+ # * :http -- HTTP_PROXY
49
+ # * :exclude -- NO_PROXY
50
+ class Proxies
51
+
52
+ # Returns the HTTP_PROXY URL.
53
+ def http
54
+ ENV['HTTP_PROXY'] || ENV['http_proxy']
55
+ end
56
+
57
+ # Sets the HTTP_PROXY URL.
58
+ def http=(url)
59
+ ENV['http_proxy'] = nil
60
+ ENV['HTTP_PROXY'] = url
61
+ end
62
+
63
+ # Returns list of hosts to exclude from proxying (NO_PROXY).
64
+ def exclude
65
+ @exclude ||= EnvArray.new('NO_PROXY')
66
+ end
67
+
68
+ # Sets list of hosts to exclude from proxy (NO_PROXY). Accepts host name, array of names,
69
+ # or nil to clear the list.
70
+ def exclude=(url)
71
+ exclude.clear
72
+ exclude.concat [url].flatten if url
73
+ exclude
74
+ end
75
+
76
+ end
77
+
78
+ # :call-seq:
79
+ # proxy => options
80
+ #
81
+ # Returns the proxy options. Currently supported options are:
82
+ # * :http -- HTTP proxy for use when downloading.
83
+ # * :exclude -- Do not use proxy for these hosts/domains.
84
+ #
85
+ # For example:
86
+ # options.proxy.http = 'http://proxy.acme.com:8080'
87
+ # You can also set it using the environment variable HTTP_PROXY.
88
+ #
89
+ # You can exclude individual hosts from being proxied, or entire domains, for example:
90
+ # options.proxy.exclude = 'optimus'
91
+ # options.proxy.exclude = ['optimus', 'prime']
92
+ # options.proxy.exclude << '*.internal'
93
+ def proxy
94
+ @proxy ||= Proxies.new
95
+ end
96
+
97
+ end
98
+
99
+
100
+ class << self
101
+
102
+ # :call-seq:
103
+ # options => Options
104
+ #
105
+ # Returns the Buildr options. See Options.
106
+ def options
107
+ @options ||= Options.new
108
+ end
109
+
110
+ end
111
+
112
+ # :call-seq:
113
+ # options => Options
114
+ #
115
+ # Returns the Buildr options. See Options.
116
+ def options
117
+ Buildr.options
118
+ end
119
+
120
+ end
@@ -0,0 +1,258 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ module Buildr
18
+
19
+ # A filter knows how to copy files from one directory to another, applying mappings to the
20
+ # contents of these files.
21
+ #
22
+ # You can specify the mapping using a Hash, and it will map ${key} fields found in each source
23
+ # file into the appropriate value in the target file. For example:
24
+ #
25
+ # filter.using 'version'=>'1.2', 'build'=>Time.now
26
+ #
27
+ # will replace all occurrences of <tt>${version}</tt> with <tt>1.2</tt>, and <tt>${build}</tt>
28
+ # with the current date/time.
29
+ #
30
+ # You can also specify the mapping by passing a proc or a method, that will be called for
31
+ # each source file, with the file name and content, returning the modified content.
32
+ #
33
+ # Without any mapping, the filter simply copies files from the source directory into the target
34
+ # directory.
35
+ #
36
+ # A filter has one target directory, but you can specify any number of source directories,
37
+ # either when creating the filter or calling #from. Include/exclude patterns are specified
38
+ # relative to the source directories, so:
39
+ # filter.include '*.png'
40
+ # will only include PNG files from any of the source directories.
41
+ #
42
+ # See Buildr#filter.
43
+ class Filter
44
+
45
+ def initialize #:nodoc:
46
+ clear
47
+ end
48
+
49
+ # Returns the list of source directories (each being a file task).
50
+ attr_reader :sources
51
+
52
+ # :call-seq:
53
+ # clear => self
54
+ #
55
+ # Clear filter sources and include/exclude patterns
56
+ def clear
57
+ @include = []
58
+ @exclude = []
59
+ @sources = []
60
+ self
61
+ end
62
+
63
+ # :call-seq:
64
+ # from(*sources) => self
65
+ #
66
+ # Adds additional directories from which to copy resources.
67
+ #
68
+ # For example:
69
+ # filter.from('src').into('target').using('build'=>Time.now)
70
+ def from(*sources)
71
+ @sources |= sources.flatten.map { |dir| file(File.expand_path(dir.to_s)) }
72
+ self
73
+ end
74
+
75
+ # The target directory as a file task.
76
+ attr_reader :target
77
+
78
+ # :call-seq:
79
+ # into(dir) => self
80
+ #
81
+ # Sets the target directory into which files are copied and returns self.
82
+ #
83
+ # For example:
84
+ # filter.from('src').into('target').using('build'=>Time.now)
85
+ def into(dir)
86
+ @target = file(File.expand_path(dir.to_s)) { |task| run if target == task && !sources.empty? }
87
+ self
88
+ end
89
+
90
+ # :call-seq:
91
+ # include(*files) => self
92
+ #
93
+ # Specifies files to include and returns self. See FileList#include.
94
+ #
95
+ # By default all files are included. You can use this method to only include specific
96
+ # files form the source directory.
97
+ def include(*files)
98
+ @include += files
99
+ self
100
+ end
101
+ alias :add :include
102
+
103
+ # :call-seq:
104
+ # exclude(*files) => self
105
+ #
106
+ # Specifies files to exclude and returns self. See FileList#exclude.
107
+ def exclude(*files)
108
+ @exclude += files
109
+ self
110
+ end
111
+
112
+ # The mapping. See #using.
113
+ attr_accessor :mapping
114
+
115
+ # The mapper to use. See #using.
116
+ attr_accessor :mapper
117
+
118
+ # :call-seq:
119
+ # using(mapping) => self
120
+ # using { |file_name, contents| ... } => self
121
+ #
122
+ # Specifies the mapping to use and returns self.
123
+ #
124
+ # The most typical mapping uses a Hash, and the default mapping uses the Maven style, so
125
+ # <code>${key}</code> are mapped to the values. You can change that by passing a different
126
+ # format as the first argument. Currently supports:
127
+ # * :ant -- Map <code>@key@</code>.
128
+ # * :maven -- Map <code>${key}</code> (default).
129
+ # * :ruby -- Map <code>#{key}</code>.
130
+ # * Regexp -- Maps the matched data (e.g. <code>/=(.*?)=/</code>
131
+ #
132
+ # For example:
133
+ # filter.using 'version'=>'1.2'
134
+ # Is the same as:
135
+ # filter.using :maven, 'version'=>'1.2'
136
+ #
137
+ # You can also pass a proc or method. It will be called with the file name and content,
138
+ # to return the mapped content.
139
+ #
140
+ # Without any mapping, all files are copied as is.
141
+ def using(*args, &block)
142
+ case args.first
143
+ when Hash # Maven hash mapping
144
+ using :maven, *args
145
+ when Symbol # Mapping from a method
146
+ raise ArgumentError, 'Expected mapper type followed by mapping hash' unless args.size == 2 && Hash === args[1]
147
+ @mapper, @mapping = *args
148
+ when Regexp # Mapping using a regular expression
149
+ raise ArgumentError, 'Expected regular expression followed by mapping hash' unless args.size == 2 && Hash === args[1]
150
+ @mapper, @mapping = *args
151
+ else
152
+ raise ArgumentError, 'Expected proc, method or a block' if args.size > 1 || (args.first && block)
153
+ @mapping = args.first || block
154
+ end
155
+ self
156
+ end
157
+
158
+ # :call-seq:
159
+ # run => boolean
160
+ #
161
+ # Runs the filter.
162
+ def run
163
+ raise 'No source directory specified, where am I going to find the files to filter?' if sources.empty?
164
+ sources.each { |source| raise "Source directory #{source} doesn't exist" unless File.exist?(source.to_s) }
165
+ raise 'No target directory specified, where am I going to copy the files to?' if target.nil?
166
+
167
+ copy_map = sources.flatten.map(&:to_s).inject({}) do |map, source|
168
+ files = Util.recursive_with_dot_files(source).
169
+ map { |file| Util.relative_path(file, source) }.
170
+ select { |file| @include.empty? || @include.any? { |pattern| File.fnmatch(pattern, file, File::FNM_PATHNAME) } }.
171
+ reject { |file| @exclude.any? { |pattern| File.fnmatch(pattern, file, File::FNM_PATHNAME) } }
172
+ files.each do |file|
173
+ src, dest = File.expand_path(file, source), File.expand_path(file, target.to_s)
174
+ map[file] = src if !File.exist?(dest) || File.stat(src).mtime > File.stat(dest).mtime
175
+ end
176
+ map
177
+ end
178
+
179
+ return false if copy_map.empty?
180
+
181
+ verbose(Buildr.application.options.trace || false) do
182
+ mkpath target.to_s
183
+ copy_map.each do |path, source|
184
+ dest = File.expand_path(path, target.to_s)
185
+ if File.directory?(source)
186
+ mkpath dest
187
+ else
188
+ mkpath File.dirname(dest)
189
+ case mapping
190
+ when Proc, Method # Call on input, accept output.
191
+ mapped = mapping.call(path, File.open(source, 'rb') { |file| file.read })
192
+ File.open(dest, 'wb') { |file| file.write mapped }
193
+ when Hash # Map ${key} to value
194
+ content = File.open(source, 'rb') { |file| file.read }
195
+ if Symbol === @mapper
196
+ mapped = send("#{@mapper}_mapper", content) { |key| mapping[key] }
197
+ else
198
+ mapped = regexp_mapper(content) { |key| mapping[key] }
199
+ end
200
+ #gsub(/\$\{[^}]*\}/) { |str| mapping[str[2..-2]] || str }
201
+ File.open(dest, 'wb') { |file| file.write mapped }
202
+ when nil # No mapping.
203
+ cp source, dest
204
+ File.chmod(0664, dest)
205
+ else
206
+ fail "Filter can be a hash (key=>value), or a proc/method; I don't understand #{mapping}"
207
+ end
208
+ end
209
+ end
210
+ touch target.to_s
211
+ end
212
+ true
213
+ end
214
+
215
+ # Returns the target directory.
216
+ def to_s
217
+ @target.to_s
218
+ end
219
+
220
+ private
221
+
222
+ def maven_mapper(content)
223
+ content.gsub(/\$\{.*?\}/) { |str| yield(str[2..-2]) || str }
224
+ end
225
+
226
+ def ant_mapper(content)
227
+ content.gsub(/@.*?@/) { |str| yield(str[1..-2]) || str }
228
+ end
229
+
230
+ def ruby_mapper(content)
231
+ content.gsub(/#\{.*?\}/) { |str| yield(str[2..-2]) || str }
232
+ end
233
+
234
+ def regexp_mapper(content)
235
+ content.gsub(@mapper) { |str| yield(str.scan(@mapper).join) || str }
236
+ end
237
+
238
+ end
239
+
240
+ # :call-seq:
241
+ # filter(*source) => Filter
242
+ #
243
+ # Creates a filter that will copy files from the source directory(ies) into the target directory.
244
+ # You can extend the filter to modify files by mapping <tt>${key}</tt> into values in each
245
+ # of the copied files, and by including or excluding specific files.
246
+ #
247
+ # A filter is not a task, you must call the Filter#run method to execute it.
248
+ #
249
+ # For example, to copy all files from one directory to another:
250
+ # filter('src/files').into('target/classes').run
251
+ # To include only the text files, and replace each instance of <tt>${build}</tt> with the current
252
+ # date/time:
253
+ # filter('src/files').into('target/classes').include('*.txt').using('build'=>Time.now).run
254
+ def filter(*sources)
255
+ Filter.new.from(*sources)
256
+ end
257
+
258
+ end
@@ -1,11 +1,28 @@
1
- require 'java/pom'
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require 'buildr/java/pom'
18
+
2
19
 
3
20
  module Buildr
4
21
  module Generate #:nodoc:
5
22
 
6
23
  task "generate" do
7
24
  script = nil
8
- HighLine.new.choose do |menu|
25
+ choose do |menu|
9
26
  menu.header = "To use Buildr you need a buildfile. Do you want me to create one?"
10
27
 
11
28
  menu.choice("From maven2 pom file") { script = Generate.from_maven2_pom(true).join("\n") } if File.exists?("pom.xml")
@@ -14,7 +31,7 @@ module Buildr
14
31
  end
15
32
 
16
33
  if script
17
- buildfile = File.expand_path("buildfile")
34
+ buildfile = File.expand_path(Buildr::Application::DEFAULT_BUILDFILES.first)
18
35
  File.open(buildfile, "w") { |file| file.write script }
19
36
  puts "Created #{buildfile}"
20
37
  end
@@ -85,7 +102,7 @@ EOF
85
102
  if root
86
103
  script = HEADER.split("\n")
87
104
 
88
- settings_file = ENV["M2_SETTINGS"] || File.join(Gem::user_home, ".m2/settings.xml")
105
+ settings_file = ENV["M2_SETTINGS"] || File.join(ENV['HOME'], ".m2/settings.xml")
89
106
  settings = XmlSimple.xml_in(IO.read(settings_file)) if File.exists?(settings_file)
90
107
 
91
108
  if settings
@@ -157,7 +174,7 @@ EOF
157
174
  test_dependencies = test_dependencies.sort.map{|d| "'#{d}'"}.join(', ')
158
175
  script << " test.with #{test_dependencies}" unless test_dependencies.empty?
159
176
 
160
- packaging = project['packaging'].first
177
+ packaging = project['packaging'] ? project['packaging'].first : 'jar'
161
178
  if %w(jar war).include?(packaging)
162
179
  script << " package :#{packaging}, :id => '#{artifactId}'"
163
180
  end
@@ -0,0 +1,118 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+
17
+ require 'buildr/core/common'
18
+ require 'buildr/core/project'
19
+
20
+
21
+ module Buildr
22
+
23
+ module Help #:nodoc:
24
+ class << self
25
+
26
+ def <<(arg)
27
+ if arg.respond_to?(:call)
28
+ texters << arg
29
+ else
30
+ texters << lambda { arg }
31
+ end
32
+ end
33
+
34
+ def to_s
35
+ texters.map(&:call).join("\n")
36
+ end
37
+
38
+ protected
39
+ def texters
40
+ @texters ||= []
41
+ end
42
+
43
+ end
44
+ end
45
+
46
+ class << self
47
+ def help(&block)
48
+ Help << block if block_given?
49
+ Help
50
+ end
51
+ end
52
+
53
+ end
54
+
55
+
56
+ task 'help' do
57
+ # Greeater.
58
+ Buildr.application.usage
59
+ puts
60
+
61
+ # Show only the top-level projects.
62
+ projects.reject(&:parent).tap do |top_level|
63
+ unless top_level.empty?
64
+ puts 'Top-level projects (buildr help:projects for full list):'
65
+ width = [top_level.map(&:name).map(&:size), 20].flatten.max
66
+ top_level.each do |project|
67
+ puts project.comment.to_s.empty? ? project.name : (" %-#{width}s # %s" % [project.name, project.comment])
68
+ end
69
+ puts
70
+ end
71
+ end
72
+
73
+ # Show all the top-level tasks, excluding projects.
74
+ puts 'Common tasks:'
75
+ task('help:tasks').invoke
76
+ puts
77
+ puts 'For help on command line options:'
78
+ puts ' buildr --help'
79
+ puts Buildr.help.to_s
80
+ end
81
+
82
+
83
+ module Buildr
84
+
85
+ # :call-seq:
86
+ # help() { ... }
87
+ #
88
+ # Use this to enhance the help task, e.g. to print some important information about your build,
89
+ # configuration options, build instructions, etc.
90
+ def help(&block)
91
+ Buildr.help << block
92
+ end
93
+
94
+ end
95
+
96
+
97
+ namespace 'help' do
98
+
99
+ desc 'List all projects defined by this buildfile'
100
+ task 'projects' do
101
+ width = projects.map(&:name).map(&:size).max
102
+ projects.each do |project|
103
+ puts project.comment.to_s.empty? ? " #{project.name}" : (" %-#{width}s # %s" % [project.name, project.comment])
104
+ end
105
+ end
106
+
107
+ desc 'List all tasks available from this buildfile'
108
+ task 'tasks' do
109
+ Buildr.application.tasks.select(&:comment).reject { |task| Project === task }.tap do |tasks|
110
+ width = [tasks.map(&:name).map(&:size), 20].flatten.max
111
+ tasks.each do |task|
112
+ printf " %-#{width}s # %s\n", task.name, task.comment
113
+ end
114
+ puts
115
+ end
116
+ end
117
+
118
+ end