buildr 0.22.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,14 @@
1
+ 1.0.0 (5/4/2007)
2
+ * Added: buildr:freeze and buildr:unfreeze task. These set the Rakefile to use a particular version of Buildr, freezing by setting to the current version of Buildr, unfreeze to use the latest Gem.
3
+ * Added: Buildr.options, with three options to start with: test, debug and parallel.
4
+ * Added: Buildr.option.debug or environment variable DEBUG to control the compiler debug option. Defaults to yes, except when doing a release.
5
+ * Changed: Buildr now fails nicely if JAVA_HOME not set.
6
+ * Changed: Migrated test cases to RSpec 0.9.
7
+ * Changed: Extended circular dependency check to multitask.
8
+ * Changed: JavaCC using RJB.
9
+ * Changed: OpenJPA 0.9.7 no longer snapshoted.
10
+ * Fixed: For Windows users: user's home directory, fu_check_options is now rake_check_options, java command works around funky system bbug.
11
+
1
12
  0.22 (4/26/2007)
2
13
  * Added: Calling projects(:in=>foo) returns only the sub-projects defined in foo.
3
14
  * Added: _() as shortcut for path_to().
data/LICENSE CHANGED
@@ -1,202 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright 2006-2007, Intalio Inc.
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
202
-
@@ -30,7 +30,7 @@ end
30
30
 
31
31
 
32
32
  module Buildr
33
- VERSION = "0.22.0"
33
+ VERSION = "1.0.0"
34
34
  end
35
35
 
36
36
  $LOAD_PATH.unshift __DIR__
@@ -54,13 +54,12 @@ class Project ; include Buildr ; end
54
54
  require "builder"
55
55
 
56
56
  module Buildr
57
- @loaded_features_to_ignore = $LOADED_FEATURES +
58
- [Pathname.new(File.expand_path(__FILE__)).relative_path_from(Pathname.new(Dir.pwd)).to_s]
57
+ @loaded_features_to_ignore = $LOADED_FEATURES
59
58
  end
60
59
 
61
60
  # Load the settings files.
62
- [ File.expand_path("buildr.rake", ENV["HOME"] || "~"), File.expand_path("buildr.rake") ].each { |file| load file if File.exist?(file) }
63
- [ File.expand_path("buildr.rb", ENV["HOME"] || "~"), File.expand_path("buildr.rb") ].each do |file|
61
+ [ File.expand_path("buildr.rake", Gem::user_home), File.expand_path("buildr.rake") ].each { |file| load file if File.exist?(file) }
62
+ [ File.expand_path("buildr.rb", Gem::user_home), File.expand_path("buildr.rb") ].each do |file|
64
63
  if File.exist?(file)
65
64
  warn "Please use #{file.ext('rake')} instead of #{file}"
66
65
  require file
@@ -5,33 +5,35 @@ module Buildr
5
5
 
6
6
  REQUIRES = [ "net.java.dev.javacc:javacc:jar:4.0", "net.java.dev.javacc:javacc:jar:4.0" ]
7
7
 
8
+ Java.rjb.onload do
9
+ Java.rjb.classpath << REQUIRES
10
+ end
11
+
8
12
  class << self
9
13
 
10
14
  def javacc(*args)
11
- options = Hash === args.last ? args.pop.clone : {}
12
- options[:verbose] ||= Rake.application.options.trace || false
13
- fu_check_options options, *Java::JAVA_OPTIONS + [:output]
15
+ options = Hash === args.last ? args.pop : {}
16
+ rake_check_options options, :output
14
17
 
15
- (options[:classpath] ||= []) << REQUIRES
16
- java_args = ["javacc"]
17
- java_args << "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
18
- java_args += args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "/**/*.jj"] : f }.flatten
19
- java_args << options.reject { |k, v| !Java::JAVA_OPTIONS.include?(k) }
20
- Java.java(*java_args)
18
+ args = args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "/**/*.jj"] : f }.flatten
19
+ args.unshift "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
20
+ Java.rjb do |rjb|
21
+ rjb.import("org.javacc.parser.Main").mainProgram(args) == 0 or
22
+ fail "Failed to run JavaCC, see errors above."
23
+ end
21
24
  end
22
25
 
23
26
  def jjtree(*args)
24
- options = Hash === args.last ? args.pop.clone : {}
25
- options[:verbose] ||= Rake.application.options.trace || false
26
- fu_check_options options, *Java::JAVA_OPTIONS + [:output, :build_node_files]
27
+ options = Hash === args.last ? args.pop : {}
28
+ rake_check_options options, :output, :build_node_files
27
29
 
