vic-buildr 1.3.1 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. data/CHANGELOG +90 -8
  2. data/{README → README.rdoc} +29 -16
  3. data/Rakefile +17 -19
  4. data/_buildr +50 -0
  5. data/addon/buildr/cobertura.rb +47 -44
  6. data/addon/buildr/emma.rb +237 -0
  7. data/addon/buildr/jetty.rb +1 -1
  8. data/addon/buildr/nailgun.rb +581 -661
  9. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail$Main.class +0 -0
  10. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.class +0 -0
  11. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.java +0 -0
  12. data/addon/buildr/xmlbeans.rb +1 -1
  13. data/bin/buildr +9 -2
  14. data/buildr.buildfile +53 -0
  15. data/buildr.gemspec +23 -15
  16. data/doc/css/default.css +51 -48
  17. data/doc/css/print.css +60 -55
  18. data/doc/css/syntax.css +40 -31
  19. data/doc/images/growl-icon.tiff +0 -0
  20. data/doc/images/project-structure.png +0 -0
  21. data/doc/pages/artifacts.textile +46 -156
  22. data/doc/pages/building.textile +63 -324
  23. data/doc/pages/contributing.textile +116 -88
  24. data/doc/pages/download.textile +20 -15
  25. data/doc/pages/extending.textile +27 -81
  26. data/doc/pages/getting_started.textile +47 -111
  27. data/doc/pages/index.textile +19 -37
  28. data/doc/pages/languages.textile +407 -0
  29. data/doc/pages/more_stuff.textile +92 -173
  30. data/doc/pages/packaging.textile +72 -237
  31. data/doc/pages/projects.textile +58 -233
  32. data/doc/pages/recipes.textile +19 -43
  33. data/doc/pages/settings_profiles.textile +39 -104
  34. data/doc/pages/testing.textile +41 -304
  35. data/doc/pages/troubleshooting.textile +29 -47
  36. data/doc/pages/whats_new.textile +66 -157
  37. data/doc/print.haml +0 -1
  38. data/doc/print.toc.yaml +1 -0
  39. data/doc/scripts/buildr-git.rb +1 -1
  40. data/doc/scripts/install-jruby.sh +1 -1
  41. data/doc/scripts/install-linux.sh +4 -4
  42. data/doc/site.toc.yaml +8 -5
  43. data/{KEYS → etc/KEYS} +0 -0
  44. data/etc/git-svn-authors +16 -0
  45. data/lib/buildr.rb +2 -13
  46. data/lib/buildr/core/application.rb +200 -95
  47. data/lib/buildr/core/application_cli.rb +6 -1
  48. data/lib/buildr/core/build.rb +140 -91
  49. data/lib/buildr/core/checks.rb +5 -5
  50. data/lib/buildr/core/common.rb +1 -1
  51. data/lib/buildr/core/compile.rb +14 -12
  52. data/lib/buildr/core/filter.rb +151 -46
  53. data/lib/buildr/core/generate.rb +9 -7
  54. data/lib/buildr/core/progressbar.rb +1 -1
  55. data/lib/buildr/core/project.rb +8 -7
  56. data/lib/buildr/core/test.rb +54 -29
  57. data/lib/buildr/core/transports.rb +25 -20
  58. data/lib/buildr/core/util.rb +80 -26
  59. data/lib/buildr/groovy.rb +18 -0
  60. data/lib/buildr/groovy/bdd.rb +105 -0
  61. data/lib/buildr/groovy/compiler.rb +138 -0
  62. data/lib/buildr/ide/eclipse.rb +102 -71
  63. data/lib/buildr/ide/idea.rb +7 -12
  64. data/lib/buildr/ide/idea7x.rb +20 -20
  65. data/lib/buildr/java.rb +4 -7
  66. data/lib/buildr/java/ant.rb +26 -5
  67. data/lib/buildr/java/bdd.rb +447 -0
  68. data/lib/buildr/java/commands.rb +8 -9
  69. data/lib/buildr/java/{compilers.rb → compiler.rb} +8 -90
  70. data/lib/buildr/java/jruby.rb +29 -11
  71. data/lib/buildr/java/jtestr_runner.rb.erb +114 -0
  72. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  73. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +4 -1
  74. data/lib/buildr/java/packaging.rb +23 -16
  75. data/lib/buildr/java/pom.rb +1 -1
  76. data/lib/buildr/java/rjb.rb +21 -8
  77. data/lib/buildr/java/test_result.rb +277 -0
  78. data/lib/buildr/java/{test_frameworks.rb → tests.rb} +121 -88
  79. data/lib/buildr/packaging/artifact.rb +12 -11
  80. data/lib/buildr/packaging/artifact_namespace.rb +7 -4
  81. data/lib/buildr/packaging/gems.rb +3 -3
  82. data/lib/buildr/packaging/zip.rb +13 -10
  83. data/lib/buildr/resources/buildr.icns +0 -0
  84. data/lib/buildr/scala.rb +19 -0
  85. data/lib/buildr/scala/compiler.rb +109 -0
  86. data/lib/buildr/scala/tests.rb +203 -0
  87. data/rakelib/apache.rake +31 -41
  88. data/rakelib/doc.rake +2 -2
  89. data/rakelib/package.rake +31 -2
  90. data/rakelib/rspec.rake +22 -20
  91. data/rakelib/rubyforge.rake +1 -0
  92. data/rakelib/setup.rake +34 -9
  93. data/spec/addon/cobertura_spec.rb +77 -0
  94. data/spec/addon/emma_spec.rb +120 -0
  95. data/spec/addon/test_coverage_spec.rb +249 -0
  96. data/spec/{application_spec.rb → core/application_spec.rb} +82 -4
  97. data/spec/{artifact_namespace_spec.rb → core/artifact_namespace_spec.rb} +12 -1
  98. data/spec/core/build_spec.rb +415 -0
  99. data/spec/{checks_spec.rb → core/checks_spec.rb} +1 -1
  100. data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
  101. data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
  102. data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
  103. data/spec/{test_spec.rb → core/test_spec.rb} +226 -32
  104. data/spec/{transport_spec.rb → core/transport_spec.rb} +35 -23
  105. data/spec/groovy/bdd_spec.rb +80 -0
  106. data/spec/{groovy_compilers_spec.rb → groovy/compiler_spec.rb} +1 -1
  107. data/spec/ide/eclipse_spec.rb +243 -0
  108. data/spec/{java_spec.rb → java/ant.rb} +7 -17
  109. data/spec/java/bdd_spec.rb +358 -0
  110. data/spec/{java_compilers_spec.rb → java/compiler_spec.rb} +1 -1
  111. data/spec/java/java_spec.rb +88 -0
  112. data/spec/{java_packaging_spec.rb → java/packaging_spec.rb} +65 -4
  113. data/spec/{java_test_frameworks_spec.rb → java/tests_spec.rb} +50 -10
  114. data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
  115. data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +10 -3
  116. data/spec/{packaging_helper.rb → packaging/packaging_helper.rb} +0 -0
  117. data/spec/{packaging_spec.rb → packaging/packaging_spec.rb} +1 -1
  118. data/spec/sandbox.rb +25 -4
  119. data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
  120. data/spec/scala/tests_spec.rb +215 -0
  121. data/spec/spec_helpers.rb +38 -17
  122. metadata +119 -69
  123. data/lib/buildr/java/bdd_frameworks.rb +0 -265
  124. data/lib/buildr/java/groovyc.rb +0 -137
  125. data/spec/build_spec.rb +0 -193
  126. data/spec/java_bdd_frameworks_spec.rb +0 -238
  127. data/spec/spec.opts +0 -6
