buildr 1.3.4-java → 1.3.5-java
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.
- data/CHANGELOG +35 -0
- data/README.rdoc +1 -1
- data/Rakefile +3 -3
- data/buildr.buildfile +6 -1
- data/buildr.gemspec +10 -9
- data/doc/_config.yml +1 -0
- data/doc/_layouts/default.html +25 -19
- data/doc/artifacts.textile +0 -36
- data/doc/building.textile +0 -38
- data/doc/contributing.textile +51 -15
- data/doc/css/default.css +11 -4
- data/doc/css/print.css +32 -24
- data/doc/download.textile +33 -22
- data/doc/extending.textile +10 -20
- data/doc/images/1442160941-frontcover.jpg +0 -0
- data/doc/images/asf-logo.png +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.png +0 -0
- data/doc/index.textile +39 -17
- data/doc/{getting_started.textile → installing.textile} +3 -80
- data/doc/languages.textile +50 -52
- data/doc/more_stuff.textile +154 -62
- data/doc/packaging.textile +0 -82
- data/doc/preface.textile +41 -15
- data/doc/projects.textile +0 -18
- data/doc/quick_start.textile +210 -0
- data/doc/scripts/install-linux.sh +10 -2
- data/doc/settings_profiles.textile +1 -33
- data/doc/testing.textile +6 -32
- data/lib/buildr.rb +2 -1
- data/lib/buildr/core.rb +6 -0
- data/lib/buildr/core/application.rb +2 -5
- data/lib/buildr/core/build.rb +29 -19
- data/lib/buildr/core/compile.rb +22 -4
- data/lib/buildr/core/filter.rb +2 -4
- data/lib/buildr/core/project.rb +5 -4
- data/lib/buildr/core/shell.rb +198 -0
- data/lib/buildr/core/test.rb +2 -0
- data/lib/buildr/core/transports.rb +18 -19
- data/lib/buildr/core/util.rb +178 -9
- data/lib/buildr/groovy.rb +1 -0
- data/lib/buildr/groovy/bdd.rb +5 -5
- data/lib/buildr/groovy/shell.rb +48 -0
- data/lib/buildr/ide/eclipse.rb +148 -36
- data/lib/buildr/ide/eclipse/java.rb +53 -0
- data/lib/buildr/ide/eclipse/plugin.rb +68 -0
- data/lib/buildr/ide/eclipse/scala.rb +66 -0
- data/lib/buildr/java/bdd.rb +16 -8
- data/lib/buildr/java/cobertura.rb +44 -13
- data/lib/buildr/java/commands.rb +5 -3
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +18 -0
- data/lib/buildr/java/packaging.rb +2 -2
- data/lib/buildr/java/rjb.rb +1 -1
- data/lib/buildr/java/test_result.rb +48 -1
- data/lib/buildr/java/tests.rb +8 -5
- data/lib/buildr/packaging/artifact_namespace.rb +1 -1
- data/lib/buildr/packaging/package.rb +6 -2
- data/lib/buildr/packaging/zip.rb +10 -1
- data/lib/buildr/packaging/ziptask.rb +5 -2
- data/lib/buildr/scala.rb +1 -0
- data/lib/buildr/scala/bdd.rb +17 -8
- data/lib/buildr/scala/compiler.rb +66 -21
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
- data/lib/buildr/scala/shell.rb +55 -0
- data/lib/buildr/scala/tests.rb +6 -5
- data/lib/buildr/shell.rb +180 -0
- data/rakelib/doc.rake +2 -3
- data/rakelib/jekylltask.rb +42 -32
- data/rakelib/package.rake +4 -2
- data/rakelib/release.rake +8 -8
- data/rakelib/rspec.rake +3 -3
- data/rakelib/setup.rake +7 -1
- data/rakelib/stage.rake +9 -2
- data/rakelib/stage.rake~ +213 -0
- data/spec/core/application_spec.rb +84 -1
- data/spec/core/build_spec.rb +54 -2
- data/spec/core/common_spec.rb +1 -1
- data/spec/core/compile_spec.rb +2 -1
- data/spec/core/extension_spec.rb +93 -0
- data/spec/core/test_spec.rb +2 -2
- data/spec/core/transport_spec.rb +1 -1
- data/spec/groovy/bdd_spec.rb +6 -6
- data/spec/groovy/compiler_spec.rb +1 -0
- data/spec/ide/eclipse_spec.rb +262 -72
- data/spec/java/{ant.rb → ant_spec.rb} +0 -0
- data/spec/java/bdd_spec.rb +15 -0
- data/spec/java/cobertura_spec.rb +9 -1
- data/spec/java/emma_spec.rb +1 -1
- data/spec/java/java_spec.rb +26 -0
- data/spec/java/packaging_spec.rb +9 -7
- data/spec/java/{test_coverage_spec.rb → test_coverage_helper.rb} +6 -4
- data/spec/java/tests_spec.rb +22 -0
- data/spec/packaging/archive_spec.rb +14 -0
- data/spec/packaging/artifact_spec.rb +2 -2
- data/spec/packaging/packaging_spec.rb +97 -2
- data/spec/sandbox.rb +3 -1
- data/spec/scala/bdd_spec.rb +17 -48
- data/spec/scala/compiler_spec.rb +31 -2
- data/spec/scala/tests_spec.rb +1 -0
- data/spec/spec_helpers.rb +12 -0
- metadata +145 -148
data/lib/buildr/core/test.rb
CHANGED
|
@@ -443,6 +443,8 @@ module Buildr
|
|
|
443
443
|
else
|
|
444
444
|
info "Running tests in #{@project.name}"
|
|
445
445
|
begin
|
|
446
|
+
# set the baseDir system property if not set
|
|
447
|
+
@framework.options[:properties] = { 'baseDir' => @project.test.compile.target.to_s }.merge(@framework.options[:properties] || {})
|
|
446
448
|
@passed_tests = @framework.run(@tests, dependencies)
|
|
447
449
|
rescue Exception=>ex
|
|
448
450
|
error "Test framework error: #{ex.message}"
|
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
|
|
17
17
|
require 'uri'
|
|
18
18
|
require 'net/http'
|
|
19
|
-
Net.autoload :HTTPS, 'net/https'
|
|
20
19
|
# PATCH: On Windows, Net::SSH 2.0.2 attempts to load the Pageant DLLs which break on JRuby.
|
|
21
20
|
$LOADED_FEATURES << 'net/ssh/authentication/pageant.rb' if RUBY_PLATFORM =~ /java/
|
|
22
21
|
gem 'net-ssh' ; Net.autoload :SSH, 'net/ssh'
|
|
@@ -148,11 +147,10 @@ module URI
|
|
|
148
147
|
# worse than not having a file at all, so download to temporary
|
|
149
148
|
# file and then move over.
|
|
150
149
|
modified = File.stat(target).mtime if File.exist?(target)
|
|
151
|
-
temp =
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
end
|
|
150
|
+
temp = Tempfile.new(File.basename(target))
|
|
151
|
+
temp.binmode
|
|
152
|
+
read({:progress=>verbose}.merge(options || {}).merge(:modified=>modified)) { |chunk| temp.write chunk }
|
|
153
|
+
temp.close
|
|
156
154
|
mkpath File.dirname(target)
|
|
157
155
|
mv temp.path, target
|
|
158
156
|
when File
|
|
@@ -366,7 +364,10 @@ module URI
|
|
|
366
364
|
else
|
|
367
365
|
http = Net::HTTP.new(host, port)
|
|
368
366
|
end
|
|
369
|
-
|
|
367
|
+
if self.instance_of? URI::HTTPS
|
|
368
|
+
require 'net/https'
|
|
369
|
+
http.use_ssl = true
|
|
370
|
+
end
|
|
370
371
|
yield http
|
|
371
372
|
end
|
|
372
373
|
|
|
@@ -537,20 +538,18 @@ module URI
|
|
|
537
538
|
|
|
538
539
|
def write_internal(options, &block) #:nodoc:
|
|
539
540
|
raise ArgumentError, 'Either you\'re attempting to write a file to another host (which we don\'t support), or you used two slashes by mistake, where you should have file:///<path>.' if host
|
|
540
|
-
temp =
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
progress << chunk
|
|
547
|
-
end
|
|
541
|
+
temp = Tempfile.new(File.basename(path))
|
|
542
|
+
temp.binmode
|
|
543
|
+
with_progress_bar options[:progress] && options[:size], path.split('/'), options[:size] || 0 do |progress|
|
|
544
|
+
while chunk = yield(RW_CHUNK_SIZE)
|
|
545
|
+
temp.write chunk
|
|
546
|
+
progress << chunk
|
|
548
547
|
end
|
|
549
548
|
end
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
549
|
+
temp.close
|
|
550
|
+
mkpath File.dirname(real_path)
|
|
551
|
+
mv temp.path, real_path
|
|
552
|
+
real_path
|
|
554
553
|
end
|
|
555
554
|
|
|
556
555
|
@@schemes['FILE'] = FILE
|
data/lib/buildr/core/util.rb
CHANGED
|
@@ -159,24 +159,54 @@ module Buildr
|
|
|
159
159
|
end
|
|
160
160
|
|
|
161
161
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
class Object #:nodoc:
|
|
163
|
+
unless defined? instance_exec # 1.9
|
|
164
|
+
module InstanceExecMethods #:nodoc:
|
|
165
|
+
end
|
|
166
|
+
include InstanceExecMethods
|
|
167
|
+
|
|
168
|
+
# Evaluate the block with the given arguments within the context of
|
|
169
|
+
# this object, so self is set to the method receiver.
|
|
170
|
+
#
|
|
171
|
+
# From Mauricio's http://eigenclass.org/hiki/bounded+space+instance_exec
|
|
172
|
+
def instance_exec(*args, &block)
|
|
173
|
+
begin
|
|
174
|
+
old_critical, Thread.critical = Thread.critical, true
|
|
175
|
+
n = 0
|
|
176
|
+
n += 1 while respond_to?(method_name = "__instance_exec#{n}")
|
|
177
|
+
InstanceExecMethods.module_eval { define_method(method_name, &block) }
|
|
178
|
+
ensure
|
|
179
|
+
Thread.critical = old_critical
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
begin
|
|
183
|
+
send(method_name, *args)
|
|
184
|
+
ensure
|
|
185
|
+
InstanceExecMethods.module_eval { remove_method(method_name) } rescue nil
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
module Kernel #:nodoc:
|
|
192
|
+
unless defined? tap # 1.9
|
|
165
193
|
def tap
|
|
166
194
|
yield self if block_given?
|
|
167
195
|
self
|
|
168
|
-
end
|
|
196
|
+
end
|
|
169
197
|
end
|
|
198
|
+
end
|
|
170
199
|
|
|
171
|
-
|
|
172
|
-
|
|
200
|
+
class Symbol #:nodoc:
|
|
201
|
+
unless defined? to_proc # 1.9
|
|
173
202
|
# Borrowed from Ruby 1.9.
|
|
174
203
|
def to_proc
|
|
175
204
|
Proc.new{|*args| args.shift.__send__(self, *args)}
|
|
176
|
-
end
|
|
205
|
+
end
|
|
177
206
|
end
|
|
207
|
+
end
|
|
178
208
|
|
|
179
|
-
|
|
209
|
+
unless defined? BasicObject # 1.9
|
|
180
210
|
class BasicObject #:nodoc:
|
|
181
211
|
(instance_methods - ['__send__', '__id__', '==', 'send', 'send!', 'respond_to?', 'equal?', 'object_id']).
|
|
182
212
|
each do |method|
|
|
@@ -230,7 +260,9 @@ class Hash
|
|
|
230
260
|
# and the Hash doesn't work the way we need it to. Unfortunately, we can call toString on MRI's object,
|
|
231
261
|
# but not on the JRuby one; calling to_s on the JRuby object returns what we need, but ... you guessed it.
|
|
232
262
|
# So this seems like the one hack to unite them both.
|
|
233
|
-
key = Java.java.lang.String.valueOf(keys.next)
|
|
263
|
+
#key = Java.java.lang.String.valueOf(keys.next.to_s)
|
|
264
|
+
key = keys.next
|
|
265
|
+
key = key.toString unless String === key
|
|
234
266
|
hash[key] = java_properties.getProperty(key)
|
|
235
267
|
end
|
|
236
268
|
hash
|
|
@@ -278,3 +310,140 @@ class Hash
|
|
|
278
310
|
end
|
|
279
311
|
|
|
280
312
|
end
|
|
313
|
+
|
|
314
|
+
if Buildr::Util.java_platform?
|
|
315
|
+
require 'ffi'
|
|
316
|
+
|
|
317
|
+
# Fix for BUILDR-292.
|
|
318
|
+
# JRuby fails to rename a file on different devices
|
|
319
|
+
# this monkey-patch wont be needed when JRUBY-3381 gets resolved.
|
|
320
|
+
module FileUtils #:nodoc:
|
|
321
|
+
alias_method :__mv_native, :mv
|
|
322
|
+
|
|
323
|
+
def mv(from, to, options = nil)
|
|
324
|
+
dir_to = File.directory?(to) ? to : File.dirname(to)
|
|
325
|
+
Array(from).each do |from|
|
|
326
|
+
dir_from = File.dirname(from)
|
|
327
|
+
if File.stat(dir_from).dev != File.stat(dir_to).dev
|
|
328
|
+
cp from, to, options
|
|
329
|
+
rm from, options
|
|
330
|
+
else
|
|
331
|
+
__mv_native from, to, options
|
|
332
|
+
end
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
private :mv
|
|
336
|
+
end
|
|
337
|
+
|
|
338
|
+
module RakeFileUtils #:nodoc:
|
|
339
|
+
def rake_merge_option(args, defaults)
|
|
340
|
+
defaults[:verbose] = false if defaults[:verbose] == :default
|
|
341
|
+
|
|
342
|
+
if Hash === args.last
|
|
343
|
+
defaults.update(args.last)
|
|
344
|
+
args.pop
|
|
345
|
+
end
|
|
346
|
+
args.push defaults
|
|
347
|
+
args
|
|
348
|
+
end
|
|
349
|
+
private :rake_merge_option
|
|
350
|
+
end
|
|
351
|
+
|
|
352
|
+
module Buildr
|
|
353
|
+
class ProcessStatus
|
|
354
|
+
attr_reader :pid, :termsig, :stopsig, :exitstatus
|
|
355
|
+
|
|
356
|
+
def initialize(pid, success, exitstatus)
|
|
357
|
+
@pid = pid
|
|
358
|
+
@success = success
|
|
359
|
+
@exitstatus = exitstatus
|
|
360
|
+
|
|
361
|
+
@termsig = nil
|
|
362
|
+
@stopsig = nil
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
def &(num)
|
|
366
|
+
pid & num
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
def ==(other)
|
|
370
|
+
pid == other.pid
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
def >>(num)
|
|
374
|
+
pid >> num
|
|
375
|
+
end
|
|
376
|
+
|
|
377
|
+
def coredump?
|
|
378
|
+
false
|
|
379
|
+
end
|
|
380
|
+
|
|
381
|
+
def exited?
|
|
382
|
+
true
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
def stopped?
|
|
386
|
+
false
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
def success?
|
|
390
|
+
@success
|
|
391
|
+
end
|
|
392
|
+
|
|
393
|
+
def to_i
|
|
394
|
+
pid
|
|
395
|
+
end
|
|
396
|
+
|
|
397
|
+
def to_int
|
|
398
|
+
pid
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
def to_s
|
|
402
|
+
pid.to_s
|
|
403
|
+
end
|
|
404
|
+
end
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
module FileUtils
|
|
408
|
+
extend FFI::Library
|
|
409
|
+
alias_method :__jruby_system__, :system
|
|
410
|
+
attach_function :system, [:string], :int
|
|
411
|
+
alias_method :__native_system__, :system
|
|
412
|
+
alias_method :system, :__jruby_system__
|
|
413
|
+
|
|
414
|
+
# code "borrowed" directly from Rake
|
|
415
|
+
def sh(*cmd, &block)
|
|
416
|
+
options = (Hash === cmd.last) ? cmd.pop : {}
|
|
417
|
+
unless block_given?
|
|
418
|
+
show_command = cmd.join(" ")
|
|
419
|
+
show_command = show_command[0,42] + "..."
|
|
420
|
+
|
|
421
|
+
block = lambda { |ok, status|
|
|
422
|
+
ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
|
|
423
|
+
}
|
|
424
|
+
end
|
|
425
|
+
if RakeFileUtils.verbose_flag == :default
|
|
426
|
+
options[:verbose] = false
|
|
427
|
+
else
|
|
428
|
+
options[:verbose] ||= RakeFileUtils.verbose_flag
|
|
429
|
+
end
|
|
430
|
+
options[:noop] ||= RakeFileUtils.nowrite_flag
|
|
431
|
+
rake_check_options options, :noop, :verbose
|
|
432
|
+
rake_output_message cmd.join(" ") if options[:verbose]
|
|
433
|
+
unless options[:noop]
|
|
434
|
+
cd = "cd '#{Dir.pwd}' && "
|
|
435
|
+
args = if cmd.size > 1 then cmd[1..cmd.size] else [] end
|
|
436
|
+
|
|
437
|
+
res = if Buildr::Util.win_os? && cmd.size == 1
|
|
438
|
+
__native_system__("#{cd} call #{cmd.first}")
|
|
439
|
+
else
|
|
440
|
+
arg_str = args.map { |a| "'#{a}'" }
|
|
441
|
+
__native_system__(cd + cmd.first + ' ' + arg_str.join(' '))
|
|
442
|
+
end
|
|
443
|
+
$? = Buildr::ProcessStatus.new(0, res == 0, res) # KLUDGE
|
|
444
|
+
block.call(res == 0, $?)
|
|
445
|
+
end
|
|
446
|
+
end
|
|
447
|
+
|
|
448
|
+
end
|
|
449
|
+
end
|
data/lib/buildr/groovy.rb
CHANGED
data/lib/buildr/groovy/bdd.rb
CHANGED
|
@@ -23,7 +23,7 @@ module Buildr::Groovy
|
|
|
23
23
|
#
|
|
24
24
|
# This framework will search in your project for:
|
|
25
25
|
# src/spec/groovy/**/*Story.groovy
|
|
26
|
-
# src/spec/groovy/**/*
|
|
26
|
+
# src/spec/groovy/**/*Specification.groovy
|
|
27
27
|
#
|
|
28
28
|
# Support the following options:
|
|
29
29
|
# * :format -- Report format :txt or :xml, default is :txt
|
|
@@ -33,8 +33,8 @@ module Buildr::Groovy
|
|
|
33
33
|
@lang = :groovy
|
|
34
34
|
@bdd_dir = :spec
|
|
35
35
|
|
|
36
|
-
VERSION = "0.
|
|
37
|
-
TESTS_PATTERN = [ /(Story|
|
|
36
|
+
VERSION = "0.9"
|
|
37
|
+
TESTS_PATTERN = [ /(Story|Specification).groovy$/ ]
|
|
38
38
|
OPTIONS = [:format, :properties, :java_args]
|
|
39
39
|
|
|
40
40
|
class << self
|
|
@@ -50,7 +50,7 @@ module Buildr::Groovy
|
|
|
50
50
|
|
|
51
51
|
def applies_to?(project) #:nodoc:
|
|
52
52
|
%w{
|
|
53
|
-
**/*
|
|
53
|
+
**/*Specification.groovy **/*Story.groovy
|
|
54
54
|
}.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
|
|
55
55
|
end
|
|
56
56
|
|
|
@@ -78,7 +78,7 @@ module Buildr::Groovy
|
|
|
78
78
|
raise "Invalid format #{options[:format]} expected one of :txt :xml"
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
cmd_args = [ 'org.disco.easyb.
|
|
81
|
+
cmd_args = [ 'org.disco.easyb.BehaviorRunner' ]
|
|
82
82
|
cmd_options = { :properties => options[:properties],
|
|
83
83
|
:java_args => options[:java_args],
|
|
84
84
|
:classpath => dependencies }
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
require 'buildr/shell'
|
|
17
|
+
|
|
18
|
+
module Buildr
|
|
19
|
+
module Groovy
|
|
20
|
+
class GroovySH < Buildr::Shell::Base
|
|
21
|
+
SUFFIX = if Util.win_os? then '.bat' else '' end
|
|
22
|
+
|
|
23
|
+
class << self
|
|
24
|
+
def lang
|
|
25
|
+
:groovy
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def launch
|
|
30
|
+
fail 'Are we forgetting something? GROOVY_HOME not set.' unless groovy_home
|
|
31
|
+
|
|
32
|
+
cp = project.compile.dependencies.join(File::PATH_SEPARATOR) +
|
|
33
|
+
File::PATH_SEPARATOR + project.path_to(:target, :classes)
|
|
34
|
+
|
|
35
|
+
cmd_args = " -classpath '#{cp}'"
|
|
36
|
+
trace "groovysh #{cmd_args}"
|
|
37
|
+
system(File.expand_path("bin#{File::SEPARATOR}groovysh#{SUFFIX}", groovy_home) + cmd_args)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
def groovy_home
|
|
42
|
+
@home ||= ENV['GROOVY_HOME']
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
Buildr::ShellProviders << Buildr::Groovy::GroovySH
|
data/lib/buildr/ide/eclipse.rb
CHANGED
|
@@ -20,13 +20,127 @@ require 'buildr/packaging'
|
|
|
20
20
|
|
|
21
21
|
module Buildr
|
|
22
22
|
module Eclipse #:nodoc:
|
|
23
|
-
|
|
24
23
|
include Extension
|
|
25
24
|
|
|
25
|
+
class Eclipse
|
|
26
|
+
|
|
27
|
+
attr_reader :options
|
|
28
|
+
|
|
29
|
+
def initialize(project)
|
|
30
|
+
@project = project
|
|
31
|
+
@options = Options.new(project)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# :call-seq:
|
|
35
|
+
# natures=(natures)
|
|
36
|
+
# Sets the Eclipse project natures on the project.
|
|
37
|
+
#
|
|
38
|
+
def natures=(var)
|
|
39
|
+
@natures = arrayfy(var)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# :call-seq:
|
|
43
|
+
# natures() => [n1, n2]
|
|
44
|
+
# Returns the Eclipse project natures on the project.
|
|
45
|
+
# They may be derived from the parent project if no specific natures have been set
|
|
46
|
+
# on the project.
|
|
47
|
+
#
|
|
48
|
+
# An Eclipse project nature is used internally by Eclipse to determine the aspects of a project.
|
|
49
|
+
def natures(*values)
|
|
50
|
+
if values.size > 0
|
|
51
|
+
@natures ||= []
|
|
52
|
+
@natures += values
|
|
53
|
+
else
|
|
54
|
+
@natures || (@project.parent ? @project.parent.eclipse.natures : [])
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# :call-seq:
|
|
59
|
+
# classpath_containers=(cc)
|
|
60
|
+
# Sets the Eclipse project classpath containers on the project.
|
|
61
|
+
#
|
|
62
|
+
def classpath_containers=(var)
|
|
63
|
+
@classpath_containers = arrayfy(var)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# :call-seq:
|
|
67
|
+
# classpath_containers() => [con1, con2]
|
|
68
|
+
# Returns the Eclipse project classpath containers on the project.
|
|
69
|
+
# They may be derived from the parent project if no specific classpath containers have been set
|
|
70
|
+
# on the project.
|
|
71
|
+
#
|
|
72
|
+
# A classpath container is an Eclipse pre-determined ensemble of dependencies made available to
|
|
73
|
+
# the project classpath.
|
|
74
|
+
def classpath_containers(*values)
|
|
75
|
+
if values.size > 0
|
|
76
|
+
@classpath_containers ||= []
|
|
77
|
+
@classpath_containers += values
|
|
78
|
+
else
|
|
79
|
+
@classpath_containers || (@project.parent ? @project.parent.eclipse.classpath_containers : [])
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
# :call-seq:
|
|
84
|
+
# builders=(builders)
|
|
85
|
+
# Sets the Eclipse project builders on the project.
|
|
86
|
+
#
|
|
87
|
+
def builders=(var)
|
|
88
|
+
@builders = arrayfy(var)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# :call-seq:
|
|
92
|
+
# builders() => [b1, b2]
|
|
93
|
+
# Returns the Eclipse project builders on the project.
|
|
94
|
+
# They may be derived from the parent project if no specific builders have been set
|
|
95
|
+
# on the project.
|
|
96
|
+
#
|
|
97
|
+
# A builder is an Eclipse background job that parses the source code to produce built artifacts.
|
|
98
|
+
def builders(*values)
|
|
99
|
+
if values.size > 0
|
|
100
|
+
@builders ||= []
|
|
101
|
+
@builders += values
|
|
102
|
+
else
|
|
103
|
+
@builders || (@project.parent ? @project.parent.eclipse.builders : [])
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
private
|
|
108
|
+
|
|
109
|
+
def arrayfy(obj)
|
|
110
|
+
obj.is_a?(Array) ? obj : [obj]
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
class Options
|
|
115
|
+
|
|
116
|
+
attr_writer :m2_repo_var
|
|
117
|
+
|
|
118
|
+
def initialize(project)
|
|
119
|
+
@project = project
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# The classpath variable used to point at the local maven2 repository.
|
|
123
|
+
# Example:
|
|
124
|
+
# eclipse.options.m2_repo_var = 'M2_REPO'
|
|
125
|
+
def m2_repo_var(*values)
|
|
126
|
+
fail "m2_repo_var can only accept one value: #{values}" if values.size > 1
|
|
127
|
+
if values.size > 0
|
|
128
|
+
@m2_repo_var = values[0]
|
|
129
|
+
else
|
|
130
|
+
@m2_repo_var || (@project.parent ? @project.parent.eclipse.options.m2_repo_var : 'M2_REPO')
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def eclipse
|
|
136
|
+
@eclipse ||= Eclipse.new(self)
|
|
137
|
+
@eclipse
|
|
138
|
+
end
|
|
139
|
+
|
|
26
140
|
first_time do
|
|
27
141
|
# Global task "eclipse" generates artifacts for all projects.
|
|
28
142
|
desc 'Generate Eclipse artifacts for all projects'
|
|
29
|
-
Project.local_task
|
|
143
|
+
Project.local_task('eclipse'=>'artifacts') { |name| "Generating Eclipse project for #{name}" }
|
|
30
144
|
end
|
|
31
145
|
|
|
32
146
|
before_define do |project|
|
|
@@ -36,19 +150,11 @@ module Buildr
|
|
|
36
150
|
after_define do |project|
|
|
37
151
|
eclipse = project.task('eclipse')
|
|
38
152
|
|
|
39
|
-
|
|
40
|
-
scala = project.compile.language == :scala
|
|
41
|
-
|
|
42
|
-
# Only for projects that we support
|
|
43
|
-
supported_languages = [:java, :scala]
|
|
44
|
-
supported_packaging = %w(jar war rar mar aar)
|
|
45
|
-
if (supported_languages.include?(project.compile.language) ||
|
|
46
|
-
supported_languages.include?(project.test.compile.language) ||
|
|
47
|
-
project.packages.detect { |pkg| supported_packaging.include?(pkg.type.to_s) })
|
|
48
|
-
eclipse.enhance [ file(project.path_to('.classpath')), file(project.path_to('.project')) ]
|
|
153
|
+
eclipse.enhance [ file(project.path_to('.classpath')), file(project.path_to('.project')) ]
|
|
49
154
|
|
|
50
|
-
|
|
51
|
-
|
|
155
|
+
# The only thing we need to look for is a change in the Buildfile.
|
|
156
|
+
file(project.path_to('.classpath')=>Buildr.application.buildfile) do |task|
|
|
157
|
+
if (project.eclipse.natures.reject { |x| x.is_a?(Symbol) }.size > 0)
|
|
52
158
|
info "Writing #{task.name}"
|
|
53
159
|
|
|
54
160
|
m2repo = Buildr::Repositories.instance.local
|
|
@@ -69,8 +175,8 @@ module Buildr
|
|
|
69
175
|
# Separate artifacts from Maven2 repository
|
|
70
176
|
m2_libs, others = others.partition { |path| path.to_s.index(m2repo) == 0 }
|
|
71
177
|
|
|
72
|
-
# Generated: classpath elements in the project are assumed to be generated
|
|
73
|
-
|
|
178
|
+
# Generated: Any non-file classpath elements in the project are assumed to be generated
|
|
179
|
+
libs, generated = others.partition { |path| File.file?(path.to_s) }
|
|
74
180
|
|
|
75
181
|
classpathentry.src project.compile.sources + generated
|
|
76
182
|
classpathentry.src project.resources
|
|
@@ -85,16 +191,19 @@ module Buildr
|
|
|
85
191
|
|
|
86
192
|
classpathentry.output project.compile.target if project.compile.target
|
|
87
193
|
classpathentry.lib libs
|
|
88
|
-
classpathentry.var m2_libs,
|
|
194
|
+
classpathentry.var m2_libs, project.eclipse.options.m2_repo_var, m2repo
|
|
89
195
|
|
|
90
|
-
|
|
91
|
-
|
|
196
|
+
project.eclipse.classpath_containers.each { |container|
|
|
197
|
+
classpathentry.con container
|
|
198
|
+
}
|
|
92
199
|
end
|
|
93
200
|
end
|
|
94
201
|
end
|
|
202
|
+
end
|
|
95
203
|
|
|
96
|
-
|
|
97
|
-
|
|
204
|
+
# The only thing we need to look for is a change in the Buildfile.
|
|
205
|
+
file(project.path_to('.project')=>Buildr.application.buildfile) do |task|
|
|
206
|
+
if (project.eclipse.natures.reject { |x| x.is_a?(Symbol) }.size > 0)
|
|
98
207
|
info "Writing #{task.name}"
|
|
99
208
|
File.open(task.name, 'w') do |file|
|
|
100
209
|
xml = Builder::XmlMarkup.new(:target=>file, :indent=>2)
|
|
@@ -102,27 +211,24 @@ module Buildr
|
|
|
102
211
|
xml.name project.id
|
|
103
212
|
xml.projects
|
|
104
213
|
xml.buildSpec do
|
|
105
|
-
|
|
106
|
-
xml.buildCommand do
|
|
107
|
-
xml.name 'ch.epfl.lamp.sdt.core.scalabuilder'
|
|
108
|
-
end
|
|
109
|
-
else
|
|
214
|
+
project.eclipse.builders.each { |builder|
|
|
110
215
|
xml.buildCommand do
|
|
111
|
-
xml.name
|
|
216
|
+
xml.name builder
|
|
112
217
|
end
|
|
113
|
-
|
|
218
|
+
}
|
|
114
219
|
end
|
|
115
220
|
xml.natures do
|
|
116
|
-
|
|
117
|
-
|
|
221
|
+
project.eclipse.natures.each { |nature|
|
|
222
|
+
xml.nature nature unless nature.is_a? Symbol
|
|
223
|
+
}
|
|
118
224
|
end
|
|
119
225
|
end
|
|
120
226
|
end
|
|
121
227
|
end
|
|
122
228
|
end
|
|
123
|
-
|
|
124
229
|
end
|
|
125
230
|
|
|
231
|
+
|
|
126
232
|
# Writes 'classpathentry' tags in an xml file.
|
|
127
233
|
# It converts tasks to paths.
|
|
128
234
|
# It converts absolute paths to relative paths.
|
|
@@ -134,11 +240,11 @@ module Buildr
|
|
|
134
240
|
@excludes = [ '**/.svn/', '**/CVS/' ].join('|')
|
|
135
241
|
@paths_written = []
|
|
136
242
|
end
|
|
137
|
-
|
|
243
|
+
|
|
138
244
|
def write &block
|
|
139
245
|
@xml.classpath &block
|
|
140
246
|
end
|
|
141
|
-
|
|
247
|
+
|
|
142
248
|
def con path
|
|
143
249
|
@xml.classpathentry :kind=>'con', :path=>path
|
|
144
250
|
end
|
|
@@ -166,7 +272,7 @@ module Buildr
|
|
|
166
272
|
@xml.classpathentry :kind=>'src', :combineaccessrules=>'false', :path=>"/#{project_id}"
|
|
167
273
|
end
|
|
168
274
|
end
|
|
169
|
-
|
|
275
|
+
|
|
170
276
|
def output target
|
|
171
277
|
@xml.classpathentry :kind=>'output', :path=>relative(target)
|
|
172
278
|
end
|
|
@@ -185,7 +291,7 @@ module Buildr
|
|
|
185
291
|
@xml.classpathentry :kind=>'var', :path=>relative_lib_path, :sourcepath=>relative_source_path
|
|
186
292
|
end
|
|
187
293
|
end
|
|
188
|
-
|
|
294
|
+
|
|
189
295
|
private
|
|
190
296
|
|
|
191
297
|
# Find a path relative to the project's root directory.
|
|
@@ -214,9 +320,15 @@ module Buildr
|
|
|
214
320
|
end
|
|
215
321
|
|
|
216
322
|
end
|
|
217
|
-
end # module Buildr
|
|
218
323
|
|
|
324
|
+
end # module Buildr
|
|
219
325
|
|
|
220
326
|
class Buildr::Project
|
|
221
327
|
include Buildr::Eclipse
|
|
222
328
|
end
|
|
329
|
+
|
|
330
|
+
# Order is significant for auto-detection, from most specific to least
|
|
331
|
+
require 'buildr/ide/eclipse/plugin'
|
|
332
|
+
require 'buildr/ide/eclipse/scala'
|
|
333
|
+
require 'buildr/ide/eclipse/java'
|
|
334
|
+
|