28
- (options[:classpath] ||= []) << REQUIRES
29
- java_args = ["jjtree"]
30
- java_args << "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
31
- java_args << "-BUILD_NODE_FILES=#{options[:build_node_files] || false}"
32
- java_args += args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "/**/*.jjt"] : f }.flatten
33
- java_args << options.reject { |k, v| !Java::JAVA_OPTIONS.include?(k) }
34
- Java.java(*java_args)
30
+ args = args.flatten.map(&:to_s).collect { |f| File.directory?(f) ? FileList[f + "**/*.jjt"] : f }.flatten
31
+ args.unshift "-OUTPUT_DIRECTORY=#{options[:output]}" if options[:output]
32
+ args.unshift "-BUILD_NODE_FILES=#{options[:build_node_files] || false}"
33
+ Java.rjb do |rjb|
34
+ rjb.import("org.javacc.jjtree.JJTree").new.main(args) == 0 or
35
+ fail "Failed to run JJTree, see errors above."
36
+ end
35
37
  end
36
38
 
37
39
  end
@@ -3,6 +3,7 @@ require "net/http"
3
3
  require "core/project"
4
4
  require "java/artifact"
5
5
  require "java/java"
6
+ require "thread"
6
7
 
7
8
  module Buildr
8
9
 
@@ -69,16 +70,13 @@ module Buildr
69
70
  # Starts Jetty. This method does not return, it keeps the thread running until
70
71
  # Jetty is stopped. If you want to run Jetty parallel with other tasks in the build,
71
72
  # invoke the #use task instead.
72
- def start(pipe = nil)
73
+ def start(sync = nil)
73
74
  begin
74
75
  Java.rjb do
75
76
  port = URI.parse(url).port
76
- puts "Starting Jetty at http://localhost:#{port}"
77
+ puts "Starting Jetty at http://localhost:#{port}" if verbose
77
78
  jetty = Rjb::import("JettyWrapper").new(port)
78
- if pipe
79
- pipe.puts "Started"
80
- pipe.close
81
- end
79
+ sync << "Started" if sync
82
80
  sleep # Forever
83
81
  end
84
82
  rescue Interrupt # Stopped from console
@@ -118,7 +116,7 @@ module Buildr
118
116
  response = http.request_get("/buildr/")
119
117
  response.is_a?(Net::HTTPSuccess) && response.body =~ /Alive/
120
118
  end
121
- rescue Errno::ECONNREFUSED
119
+ rescue Errno::ECONNREFUSED, Errno::EBADF
122
120
  false
123
121
  end
124
122
  end
@@ -199,17 +197,12 @@ module Buildr
199
197
  # take jetty:start), it will use the existing instance without shutting it down.
200
198
  def fire()
201
199
  unless running?
202
- reader, writer = IO.pipe
203
- if pid = fork
204
- # Wait for Jetty to fire up before doing anything else.
205
- if reader.gets == "Started"
206
- puts "Jetty started"
207
- reader.close
208
- end
209
- at_exit { stop }
210
- else
211
- start writer
212
- end
200
+ sync = Queue.new
201
+ Thread.new { start sync }
202
+ # Wait for Jetty to fire up before doing anything else.
203
+ sync.pop == "Started" or fail "Jetty not started"
204
+ puts "Jetty started" if verbose
205
+ at_exit { stop }
213
206
  end
214
207
  @setup.invoke
215
208
  at_exit { @teardown.invoke }
@@ -3,7 +3,7 @@ require "java/java"
3
3
  module Buildr
4
4
  module OpenJPA
5
5
 
6
- VERSION = "0.9.7-incubating-SNAPSHOT"
6
+ VERSION = "0.9.7-incubating"
7
7
 