@@ -54,6 +54,8 @@ module Buildr
54
54
  'Require MODULE before executing buildfile.'],
55
55
  ['--trace', '-t', GetoptLong::NO_ARGUMENT,
56
56
  'Turn on invoke/execute tracing, enable full backtrace.'],
57
+ ['--prereqs', '-P', GetoptLong::OPTIONAL_ARGUMENT,
58
+ 'Display tasks and dependencies, then exit.'],
57
59
  ['--version', '-v', GetoptLong::NO_ARGUMENT,
58
60
  'Display the program version.'],
59
61
  ['--environment', '-e', GetoptLong::REQUIRED_ARGUMENT,
@@ -92,6 +94,9 @@ module Buildr
92
94
  ENV['BUILDR_ENV'] = value
93
95
  when '--require'
94
96
  requires << value
97
+ when '--prereqs'
98
+ options.show_prereqs = true
99
+ options.show_task_pattern = Regexp.new(value || '.')
95
100
  when '--nosearch', '--quiet', '--trace'
96
101
  super
97
102
  end
@@ -129,6 +134,6 @@ module Buildr
129
134
  puts 'For help with your buildfile:'
130
135
  puts ' buildr help'
131
136
  end
132
-
137
+
133
138
  end
134
139
  end
@@ -27,7 +27,7 @@ module Buildr
27
27
  # Runs the build in parallel when true (defaults to false). You can force a parallel build by
28
28
  # setting this option directly, or by running the parallel task ahead of the build task.
29
29
  #
30
- # This option only affects recurvise tasks. For example:
30
+ # This option only affects recursive tasks. For example:
31
31
  # buildr parallel package
32
32
  # will run all package tasks (from the sub-projects) in parallel, but each sub-project's package
33
33
  # task runs its child tasks (prepare, compile, resources, etc) in sequence.
@@ -48,7 +48,7 @@ module Buildr
48
48
  desc 'Clean files generated during a build'
49
49
  Project.local_task('clean') { |name| "Cleaning #{name}" }
50
50
 
51
- desc 'The default task it build'
51
+ desc 'The default task is build'
52
52
  task 'default'=>'build'
53
53
  end
54
54
 
@@ -109,146 +109,195 @@ module Buildr
109
109
  end
110
110
 
111
111
 
112
+ class Svn
113
+
114
+ class << self
115
+ def commit(file, message)
116
+ svn 'commit', '-m', message, file
117
+ end
118
+
119
+ def copy(dir, url, message)
120
+ svn 'copy', dir, url, '-m', message
121
+ end
122
+
123
+ # Return the current SVN URL
124
+ def repo_url
125
+ svn('info').scan(/URL: (.*)/)[0][0]
126
+ end
127
+
128
+ def remove(url, message)
129
+ svn 'remove', url, '-m', message
130
+ end
131
+
132
+ # Status check reveals modified files, but also SVN externals which we can safely ignore.
133
+ def uncommitted_files
134
+ svn('status', '--ignore-externals').reject { |line| line =~ /^X\s/ }
135
+ end
136
+
137
+ # :call-seq:
138
+ # svn(*args)
139
+ #
140
+ # Executes SVN command and returns the output.
141
+ def svn(*args)
142
+ cmd = 'svn ' + args.map { |arg| arg[' '] ? %Q{"#{arg}"} : arg }.join(' ')
143
+ trace cmd
144
+ `#{cmd}`.tap { fail 'SVN command failed' unless $?.exitstatus == 0 }
145
+ end
146
+ end
147
+ end
148
+
149
+
112
150
  class Release
113
151
 
114
- THIS_VERSION_PATTERN = /THIS_VERSION|VERSION_NUMBER\s*=\s*(["'])(.*)\1/
115
- NEXT_VERSION_PATTERN = /NEXT_VERSION\s*=\s*(["'])(.*)\1/
152
+ THIS_VERSION_PATTERN = /(THIS_VERSION|VERSION_NUMBER)\s*=\s*(["'])(.*)\2/
116
153
 
117
154
  class << self
155
+
156
+ # Use this to specify a different tag name for tagging the release in source control.
157
+ # You can set the tag name or a proc that will be called with the version number,
158
+ # for example:
159
+ # Release.tag_name = lambda { |ver| "foo-#{ver}" }
160
+ attr_accessor :tag_name
118
161
 
119
162
  # :call-seq:
120
163
  # make()
121
164
  #
122
165
  # Make a release.
123
- def make()
166
+ def make
124
167
  check
125
- version = with_next_version do |filename, version|
126
- options = ['--buildfile', filename, 'DEBUG=no']
168
+ with_release_candidate_version do |release_candidate_buildfile|
169
+ options = ['--buildfile', release_candidate_buildfile, 'DEBUG=no']
127
170
  options << '--environment' << Buildr.environment unless Buildr.environment.to_s.empty?
128
- sh "#{command} clean upload #{options.join(' ')}"
171
+ buildr %w{clean upload}, options
129
172
  end
130
- tag version
131
- commit version + '-SNAPSHOT'
173
+ tag_release
174
+ commit_new_snapshot
132
175
  end
133
176
 
134
- protected
135
-
136
- def command() #:nodoc:
137
- Config::CONFIG['arch'] =~ /dos|win32/i ? $PROGRAM_NAME.ext('cmd') : $PROGRAM_NAME
177
+ # :call-seq:
178
+ # extract_version() => this_version
179
+ #
180
+ # Extract the current version number from the buildfile.
181
+ # Raise an error if not found.
182
+ def extract_version
183
+ buildfile = File.read(Buildr.application.buildfile.to_s)
184
+ buildfile.scan(THIS_VERSION_PATTERN)[0][2]
185
+ rescue
186
+ fail 'Looking for THIS_VERSION = "..." in your Buildfile, none found'
138
187
  end
139
-
188
+
189
+ # :call-seq:
190
+ # tag_url(svn_url, version) => tag_url
191
+ #
192
+ # Returns the SVN url for the tag.
193
+ # Can tag from the trunk or from branches.
194
+ # Can handle the two standard repository layouts.
195
+ # - http://my.repo/foo/trunk => http://my.repo/foo/tags/1.0.0
196
+ # - http://my.repo/trunk/foo => http://my.repo/tags/foo/1.0.0
197
+ def tag_url(svn_url, version)
198
+ trunk_or_branches = Regexp.union(%r{^(.*)/trunk(.*)$}, %r{^(.*)/branches(.*)/([^/]*)$})
199
+ match = trunk_or_branches.match(svn_url)
200
+ prefix = match[1] || match[3]
201
+ suffix = match[2] || match[4]
202
+ tag = tag_name || version
203
+ tag = tag.call(version) if Proc === tag
204
+ prefix + '/tags' + suffix + '/' + tag
205
+ end
206
+
140
207
  # :call-seq:
141
208
  # check()
142
209
  #
143
210
  # Check that we don't have any local changes in the working copy. Fails if it finds anything
144
211
  # in the working copy that is not checked into source control.
145
- def check()
146
- fail "SVN URL must end with 'trunk' or 'branches/...'" unless svn_url =~ /(trunk)|(branches.*)$/
147
- # Status check reveals modified file, but also SVN externals which we can safely ignore.
148
- status = svn('status', '--ignore-externals').reject { |line| line =~ /^X\s/ }
149
- fail "Uncommitted SVN files violate the First Principle Of Release!\n#{status}" unless
150
- status.empty?
212
+ def check
213
+ fail "SVN URL must contain 'trunk' or 'branches/...'" unless Svn.repo_url =~ /(trunk)|(branches.*)$/
214
+ fail "Uncommitted SVN files violate the First Principle Of Release!\n#{Svn.uncommitted_files}" unless Svn.uncommitted_files.empty?
151
215
  end
152
216
 
217
+ protected
218
+
153
219
  # :call-seq:
154
- # with_next_version() { |filename| ... } => version
220
+ # buildr(tasks, options)
155
221
  #
156
- # Yields to block with upgraded version number, before committing to use it. Returns the *new*
157
- # current version number.
222
+ # Calls another instance of buildr.
223
+ def buildr(tasks, options)
224
+ sh "#{command} _#{Buildr::VERSION}_ #{tasks.join(' ')} #{options.join(' ')}"
225
+ end
226
+
227
+ def command #:nodoc:
228
+ Config::CONFIG['arch'] =~ /dos|win32/i ? $PROGRAM_NAME.ext('cmd') : $PROGRAM_NAME
229
+ end
230
+
231
+ # :call-seq:
232
+ # with_release_candidate_version() { |filename| ... }
233
+ #
234
+ # Yields to block with release candidate buildfile, before committing to use it.
158
235
  #
159
236
  # We need a Buildfile with upgraded version numbers to run the build, but we don't want the
160
- # Buildfile modified unless the build succeeds. So this method updates the version numbers in
237
+ # Buildfile modified unless the build succeeds. So this method updates the version number in
161
238
  # a separate (Buildfile.next) file, yields to the block with that filename, and if successful
162
239
  # copies the new file over the existing one.
163
240
  #
164
- # Version numbers are updated as follows. The next release version becomes the current one,
165
- # and the next version is upgraded by one to become the new next version. So:
166
- # THIS_VERSION = 1.1.0
167
- # NEXT_VERSION = 1.2.0
241
+ # The release version is the current version without '-SNAPSHOT'. So:
242
+ # THIS_VERSION = 1.1.0-SNAPSHOT
168
243
  # becomes:
169
- # THIS_VERSION = 1.2.0
170
- # NEXT_VERSION = 1.2.1
171
- # and the method will return 1.2.0.
172
- def with_next_version()
173
- new_filename = Buildr.application.buildfile + '.next'
174
- modified = change_version do |this_version, next_version|
175
- one_after = next_version.split('.')
176
- one_after[-1] = one_after[-1].to_i + 1
177
- [ next_version, one_after.join('.') ]
178
- end
179
- File.open(new_filename, 'w') { |file| file.write modified }
244
+ # THIS_VERSION = 1.1.0
245
+ # for the release buildfile.
246
+ def with_release_candidate_version
247
+ release_candidate_buildfile = Buildr.application.buildfile.to_s + '.next'
248
+ release_candidate_buildfile_contents = change_version { |version| version[-1] = version[-1].to_i }
249
+ File.open(release_candidate_buildfile, 'w') { |file| file.write release_candidate_buildfile_contents }
180
250
  begin
181
- yield new_filename
182
- mv new_filename, Buildr.application.buildfile
251
+ yield release_candidate_buildfile
252
+ mv release_candidate_buildfile, Buildr.application.buildfile.to_s
183
253
  ensure
184
- rm new_filename rescue nil
254
+ rm release_candidate_buildfile rescue nil
185
255
  end
186
- File.read(Buildr.application.buildfile).scan(THIS_VERSION_PATTERN)[0][1]
187
256
  end
188
257
 
189
258
  # :call-seq:
190
- # change_version() { |this, next| ... } => buildfile
259
+ # change_version() { |this_version| ... } => buildfile
191
260
  #
192
- # Change version numbers in the current Buildfile, but without writing a new file (yet).
193
- # Returns the contents of the Buildfile with the modified version numbers.
261
+ # Change version number in the current Buildfile, but without writing a new file (yet).
262
+ # Returns the contents of the Buildfile with the modified version number.
194
263
  #
195
- # This method yields to the block with the current (this) and next version numbers and expects
196
- # an array with the new this and next version numbers.
197
- def change_version()
198
- buildfile = File.read(Buildr.application.buildfile)
199
- this_version = buildfile.scan(THIS_VERSION_PATTERN)[0][1] or
200
- fail "Looking for THIS_VERSION = \"...\" in your Buildfile, none found"
201
- next_version = buildfile.scan(NEXT_VERSION_PATTERN)[0][1] or
202
- fail "Looking for NEXT_VERSION = \"...\" in your Buildfile, none found"
203
- this_version, next_version = yield(this_version, next_version)
204
- if verbose
205
- puts 'Upgrading version numbers:'
206
- puts " This: #{this_version}"
207
- puts " Next: #{next_version}"
208
- end
209
- buildfile.gsub(THIS_VERSION_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{this_version}"}) }.
210
- gsub(NEXT_VERSION_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{next_version}"}) }
264
+ # This method yields to the block with the current (this) version number as an array and expects
265
+ # the block to update it.
266
+ def change_version
267
+ this_version = extract_version
268
+ new_version = this_version.split('.')
269
+ yield(new_version)
270
+ new_version = new_version.join('.')
271
+ buildfile = File.read(Buildr.application.buildfile.to_s)
272
+ buildfile.gsub(THIS_VERSION_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{new_version}"}) }
211
273
  end
212
274
 
213
275
  # :call-seq:
214
- # tag(version)
276
+ # tag_release()
215
277
  #
216
278
  # Tags the current working copy with the release version number.
217
- def tag(version)
218
- url = svn_url.sub(/(trunk$)|(branches.*)$/, "tags/#{version}")
219
- svn 'remove', url, '-m', 'Removing old copy' rescue nil
220
- svn 'copy', Dir.pwd, url, '-m', "Release #{version}"
279
+ def tag_release
280
+ version = extract_version
281
+ info "Tagging release #{version}"
282
+ url = tag_url Svn.repo_url, version
283
+ Svn.remove url, 'Removing old copy' rescue nil
284
+ Svn.copy Dir.pwd, url, "Release #{version}"
221
285
  end
222
286
 
223
287
  # :call-seq:
224
- # commit(version)
288
+ # commit_new_snapshot()
225
289
  #
226
- # Last, we commit what we currently have in the working copy.
227
- def commit(version)
228
- buildfile = File.read(Buildr.application.buildfile).
229
- gsub(THIS_VERSION_PATTERN) { |ver| ver.sub(/(["']).*\1/, %Q{"#{version}"}) }
230
- File.open(Buildr.application.buildfile, 'w') { |file| file.write buildfile }
231
- svn 'commit', '-m', "Changed version number to #{version}", Buildr.application.buildfile
232
- end
233
-
234
- # :call-seq:
235
- # svn(*args)
236
- #
237
- # Executes SVN command and returns the output.
238
- def svn(*args)
239
- cmd = 'svn ' + args.map { |arg| arg[' '] ? %Q{"#{arg}"} : arg }.join(' ')
240
- puts cmd if verbose
241
- `#{cmd}`.tap { fail 'SVN command failed' unless $?.exitstatus == 0 }
242
- end
243
-
244
- # Return the current SVN URL
245
- def svn_url
246
- url = svn('info').scan(/URL: (.*)/)[0][0]
290
+ # Last, we commit what we currently have in the working copy with an upgraded version number.
291
+ def commit_new_snapshot
292
+ buildfile = change_version { |version| version[-1] = (version[-1].to_i + 1).to_s + '-SNAPSHOT' }
293
+ File.open(Buildr.application.buildfile.to_s, 'w') { |file| file.write buildfile }
294
+ Svn.commit Buildr.application.buildfile.to_s, "Changed version number to #{extract_version}"
295
+ info "Current version is now #{extract_version}"
247
296
  end
248
297
  end
249
-
250
298
  end
251
299
 
300
+
252
301
  desc 'Make a release'
253
302
  task 'release' do |task|
254
303
  Release.make
@@ -16,7 +16,7 @@
16
16
 
17
17
  require 'buildr/core/project'
18
18
  require 'buildr/packaging/zip'
19
- require 'test/unit'
19
+ #require 'test/unit'
20
20
  require 'spec/matchers'
21
21
  require 'spec/expectations'
22
22
 
@@ -130,7 +130,7 @@ module Buildr
130
130
  # Run the expectation. We only print the expectation name when tracing (to know they all ran),
131
131
  # or when we get a failure.
132
132
  begin
133
- puts description if Buildr.application.options.trace
133
+ trace description
134
134
  klass.new.instance_eval &@block
135
135
  rescue Exception=>error
136
136
  raise error.exception("#{description}\n#{error}").tap { |wrapped| wrapped.set_backtrace(error.backtrace) }
@@ -149,10 +149,10 @@ module Buildr
149
149
  begin
150
150
  expect.run_against project
151
151
  passed
152
- rescue Exception=>error
152
+ rescue Exception=>ex
153
153
  if verbose
154
- puts error.backtrace.detect { |line| line =~ /#{Buildr.application.buildfile}/ } || ""
155
- puts error
154
+ error ex.backtrace.select { |line| line =~ /#{Buildr.application.buildfile}/ }.join("\n")
155
+ error ex
156
156
  end
157
157
  false
158
158
  end
@@ -111,7 +111,7 @@ module Buildr
111
111
  # Download to a file created by the task.
112
112
  fail unless args.keys.size == 1
113
113
  uri = URI.parse(args.values.first.to_s)
114
- file(args.keys.first).tap do |task|
114
+ file(args.keys.first.to_s).tap do |task|
115
115
  task.sources << uri
116
116
  task.enhance { uri.download task.name }
117
117
  end
@@ -122,6 +122,8 @@ module Buildr
122
122
  map = compile_map(sources, target)
123
123
  return false if map.empty?
124
124
  return true unless File.exist?(target.to_s)
125
+ source_files_not_yet_compiled = map.select { |source, target| !File.exist?(target) }
126
+ trace "Compile needed because source file #{source_files_not_yet_compiled[0][0]} has no corresponding #{source_files_not_yet_compiled[0][1]}" unless source_files_not_yet_compiled.empty?
125
127
  return true if map.any? { |source, target| !File.exist?(target) || File.stat(source).mtime > File.stat(target).mtime }
126
128
  oldest = map.map { |source, target| File.stat(target).mtime }.min
127
129
  return dependencies.any? { |path| file(path).timestamp > oldest }
@@ -173,7 +175,7 @@ module Buildr
173
175
  FileList["#{source}/**/*.{#{ext_glob}}"].reject { |file| File.directory?(file) }.
174
176
  each { |file| map[file] = File.join(target, Util.relative_path(file, source).ext(target_ext)) }
175
177
  else
176
- map[source] = File.join(target, File.basename(source).ext(target_ext))
178
+ map[source] = target # File.join(target, File.basename(source).ext(target_ext))
177
179
  end
178
180
  map
179
181
  end
@@ -223,7 +225,7 @@ module Buildr
223
225
  raise 'No compiler selected and can\'t determine which compiler to use' unless compiler
224
226
  raise 'No target directory specified' unless target
225
227
  mkpath target.to_s, :verbose=>false
226
- puts "Compiling #{task.name.gsub(/:[^:]*$/, '')} into #{target.to_s}" if verbose
228
+ info "Compiling #{task.name.gsub(/:[^:]*$/, '')} into #{target.to_s}"
227
229
  @compiler.compile(sources.map(&:to_s), target.to_s, dependencies.map(&:to_s))
228
230
  # By touching the target we let other tasks know we did something,
229
231
  # and also prevent recompiling again for dependencies.
@@ -244,6 +246,7 @@ module Buildr
244
246
  # compile.from('src/java').into('classes').with('module1.jar')
245
247
  def from(*sources)
246
248
  @sources |= sources.flatten
249
+ guess_compiler if @compiler.nil? && sources.flatten.any? { |source| File.exist?(source) }
247
250
  self
248
251
  end
249
252
 
@@ -316,10 +319,7 @@ module Buildr
316
319
  # based on existing source directories (e.g. src/main/java), or by requesting
317
320
  # a specific compiler (see #using).
318
321
  def compiler
319
- unless @compiler
320
- candidate = Compiler.compilers.detect { |cls| cls.applies_to?(project, self) }
321
- self.compiler = candidate if candidate
322
- end
322
+ guess_compiler unless @compiler
323
323
  @compiler && @compiler.class.to_sym
324
324
  end
325
325
 
@@ -363,7 +363,11 @@ module Buildr
363
363
  # Associates this task with project and particular usage (:main, :test).
364
364
  def associate_with(project, usage) #:nodoc:
365
365
  @project, @usage = project, usage
366
- # Try to guess if we have a compiler to match source files.
366
+ guess_compiler
367
+ end
368
+
369
+ # Try to guess if we have a compiler to match source files.
370
+ def guess_compiler #:nodoc:
367
371
  candidate = Compiler.compilers.detect { |cls| cls.applies_to?(project, self) }
368
372
  self.compiler = candidate if candidate
369
373
  end
@@ -451,12 +455,12 @@ module Buildr
451
455
  filter.target
452
456
  end
453
457
 
454
- protected
455
-
456
458
  def prerequisites #:nodoc:
457
459
  super + filter.sources.flatten
458
460
  end
459
461
 
462
+ protected
463
+
460
464
  # Associates this task with project and particular usage (:main, :test).
461
465
  def associate_with(project, usage) #:nodoc:
462
466
  @project, @usage = project, usage
@@ -496,9 +500,7 @@ module Buildr
496
500
  # This comes last because the target path is set inside the project definition.
497
501
  project.build project.compile.target
498
502
  project.clean do
499
- verbose(false) do
500
- rm_rf project.compile.target.to_s
501
- end
503
+ rm_rf project.compile.target.to_s, :verbose=>false
502
504
  end
503
505
  end
504
506
  end