8
8
  REQUIRES = [ "org.apache.openjpa:openjpa-all:jar:#{VERSION}",
9
9
  "commons-collections:commons-collections:jar:3.1",
@@ -18,8 +18,8 @@ module Buildr
18
18
  class << self
19
19
 
20
20
  def enhance(options)
21
- fu_check_options options, :classpath, :properties, :output
22
- artifacts = Buildr.artifacts(options[:classpath] || []).each { |a| a.invoke }.map(&:to_s) + [options[:output].to_s]
21
+ rake_check_options options, :classpath, :properties, :output
22
+ artifacts = Buildr.artifacts(options[:classpath]).each { |a| a.invoke }.map(&:to_s) + [options[:output].to_s]
23
23
  properties = file(options[:properties]).tap { |task| task.invoke }.to_s
24
24
 
25
25
  Ant.executable("openjpa") do |ant|
@@ -33,18 +33,18 @@ module Buildr
33
33
  end
34
34
 
35
35
  def mapping_tool(options)
36
- fu_check_options options, :classpath, :properties, :sql, :action
36
+ rake_check_options options, :classpath, :properties, :sql, :action
37
37
  Java.java "org.apache.openjpa.jdbc.meta.MappingTool", "-p", options[:properties].to_s, "-sql", options[:sql],
38
38
  "-sa", options[:action], :classpath=>Buildr.artifacts(options[:classpath], requires), :name=>"Mapping Tool"
39
- =begin
40
39
  # Hopefully this will work in a future release.
41
- artifacts = Buildr.artifacts(options[:classpath] || []).each{ |a| a.invoke }.map(&:to_s) + requires
42
- properties = file(options[:properties]).tap { |task| task.invoke }.to_s
40
+ =begin
41
+ artifacts = Buildr.artifacts(options[:classpath]).each{ |a| a.invoke }.map(&:to_s) + requires
42
+ properties = file(options[:properties].to_s).tap { |task| task.invoke }.to_s
43
43
 
44
44
  Ant.executable("openjpa") do |ant|
45
45
  ant.taskdef :name=>"mapping", :classname=>"org.apache.openjpa.jdbc.ant.MappingToolTask",
46
46
  :classpath=>requires.join(File::PATH_SEPARATOR)
47
- ant.mapping :schemaAction=>options[:action], :sqlFile=>options[:sql].to_s do
47
+ ant.mapping :schemaAction=>options[:action], :sqlFile=>options[:sql].to_s, :ignoreErrors=>"true" do
48
48
  config :propertiesFile=>properties
49
49
  classpath :path=>artifacts.join(File::PATH_SEPARATOR)
50
50
  end
@@ -11,7 +11,7 @@ module Buildr
11
11
  def compile(*args)
12
12
  options = Hash === args.last ? args.pop : {}
13
13
  options[:verbose] ||= Rake.application.options.trace || false
14
- fu_check_options options, :verbose, :noop, :javasource, :jar, :compile, :output, :xsb
14
+ rake_check_options options, :verbose, :noop, :javasource, :jar, :compile, :output, :xsb
15
15
  puts "Running XMLBeans schema compiler" if verbose
16
16
  Ant.executable("xmlbeans") do |ant|
17
17
  ant.taskdef :name=>"xmlbeans", :classname=>"org.apache.xmlbeans.impl.tool.XMLBean",
@@ -1,4 +1,3 @@
1
- require "open3"
2
1
  require "core/project"
3
2
 
4
3
  module Buildr
@@ -20,6 +19,37 @@ module Buildr
20
19
  Project.on_define { |project| project.recursive_task name }
21
20
  end
22
21
 
22
+
23
+ # Collection of options for controlling Buildr. For example for running builds without running
24
+ # test cases, or running builds in parallel.
25
+ class Options
26
+
27
+ # Runs the build in parallel when true (defaults to false). You can force a parallel build by
28
+ # setting this option directly, or by running the parallel task ahead of the build task.
29
+ #
30
+ # This option only affects recurvise tasks. For example:
31
+ # rake parallel package
32
+ # will run all package tasks (from the sub-projects) in parallel, but each sub-project's package
33
+ # task runs its child tasks (prepare, compile, resources, etc) in sequence.
34
+ attr_accessor :parallel
35
+
36
+ end
37
+
38
+ class << self
39
+
40
+ # :call-seq:
41
+ # options() => Options
42
+ #
43
+ # Returns the Buildr options. See Options.
44
+ def options()
45
+ @options ||= Options.new
46
+ end
47
+
48
+ end
49
+
50
+ task("parallel") { Buildr.options.parallel = true }
51
+
52
+
23
53
  class Project
24
54
 
25
55
  # :call-seq:
@@ -59,7 +89,7 @@ module Buildr
59
89
  # Make a release.
60
90
  def make()
61
91
  check
62
- version = with_next_version { |filename, version| sh "rake deploy --rakefile #{filename}" }
92
+ version = with_next_version { |filename, version| sh "rake clean deploy DEBUG=no --rakefile #{filename}" }
63
93
  tag version
64
94
  commit version + "-SNAPSHOT"
65
95
  end
@@ -176,4 +206,24 @@ module Buildr
176
206
  task "release" do |task|
177
207
  Release.make
178
208
  end
209
+
210
+
211
+ namespace "buildr" do
212
+
213
+ desc "Freezes the Rakefile so it always uses Buildr version #{Buildr::VERSION}"
214
+ task "freeze" do
215
+ gem = %Q{gem "buildr", "#{Buildr::VERSION}"}
216
+ rakefile = read(Rake.application.rakefile)
217
+ puts "Freezing the Rakefile so it always uses Buildr version #{Buildr::VERSION}"
218
+ write Rake.application.rakefile, rakefile =~ /gem\s*(["'])buildr\1/ ?
219
+ rakefile.sub(/gem\s*(["'])buildr\1\s*,\s*(["']).*\2/, gem) : gem + "\n" + rakefile
220
+ end
221
+
222
+ desc "Unfreezes the Rakefile to use the latest version of Buildr"
223
+ task "unfreeze" do
224
+ puts "Unfreezing the Rakefile to use the latest version of Buildr from your Gems repository"
225
+ write Rake.application.rakefile, read(Rake.application.rakefile).sub(/^\s*gem\s*(["'])buildr\1.*\n/, "")
226
+ end
227
+
228
+ end
179
229
  end
@@ -35,9 +35,9 @@ module Buildr
35
35
  # For example:
36
36
  # write("README") { read("README").sub("${build}", Time.now) }
37
37
  def write(name, content = nil)
38
- mkpath File.dirname(name)
38
+ mkpath File.dirname(name), :verbose=>false
39
39
  content = yield if block_given?
40
- File.open(name.to_s, "w") { |file| file.write content.to_s }
40
+ File.open(name.to_s, "wb") { |file| file.write content.to_s }
41
41
  content.to_s
42
42
  end
43
43
 
@@ -52,10 +52,11 @@ module Buildr
52
52
  # puts read("README")
53
53
  # read("README") { |text| puts text }
54
54
  def read(name)
55
+ contents = File.open(name.to_s) { |f| f.read }
55
56
  if block_given?
56
- yield File.read(name.to_s)
57
+ yield contents
57
58
  else
58
- File.read(name.to_s)
59
+ contents
59
60
  end
60
61
  end
61
62
 
@@ -162,6 +162,7 @@ module Buildr
162
162
  # See Buildr#projects.
163
163
  def projects(*names) #:nodoc:
164
164
  options = names.pop if Hash === names.last
165
+ rake_check_options options, :in if options
165
166
  @projects ||= {}
166
167
  names = @projects.keys if names.empty?
167
168
  if options && options[:in]
@@ -448,7 +449,7 @@ module Buildr
448
449
  def recursive_task(args, &block)
449
450
  task_name, deps = Rake.application.resolve_args(args)
450
451
  deps = [deps] unless deps.respond_to?(:to_ary)
451
- task = ENV["PARALLEL"] =~ /(yes|on|true)/ ? multitask(task_name) : task(task_name)
452
+ task = Buildr.options.parallel ? multitask(task_name) : task(task_name)
452
453
  Rake.application.lookup(task_name, parent.name.split(":")).enhance [task] if parent
453
454
  task.enhance deps, &block
454
455
  end
@@ -2,9 +2,8 @@ module Rake #:nodoc:
2
2
  class Task
3
3
 
4
4
  def invoke #:nodoc:
5
- tasks = (Thread.current[:tasks] || [])
6
- if tasks.include?(name)
7
- fail "Circular dependency " + (tasks + [name]).join("=>")
5
+ if stack.include?(name)
6
+ fail "Circular dependency " + (stack + [name]).join("=>")
8
7
  end
9
8
  @lock.synchronize do
10
9
  if application.options.trace
@@ -12,12 +11,12 @@ module Rake #:nodoc:
12
11
  end
13
12
  return if @already_invoked
14
13
  begin
15
- Thread.current[:tasks] = tasks + [name]
14
+ stack.push name
16
15
  @already_invoked = true
17
16
  invoke_prerequisites
18
17
  execute if needed?
19
18
  ensure
20
- Thread.current[:tasks] = tasks
19
+ stack.pop
21
20
  end
22
21
  end
23
22
  end
@@ -26,6 +25,22 @@ module Rake #:nodoc:
26
25
  prerequisites.each { |n| application[n, @scope].invoke }
27
26
  end
28
27
 
28
+ protected
29
+
30
+ def stack()
31
+ Thread.current[:rake_stack] ||= []
32
+ end
33
+
34
+ end
35
+
36
+ class MultiTask
37
+ def invoke_prerequisites
38
+ threads = @prerequisites.collect do |p|
39
+ copy = stack.dup
40
+ Thread.new(p) { |r| stack.replace copy ; application[r].invoke }
41
+ end
42
+ threads.each { |t| t.join }
43
+ end
29
44
  end
30
45
 
31
46
  class Application #:nodoc:
@@ -269,6 +269,7 @@ module Buildr
269
269
 
270
270
  def initialize(url, options)
271
271
  super
272
+ rake_check_options options, :digests if options
272
273
  @http = Net::HTTP.start(@uri.host, @uri.port)
273
274
  end
274
275
 
@@ -317,7 +318,8 @@ module Buildr
317
318
  # If download breaks we end up with a partial file which is
318
319
  # worse than not having a file at all, so download to temporary
319
320
  # file and then move over.
320
- temp = Tempfile.new(File.basename(target))
321
+ temp = Tempfile.open(File.basename(target))
322
+ temp.binmode
321
323
  download[ proc { |chunk| temp.write chunk } ]
322
324
  temp.close
323
325
  File.move temp.path, target
@@ -360,6 +362,7 @@ module Buildr
360
362
 
361
363
  def initialize(url, options)
362
364
  super
365
+ rake_check_options options, :digests, :permissions, :port, :uri, :username, :password
363
366
  @permissions = options.delete :permissions
364
367
  # SSH options are based on the username/password from the URI.
365
368
  ssh_options = { :port=>@uri.port, :username=>@uri.user }.merge(options || {})
@@ -162,6 +162,7 @@ module Buildr
162
162
  if spec.respond_to?(:to_spec)
163
163
  to_hash spec.to_spec
164
164
  elsif Hash === spec
165
+ rake_check_options spec, :id, :group, :type, :classifier, :version
165
166
  # Sanitize the hash and check it's valid.
166
167
  spec = ARTIFACT_ATTRIBUTES.inject({}) { |h, k| h[k] = spec[k].to_s if spec[k] ; h }
167
168
  fail "Missing group identifier for #{spec.inspect}" if spec[:group].blank?
@@ -256,7 +257,7 @@ module Buildr
256
257
  #
257
258
  # The default path is .m2/repository relative to the home directory.
258
259
  def local()
259
- @local ||= ENV["local_repo"] || File.join(ENV["HOME"], ".m2/repository")
260
+ @local ||= ENV["local_repo"] || File.join(Gem::user_home, ".m2/repository")
260
261
  end
261
262
 
262
263
  # :call-seq:
@@ -49,10 +49,10 @@ module Buildr
49
49
 
50
50
  # Generate warnings (opposite of -nowarn).
51
51
  attr_accessor :warnings
52
- inherited_attr :warnings
52
+ inherited_attr :warnings, false
53
53
  # Output source locations where deprecated APIs are used.
54
54
  attr_accessor :deprecation
55
- inherited_attr :deprecation
55
+ inherited_attr :deprecation, false
56
56
  # Provide source compatibility with specified release.
57
57
  attr_accessor :source
58
58
  inherited_attr :source
@@ -62,10 +62,10 @@ module Buildr
62
62
  # Values to pass to Xlint: string or array. Use true to enable
63
63
  # Xlint with no values.
64
64
  attr_accessor :lint
65
- inherited_attr :lint
65
+ inherited_attr :lint, false
66
66
  # Generate all debugging info.
67
67
  attr_accessor :debug
68
- inherited_attr :debug
68
+ inherited_attr(:debug) { Buildr.options.debug }
69
69
  # Array of arguments passed to the Java compiler as is.
70
70
  attr_accessor :other
71
71
  inherited_attr :other
@@ -557,4 +557,20 @@ module Buildr
557
557
  end
558
558
  end
559
559
 
560
+
561
+ class Options
562
+
563
+ # Runs the compile in debugging mode when true (default).
564
+ #
565
+ # You can turn this option off directly, or by setting the environment variable
566
+ # DEBUG to "no". For example:
567
+ # rake build DEBUG=no
568
+ #
569
+ # The release tasks runs a build with <tt>DEBUG=no</tt>.
570
+ attr_accessor :debug
571
+
572
+ end
573
+
574
+ options.debug = (ENV["DEBUG"] || ENV["debug"]) !~ /(no|off|false)/
575
+
560
576
  end
@@ -76,7 +76,7 @@ module Buildr
76
76
  # puts Java.version
77
77
  # => 1.5.0_10
78
78
  def version()
79
- @version ||= `#{path_to_bin("java")} -version 2>&1`.scan(/java version "(.*)"/)[0][0]
79
+ @version ||= `"#{path_to_bin("java")}" -version 2>&1`.scan(/java version "(.*)"/)[0][0]
80
80
  end
81
81
 
82
82
  # :call-seq:
@@ -85,12 +85,19 @@ module Buildr
85
85
  # Returns a path to tools.jar.
86
86
  def tools_jar()
87
87
  unless @tools
88
- home = ENV["JAVA_HOME"] || File.dirname(File.dirname(`which java`.split.first))
89
88
  tools = File.join(home, "lib/tools.jar")
90
89
  @tools = tools if File.exist?(tools)
91
90
  end
92
91
  @tools
93
92
  end
93
+
94
+ # :call-seq:
95
+ # home() => path
96
+ #
97
+ # Returns JAVA_HOME.
98
+ def home()
99
+ @home ||= ENV["JAVA_HOME"] or fail "Are we forgetting something? JAVA_HOME not set?"
100
+ end
94
101
 
95
102
  # :call-seq:
96
103
  # java(class, *args, options?)
@@ -104,22 +111,25 @@ module Buildr
104
111
  # * :properties -- Hash of system properties (e.g. "path"=>base_dir).
105
112
  # * :name -- Shows this name, otherwise shows the first argument (the class name).
106
113
  # * :verbose -- If true, prints the command and all its argument.
107
- def java(*args)
114
+ def java(*args, &block)
108
115
  options = Hash === args.last ? args.pop : {}
109
116
  options[:verbose] ||= Rake.application.options.trace || false
110
- fu_check_options options, *JAVA_OPTIONS
117
+ rake_check_options options, *JAVA_OPTIONS
111
118
 
112
119
  name = options[:name] || "java #{args.first}"
113
- cmd_args = []
120
+ cmd_args = [path_to_bin("java")]
114
121
  classpath = classpath_from(options)
115
122
  cmd_args << "-cp" << classpath.join(File::PATH_SEPARATOR) unless classpath.empty?
116
123
  options[:properties].each { |k, v| cmd_args << "-D#{k}=#{v}" } if options[:properties]
117
124
  cmd_args += options[:java_args].flatten if options[:java_args]
118
125
  cmd_args += args.flatten.compact
119
- cmd_args << { :verbose=>options[:verbose] }
120
126
  unless Rake.application.options.dryrun
121
127
  puts "Running #{name}" if verbose
122
- sh(path_to_bin("java"), *cmd_args) { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok }
128
+ block = lambda { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok } unless block
129
+ puts cmd_args.join(" ") if Rake.application.options.trace
130
+ system(cmd_args.map { |arg| %Q{"#{arg}"} }.join(" ")).tap do |ok|
131
+ block.call ok, $?
132
+ end
123
133
  end
124
134
  end
125
135
 
@@ -137,7 +147,7 @@ module Buildr
137
147
  # These are all expanded into artifacts, and all tasks are invoked.
138
148
  def apt(*args)
139
149
  options = Hash === args.last ? args.pop : {}
140
- fu_check_options options, :compile, :source, :output, :classpath
150
+ rake_check_options options, :compile, :source, :output, :classpath
141
151
 
142
152
  files = args.flatten.map(&:to_s).
143
153
  collect { |arg| File.directory?(arg) ? FileList["#{arg}/**/*.java"] : arg }.flatten
@@ -175,7 +185,7 @@ module Buildr
175
185
  # * :name -- Shows this name, otherwise shows the working directory.
176
186
  def javac(*args)
177
187
  options = Hash === args.last ? args.pop : {}
178
- fu_check_options options, :classpath, :sourcepath, :output, :javac_args, :name
188
+ rake_check_options options, :classpath, :sourcepath, :output, :javac_args, :name
179
189
 
180
190
  files = args.flatten.each { |f| f.invoke if f.respond_to?(:invoke) }.map(&:to_s).
181
191
  collect { |arg| File.directory?(arg) ? FileList["#{arg}/**/*.java"] : arg }.flatten
@@ -267,7 +277,7 @@ module Buildr
267
277
  def junit(*args)
268
278
  options = Hash === args.last ? args.pop : {}
269
279
  options[:verbose] ||= Rake.application.options.trace || false
270
- fu_check_options options, :verbose, :classpath, :properties
280
+ rake_check_options options, :verbose, :classpath, :properties
271
281
 
272
282
  classpath = classpath_from(options) + junit_artifacts
273
283
  tests = args.flatten
@@ -315,7 +325,7 @@ module Buildr
315
325
  # Returns the path to the specified Java command (with no argument to java itself).
316
326
  # Uses JAVA_HOME if set, otherwise assumes the command is accessible from the path.
317
327
  def path_to_bin(name = "java")
318
- ENV["JAVA_HOME"] ? File.join(ENV["JAVA_HOME"], "bin", name) : name
328
+ File.join(home, "bin", name)
319
329
  end
320
330
 
321
331
  protected
@@ -240,7 +240,7 @@ module Buildr
240
240
  packager.call(file_name, options) do |package|
241
241
  # Make it an artifact using the specifications, and tell it how to create a POM.
242
242
  package.extend ActsAsArtifact
243
- package.send :apply_spec, options
243
+ package.send :apply_spec, Hash[*Artifact::ARTIFACT_ATTRIBUTES.map { |k| [ k,options[k]] }.flatten]
244
244
  # Another task to create the POM file.
245
245
  pom_spec = package.to_spec_hash.merge(:type=>:pom)
246
246
  pom = file(Buildr.repositories.locate(pom_spec))
@@ -310,7 +310,7 @@ module Buildr
310
310
 
311
311
  def package_as_jar(file_name, options) #:nodoc:
312
312
  unless Rake::Task.task_defined?(file_name)
313
- fu_check_options options, *PACKAGE_OPTIONS + [:manifest, :meta_inf, :include]
313
+ rake_check_options options, *PACKAGE_OPTIONS + [:manifest, :meta_inf, :include]
314
314
  Java::Packaging::JarTask.define_task(file_name).tap do |jar|
315
315
  jar.manifest = options.has_key?(:manifest) ? options[:manifest] : manifest
316
316
  jar.meta_inf = options[:meta_inf] || meta_inf
@@ -323,14 +323,14 @@ module Buildr
323
323
  yield jar
324
324
  end
325
325
  else
326
- fu_check_options options, *PACKAGE_OPTIONS
326
+ rake_check_options options, *PACKAGE_OPTIONS
327
327
  end
328
328
  file(file_name)
329
329
  end
330
330
 
331
331
  def package_as_war(file_name, options) #:nodoc:
332
332
  unless Rake::Task.task_defined?(file_name)
333
- fu_check_options options, *PACKAGE_OPTIONS + [:manifest, :meta_inf, :classes, :libs, :include]
333
+ rake_check_options options, *PACKAGE_OPTIONS + [:manifest, :meta_inf, :classes, :libs, :include]
334
334
  Java::Packaging::WarTask.define_task(file_name).tap do |war|
335
335
  war.manifest = options.has_key?(:manifest) ? options[:manifest] : manifest
336
336
  war.meta_inf = options[:meta_inf] || meta_inf
@@ -356,14 +356,14 @@ module Buildr
356
356
  yield war
357
357
  end
358
358
  else
359
- fu_check_options options, *PACKAGE_OPTIONS
359
+ rake_check_options options, *PACKAGE_OPTIONS
360
360
  end
361
361
  file(file_name)
362
362
  end
363
363
 
364
364
  def package_as_zip(file_name, options) #:nodoc:
365
365
  unless Rake::Task.task_defined?(file_name)
366
- fu_check_options options, *PACKAGE_OPTIONS + [:include]
366
+ rake_check_options options, *PACKAGE_OPTIONS + [:include]
367
367
  ZipTask.define_task(file_name).tap do |zip|
368
368
  if options[:include]
369
369
  zip.include options[:include]
@@ -371,7 +371,7 @@ module Buildr
371
371
  yield zip
372
372
  end
373
373
  else
374
- fu_check_options options, *PACKAGE_OPTIONS
374
+ rake_check_options options, *PACKAGE_OPTIONS
375
375
  end
376
376
  file(file_name)
377
377
  end
@@ -322,10 +322,28 @@ module Buildr
322
322
  each(&:invoke)
323
323
  end
324
324
 
325
- # Require tests after build unless TEST option is off.
326
- # For example:
327
- # rake build
328
- # rake build TEST=off
329
- task("build") { task("test").invoke } unless ENV["TEST"] =~ /(off|false|no)/
325
+
326
+ class Options
327
+
328
+ # Runs test cases after the build when true (default). This forces test cases to execute
329
+ # after the build, including when running build related tasks like install, deploy and release.
330
+ #
331
+ # You can skip test cases by turning this option off directly, or by setting the environment
332
+ # variable TEST to "no". For example:
333
+ # rake build # With tests
334
+ # rake build TEST=no # Without tests
335
+ attr_accessor :test
336
+
337
+ end
338
+
339
+ options.test = (ENV["TEST"] || ENV["test"]) !~ /(no|off|false)/
340
+
341
+ task("build") do |task|
342
+ # Make sure this happens as the last action on the build, so all other enhancements
343
+ # are made to run before starting the test cases.
344
+ task.enhance do
345
+ task("test").invoke if Buildr.options.test
346
+ end
347
+ end
330
348
 
331
349
  end
@@ -14,7 +14,7 @@ module Buildr
14
14
  content << File.read(prereq.to_s) if File.exists?(prereq) && !File.directory?(prereq)
15
15
  content
16
16
  end
17
- File.open(task.name, "w") { |file| file.write content }
17
+ File.open(task.name, "wb") { |file| file.write content }
18
18
  end
19
19
  end
20
20
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: buildr
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.22.0
7
- date: 2007-04-26 00:00:00 -07:00
6
+ version: 1.0.0
7
+ date: 2007-05-04 00:00:00 -07:00
8
8
  summary: A build system that doesn't suck
9
9
  require_paths:
10
10
  - lib
@@ -94,34 +94,34 @@ dependencies:
94
94
  version_requirement:
95
95
  version_requirements: !ruby/object:Gem::Version::Requirement
96
96
  requirements:
97
- - - ">="
97
+ - - "="
98
98
  - !ruby/object:Gem::Version
99
- version: 1.8.0
99
+ version: 1.8.54
100
100
  version:
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: builder
103
103
  version_requirement:
104
104
  version_requirements: !ruby/object:Gem::Version::Requirement
105
105
  requirements:
106
- - - ">="
106
+ - - "="
107
107
  - !ruby/object:Gem::Version
108
- version: 2.0.0
108
+ version: 2.1.1
109
109
  version:
110
110
  - !ruby/object:Gem::Dependency
111
111
  name: net-ssh
112
112
  version_requirement:
113
113
  version_requirements: !ruby/object:Gem::Version::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "="
116
116
  - !ruby/object:Gem::Version
117
- version: 1.0.0
117
+ version: 1.1.0
118
118
  version:
119
119
  - !ruby/object:Gem::Dependency
120
120
  name: net-sftp
121
121
  version_requirement:
122
122
  version_requirements: !ruby/object:Gem::Version::Requirement
123
123
  requirements:
124
- - - ">="
124
+ - - "="
125
125
  - !ruby/object:Gem::Version
126
126
  version: 1.1.0
127
127
  version:
@@ -130,16 +130,16 @@ dependencies:
130
130
  version_requirement:
131
131
  version_requirements: !ruby/object:Gem::Version::Requirement
132
132
  requirements:
133
- - - ">="
133
+ - - "="
134
134
  - !ruby/object:Gem::Version
135
- version: 0.9.0
135
+ version: 0.9.1
136
136
  version:
137
137
  - !ruby/object:Gem::Dependency
138
138
  name: highline
139
139
  version_requirement:
140
140
  version_requirements: !ruby/object:Gem::Version::Requirement
141
141
  requirements:
142
- - - ">="
142
+ - - "="
143
143
  - !ruby/object:Gem::Version
144
144
  version: 1.2.7
145
145
  version:
@@ -148,7 +148,7 @@ dependencies:
148
148
  version_requirement:
149
149
  version_requirements: !ruby/object:Gem::Version::Requirement
150
150
  requirements:
151
- - - ">="
151
+ - - "="
152
152
  - !ruby/object:Gem::Version
153
153
  version: 1.0.3
154
154
  version:
@@ -157,7 +157,7 @@ dependencies:
157
157
  version_requirement:
158
158
  version_requirements: !ruby/object:Gem::Version::Requirement
159
159
  requirements:
160
- - - ">="
160
+ - - "="
161
161
  - !ruby/object:Gem::Version
162
- version: 0.5.0
162
+ version: 0.5.2
163
163
  version: