buildr 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +35 -0
- data/README.rdoc +1 -1
- data/Rakefile +1 -1
- 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 +2 -1
- 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} +2 -67
- 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/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/doc/testing.textile
CHANGED
@@ -26,39 +26,31 @@ h2(#ignoring). Excluding Tests and Ignoring Failures
|
|
26
26
|
|
27
27
|
If you have a lot of tests that are failing or just hanging there collecting dusts, you can tell Buildr to ignore them. You can either tell Buildr to only run specific tests, for example:
|
28
28
|
|
29
|
-
<notextile>
|
30
29
|
{% highlight ruby %}
|
31
30
|
test.include 'com.acme.tests.passing.*'
|
32
31
|
{% endhighlight %}
|
33
|
-
</notextile>
|
34
32
|
|
35
33
|
Or tell it to exclude specific tests, for example:
|
36
34
|
|
37
|
-
<notextile>
|
38
35
|
{% highlight ruby %}
|
39
36
|
test.exclude '*FailingTest', '*FailingWorseTest'
|
40
37
|
{% endhighlight %}
|
41
|
-
</notextile>
|
42
38
|
|
43
39
|
Note that we're always using the package qualified class name, and you can use star (@*@) to substitute for any set of characters.
|
44
40
|
|
45
41
|
When tests fail, Buildr fails the @test@ task. This is usually a good thing, but you can also tell Buildr to ignore failures by resetting the @:fail_on_failure@ option:
|
46
42
|
|
47
|
-
<notextile>
|
48
43
|
{% highlight ruby %}
|
49
44
|
test.using :fail_on_failure=>false
|
50
45
|
{% endhighlight %}
|
51
|
-
</notextile>
|
52
46
|
|
53
47
|
Besides giving you a free pass to ignore failures, you can use it for other causes, for example, to be somewhat forgiving:
|
54
48
|
|
55
|
-
<notextile>
|
56
49
|
{% highlight ruby %}
|
57
50
|
test do
|
58
51
|
fail 'More than 3 tests failed!' if test.failed_tests.size > 3
|
59
52
|
end
|
60
53
|
{% endhighlight %}
|
61
|
-
</notextile>
|
62
54
|
|
63
55
|
The @failed_tests@ collection holds the names of all classes with failed tests. And there's @classes@, which holds the names of all test classes. Ruby arithmetic allows you to get the name of all passed test classes with a simple @test.classes – test.failed_tests@. We'll let you imagine creative use for these two.
|
64
56
|
|
@@ -67,56 +59,50 @@ h2(#running). Running Tests
|
|
67
59
|
|
68
60
|
It's a good idea to run tests every time you change the source code, so we wired the @build@ task to run the @test@ task at the end of the build. And conveniently enough, the @build@ task is the default task, so another way to build changes in your code and run your tests:
|
69
61
|
|
70
|
-
<notextile>
|
71
62
|
{% highlight sh %}
|
72
63
|
$ buildr
|
73
64
|
{% endhighlight %}
|
74
|
-
</notextile>
|
75
65
|
|
76
66
|
That only works with the local @build@ task and any local task that depends on it, like @package@, @install@ and @upload@. Each project also has its own @build@ task that does not invoke the @test@ task, so @buildr build@ will run the tests cases, but @buildr foo:build@ will not.
|
77
67
|
|
78
68
|
While it's a good idea to always run your tests, it's not always possible. There are two ways you can get @build@ to not run the @test@ task. You can set the environment variable @test@ to @no@ (but @skip@ and @off@ will also work). You can do that when running Buildr:
|
79
69
|
|
80
|
-
<notextile>
|
81
70
|
{% highlight sh %}
|
82
71
|
$ buildr test=no
|
83
72
|
{% endhighlight %}
|
84
|
-
</notextile>
|
85
73
|
|
86
74
|
Or set it once in your environment:
|
87
75
|
|
88
|
-
<notextile>
|
89
76
|
{% highlight sh %}
|
90
77
|
$ export TEST=no
|
91
78
|
$ buildr
|
92
79
|
{% endhighlight %}
|
93
|
-
</notextile>
|
94
80
|
|
95
81
|
If you're feeling really adventurous, you can also disable tests from your Buildfile or @buildr.rb@ file, by setting @options.test = false@. We didn't say it's a good idea, we're just giving you the option.
|
96
82
|
|
97
83
|
The @test@ task is just smart enough to run all the tests it finds, but will accept include/exclude patterns. Often enough you're only working on one broken test and you only want to run that one test. Better than changing your Buildfile, you can run the @test@ task with a pattern. For example:
|
98
84
|
|
99
|
-
<notextile>
|
100
85
|
{% highlight sh %}
|
101
86
|
$ buildr test:KillerAppTest
|
102
87
|
{% endhighlight %}
|
103
|
-
</notextile>
|
104
88
|
|
105
89
|
Buildr will then run only tests that match the pattern @KillerAppTest@. It uses pattern matching, so @test:Foo@ will run @com.acme.FooTest@ and @com.acme.FooBarTest@. With Java, you can use this to pick a class name, or a package name to run all tests in that package, or any such combination. In fact, you can specify several patterns separated with commas. For example:
|
106
90
|
|
107
|
-
<notextile>
|
108
91
|
{% highlight sh %}
|
109
92
|
$ buildr test:FooTest,BarTest
|
110
93
|
{% endhighlight %}
|
111
|
-
|
94
|
+
|
95
|
+
Buildr forcefully runs all tests that match the pattern. If you want to re-run all tests even if your sources have not changed, you can execute:
|
96
|
+
|
97
|
+
{% highlight sh %}
|
98
|
+
$ buildr test:*
|
99
|
+
{% endhighlight %}
|
112
100
|
|
113
101
|
As you probably noticed, Buildr will stop your build at the first test that fails. We think it's a good idea, except when it's not. If you're using a continuous build system, you'll want a report of all the failed tests without stopping at the first failure. To make that happen, set the environment variable @test@ to "all", or the Buildr @options.test@ option to @:all@. For example:
|
114
102
|
|
115
|
-
<notextile>
|
116
103
|
{% highlight sh %}
|
117
104
|
$ buildr package test=all
|
118
105
|
{% endhighlight %}
|
119
|
-
</notextile>
|
120
106
|
|
121
107
|
We're using @package@ and not @build@ above. When using a continuous build system, you want to make sure that packages are created, contain the right files, and also run the integration tests.
|
122
108
|
|
@@ -129,29 +115,23 @@ In contrast, integration tests are run with a number of components, in an enviro
|
|
129
115
|
|
130
116
|
You write integration tests much the same way as you write unit tests, using @test.compile@ and @test.resources@. However, you need to tell Buildr that your tests will execute during integration test. To do so, add the following line in your project definition:
|
131
117
|
|
132
|
-
<notextile>
|
133
118
|
{% highlight ruby %}
|
134
119
|
test.using :integration
|
135
120
|
{% endhighlight %}
|
136
|
-
</notextile>
|
137
121
|
|
138
122
|
Typically you'll use unit tests in projects that create internal modules, such as JARs, and integration tests in projects that create components, such as WARs and EARs. You only need to use the @:integration@ option with the later.
|
139
123
|
|
140
124
|
To run integration tests on the current project:
|
141
125
|
|
142
|
-
<notextile>
|
143
126
|
{% highlight sh %}
|
144
127
|
$ buildr integration
|
145
128
|
{% endhighlight %}
|
146
|
-
</notextile>
|
147
129
|
|
148
130
|
You can also run specific tests cases, for example:
|
149
131
|
|
150
|
-
<notextile>
|
151
132
|
{% highlight sh %}
|
152
133
|
$ buildr integration:ClientTest
|
153
134
|
{% endhighlight %}
|
154
|
-
</notextile>
|
155
135
|
|
156
136
|
If you run the @package@ task (or any task that depends on it, like @install@ and @upload@), Buildr will first run the @build@ task and all its unit tests, and then create the packages and run the integration tests. That gives you full coverage for your tests and ready to release packages. As with unit tests, you can set the environment variable @test@ to "no" to skip integration tests, or "all" to ignore failures.
|
157
137
|
|
@@ -162,12 +142,10 @@ Some tests need you to setup an environment before they run, and tear it down af
|
|
162
142
|
|
163
143
|
Integration tests run a setup task before the tests, and a teardown task afterwards. You can use this task to setup a Web server for testing your Web components, or a database server for testing persistence. You can access either task by calling @integration.setup@ and @integration.teardown@. For example:
|
164
144
|
|
165
|
-
<notextile>
|
166
145
|
{% highlight ruby %}
|
167
146
|
integration.setup { server.start ; server.deploy }
|
168
147
|
integration.teardown { server.stop }
|
169
148
|
{% endhighlight %}
|
170
|
-
</notextile>
|
171
149
|
|
172
150
|
Depending on your build, you may want to enhance the setup/teardown tasks from within a project, for example, to populate the database with data used by that project's test, or from outside the project definition, for example, to start and stop the Web server.
|
173
151
|
|
@@ -182,7 +160,6 @@ Each project has a @check@ task that runs just after packaging. You can use thi
|
|
182
160
|
|
183
161
|
You use the @check@ method to express and expectation. Buildr will then run all these expectations against your project, and fail at the first expectation that doesn't match. An expectation says three things. Let's look at a few examples:
|
184
162
|
|
185
|
-
<notextile>
|
186
163
|
{% highlight ruby %}
|
187
164
|
check package(:war), 'should exist' do
|
188
165
|
it.should exist
|
@@ -206,19 +183,16 @@ check file('target/classes/killerapp/Code.class'), 'should exist' do
|
|
206
183
|
it.should exist
|
207
184
|
end
|
208
185
|
{% endhighlight %}
|
209
|
-
</notextile>
|
210
186
|
|
211
187
|
The first argument is the subject, or the project if you skip the first argument. The second argument is the description, optional, but we recommend using it. The method @it@ returns the subject.
|
212
188
|
|
213
189
|
You can also write the first expectation like this:
|
214
190
|
|
215
|
-
<notextile>
|
216
191
|
{% highlight ruby %}
|
217
192
|
check do
|
218
193
|
package(:jar).should exist
|
219
194
|
end
|
220
195
|
{% endhighlight %}
|
221
|
-
</notextile>
|
222
196
|
|
223
197
|
We recommend using the subject and description, they make your build easier to read and maintain, and produce better error messages.
|
224
198
|
|
data/lib/buildr.rb
CHANGED
@@ -14,13 +14,14 @@
|
|
14
14
|
# the License.
|
15
15
|
|
16
16
|
module Buildr
|
17
|
-
VERSION = '1.3.
|
17
|
+
VERSION = '1.3.5'.freeze
|
18
18
|
end
|
19
19
|
|
20
20
|
require 'buildr/core'
|
21
21
|
require 'buildr/packaging'
|
22
22
|
require 'buildr/java'
|
23
23
|
require 'buildr/ide'
|
24
|
+
require 'buildr/shell'
|
24
25
|
|
25
26
|
# Methods defined in Buildr are both instance methods (e.g. when included in Project)
|
26
27
|
# and class methods when invoked like Buildr.artifacts().
|
data/lib/buildr/core.rb
CHANGED
@@ -14,6 +14,11 @@
|
|
14
14
|
# the License.
|
15
15
|
|
16
16
|
|
17
|
+
# TODO: Antwrap 0.7 requires this monkeypatch, have it fixed.
|
18
|
+
class Array #:nodoc:
|
19
|
+
alias :nitems :size
|
20
|
+
end
|
21
|
+
|
17
22
|
require 'buildr/core/common'
|
18
23
|
require 'buildr/core/application'
|
19
24
|
require 'buildr/core/project'
|
@@ -23,6 +28,7 @@ require 'buildr/core/build'
|
|
23
28
|
require 'buildr/core/filter'
|
24
29
|
require 'buildr/core/compile'
|
25
30
|
require 'buildr/core/test'
|
31
|
+
require 'buildr/core/shell'
|
26
32
|
require 'buildr/core/checks'
|
27
33
|
require 'buildr/core/transports'
|
28
34
|
require 'buildr/core/generate'
|
@@ -396,11 +396,6 @@ module Buildr
|
|
396
396
|
def raw_load_buildfile # replaces raw_load_rakefile
|
397
397
|
puts "(in #{Dir.pwd}, #{environment})" unless options.silent
|
398
398
|
load File.expand_path(@rakefile) if @rakefile && @rakefile != ''
|
399
|
-
options.rakelib.each do |rlib|
|
400
|
-
glob("#{rlib}/*.rake") do |name|
|
401
|
-
add_import name
|
402
|
-
end
|
403
|
-
end
|
404
399
|
load_imports
|
405
400
|
Buildr.projects
|
406
401
|
end
|
@@ -456,6 +451,8 @@ module Buildr
|
|
456
451
|
files = [ File.expand_path('buildr.rb', ENV['HOME']), 'buildr.rb' ].select { |file| File.exist?(file) }
|
457
452
|
files += [ File.expand_path('buildr.rake', ENV['HOME']), File.expand_path('buildr.rake') ].
|
458
453
|
select { |file| File.exist?(file) }.each { |file| warn "Please use '#{file.ext('rb')}' instead of '#{file}'" }
|
454
|
+
files += (options.rakelib || []).collect { |rlib| Dir["#{rlib}/*.rake"] }.flatten
|
455
|
+
|
459
456
|
files.each do |file|
|
460
457
|
unless $LOADED_FEATURES.include?(file)
|
461
458
|
load file
|
data/lib/buildr/core/build.rb
CHANGED
@@ -108,8 +108,7 @@ module Buildr
|
|
108
108
|
|
109
109
|
|
110
110
|
module Git #:nodoc:
|
111
|
-
|
112
|
-
module_function
|
111
|
+
module_function
|
113
112
|
|
114
113
|
# :call-seq:
|
115
114
|
# git(*args)
|
@@ -127,7 +126,7 @@ module Buildr
|
|
127
126
|
|
128
127
|
# Returns list of uncommited/untracked files as reported by git status.
|
129
128
|
def uncommitted_files
|
130
|
-
`git status`.scan(
|
129
|
+
`git status`.scan(/^#(\t|\s{7})(\S.*)$/).map { |match| match.last.split.last }
|
131
130
|
end
|
132
131
|
|
133
132
|
# Commit the given file with a message.
|
@@ -148,23 +147,19 @@ module Buildr
|
|
148
147
|
# Return the name of the remote repository whose branch the current local branch tracks,
|
149
148
|
# or nil if none.
|
150
149
|
def remote(branch = current_branch)
|
151
|
-
remote = git('config', '--get', "branch.#{branch}.remote").strip
|
152
|
-
remote if git('remote').include?(remote)
|
153
|
-
rescue
|
154
|
-
nil
|
150
|
+
remote = git('config', '--get', "branch.#{branch}.remote").to_s.strip
|
151
|
+
remote if !remote.empty? && git('remote').include?(remote)
|
155
152
|
end
|
156
153
|
|
157
154
|
# Return the name of the current branch
|
158
155
|
def current_branch
|
159
156
|
git('branch')[/^\* (.*)$/, 1]
|
160
157
|
end
|
161
|
-
|
162
158
|
end
|
163
159
|
|
164
160
|
|
165
161
|
module Svn #:nodoc:
|
166
|
-
|
167
|
-
module_function
|
162
|
+
module_function
|
168
163
|
|
169
164
|
# :call-seq:
|
170
165
|
# svn(*args)
|
@@ -246,6 +241,15 @@ module Buildr
|
|
246
241
|
@list ||= []
|
247
242
|
end
|
248
243
|
|
244
|
+
# Finds and returns the Release instance for this project.
|
245
|
+
def find
|
246
|
+
unless @release
|
247
|
+
klass = list.detect { |impl| impl.applies_to? }
|
248
|
+
@release = klass.new if klass
|
249
|
+
end
|
250
|
+
@release
|
251
|
+
end
|
252
|
+
|
249
253
|
end
|
250
254
|
|
251
255
|
# Use this to specify a different tag name for tagging the release in source control.
|
@@ -307,7 +311,7 @@ module Buildr
|
|
307
311
|
# for the release buildfile.
|
308
312
|
def with_release_candidate_version
|
309
313
|
release_candidate_buildfile = Buildr.application.buildfile.to_s + '.next'
|
310
|
-
release_candidate_buildfile_contents = change_version { |version| version[-1] = version[-1].
|
314
|
+
release_candidate_buildfile_contents = change_version { |version| version[-1] = version[-1].split('-')[0] }
|
311
315
|
File.open(release_candidate_buildfile, 'w') { |file| file.write release_candidate_buildfile_contents }
|
312
316
|
begin
|
313
317
|
yield release_candidate_buildfile
|
@@ -344,7 +348,7 @@ module Buildr
|
|
344
348
|
|
345
349
|
# Move the version to next and save the updated buildfile
|
346
350
|
def update_buildfile
|
347
|
-
buildfile = change_version { |version| version[-1] = (version[-1].to_i + 1)
|
351
|
+
buildfile = change_version { |version| version[-1] = sprintf("%0#{version[-1].size}d", version[-1].to_i + 1) + '-SNAPSHOT' }
|
348
352
|
File.open(Buildr.application.buildfile.to_s, 'w') { |file| file.write buildfile }
|
349
353
|
end
|
350
354
|
|
@@ -364,8 +368,14 @@ module Buildr
|
|
364
368
|
|
365
369
|
class GitRelease < Release
|
366
370
|
class << self
|
367
|
-
def applies_to?
|
368
|
-
File.exist?
|
371
|
+
def applies_to?
|
372
|
+
if File.exist? '.git/config'
|
373
|
+
true
|
374
|
+
else
|
375
|
+
File.expand_path(Dir.pwd) != '/' && Dir.chdir('..') do
|
376
|
+
applies_to?
|
377
|
+
end
|
378
|
+
end
|
369
379
|
end
|
370
380
|
end
|
371
381
|
|
@@ -402,8 +412,8 @@ module Buildr
|
|
402
412
|
|
403
413
|
class SvnRelease < Release
|
404
414
|
class << self
|
405
|
-
def applies_to?
|
406
|
-
File.exist?
|
415
|
+
def applies_to?
|
416
|
+
File.exist?('.svn')
|
407
417
|
end
|
408
418
|
end
|
409
419
|
|
@@ -429,9 +439,9 @@ module Buildr
|
|
429
439
|
|
430
440
|
desc 'Make a release'
|
431
441
|
task 'release' do |task|
|
432
|
-
|
433
|
-
fail 'Unable to detect the Version Control System.' unless
|
434
|
-
|
442
|
+
release = Release.find
|
443
|
+
fail 'Unable to detect the Version Control System.' unless release
|
444
|
+
release.make
|
435
445
|
end
|
436
446
|
|
437
447
|
end
|
data/lib/buildr/core/compile.rb
CHANGED
@@ -122,7 +122,7 @@ 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) }
|
125
|
+
source_files_not_yet_compiled = map.select { |source, target| !File.exist?(target) }.to_a
|
126
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?
|
127
127
|
return true if map.any? { |source, target| !File.exist?(target) || File.stat(source).mtime > File.stat(target).mtime }
|
128
128
|
oldest = map.map { |source, target| File.stat(target).mtime }.min
|
@@ -175,14 +175,32 @@ module Buildr
|
|
175
175
|
FileList["#{source}/**/*.{#{ext_glob}}"].reject { |file| File.directory?(file) }.
|
176
176
|
each { |file| map[file] = File.join(target, Util.relative_path(file, source).ext(target_ext)) }
|
177
177
|
else
|
178
|
-
|
178
|
+
# try to extract package name from .java or .scala files
|
179
|
+
if ['.java', '.scala', '.groovy'].include? File.extname(source)
|
180
|
+
package = findFirst(source, /^\s*package\s+(\S+)\s*;?\s*$/)
|
181
|
+
map[source] = package ? File.join(target, package[1].gsub('.', '/'), File.basename(source).ext(target_ext)) : target
|
182
|
+
elsif
|
183
|
+
map[source] = target
|
184
|
+
end
|
179
185
|
end
|
180
186
|
map
|
181
187
|
end
|
182
188
|
end
|
189
|
+
|
190
|
+
private
|
183
191
|
|
184
|
-
|
192
|
+
def findFirst(file, pattern)
|
193
|
+
match = nil
|
194
|
+
File.open(file, "r") do |infile|
|
195
|
+
while (line = infile.gets)
|
196
|
+
match = line.match(pattern)
|
197
|
+
break if match
|
198
|
+
end
|
199
|
+
end
|
200
|
+
match
|
201
|
+
end
|
185
202
|
|
203
|
+
end
|
186
204
|
end
|
187
205
|
|
188
206
|
|
@@ -244,7 +262,7 @@ module Buildr
|
|
244
262
|
#
|
245
263
|
# For example:
|
246
264
|
# compile.from('src/java').into('classes').with('module1.jar')
|
247
|
-
def from(*sources)
|
265
|
+
def from(*sources)
|
248
266
|
@sources |= sources.flatten
|
249
267
|
guess_compiler if @compiler.nil? && sources.flatten.any? { |source| File.exist?(source) }
|
250
268
|
self
|
data/lib/buildr/core/filter.rb
CHANGED
@@ -285,7 +285,7 @@ module Buildr
|
|
285
285
|
@config = configurer.call(*args, &block)
|
286
286
|
else
|
287
287
|
raise ArgumentError, "Missing hash argument after :#{mapper_type}" unless args.size == 1 && Hash === args[0]
|
288
|
-
@config =
|
288
|
+
@config = args.first
|
289
289
|
end
|
290
290
|
@mapper_type = mapper_type
|
291
291
|
end
|
@@ -312,10 +312,8 @@ module Buildr
|
|
312
312
|
|
313
313
|
def erb_transform(content, path = nil)
|
314
314
|
case config
|
315
|
-
when Binding
|
315
|
+
when Binding
|
316
316
|
bnd = config
|
317
|
-
when Method
|
318
|
-
bnd = config.to_proc
|
319
317
|
when Hash
|
320
318
|
bnd = OpenStruct.new
|
321
319
|
table = config.inject({}) { |h, e| h[e.first.to_sym] = e.last; h }
|
data/lib/buildr/core/project.rb
CHANGED
@@ -222,7 +222,7 @@ module Buildr
|
|
222
222
|
@on_define.each { |callback| callback[project] }
|
223
223
|
end if @on_define
|
224
224
|
# Enhance the project using the definition block.
|
225
|
-
project.enhance { project.
|
225
|
+
project.enhance { project.instance_exec project, &block } if block
|
226
226
|
|
227
227
|
# Top-level project? Invoke the project definition. Sub-project? We don't invoke
|
228
228
|
# the project definiton yet (allow project calls to establish order of evaluation),
|
@@ -317,11 +317,12 @@ module Buildr
|
|
317
317
|
#
|
318
318
|
# The optional block is called with the project name when the task executes
|
319
319
|
# and returns a message that, for example "Building project #{name}".
|
320
|
-
def local_task(args, &block)
|
321
|
-
task args do |task|
|
320
|
+
def local_task(*args, &block)
|
321
|
+
task *args do |task, args|
|
322
|
+
args = task.arg_names.map {|n| args[n]}
|
322
323
|
local_projects do |project|
|
323
324
|
info block.call(project.name) if block
|
324
|
-
task("#{project.name}:#{task.name}").invoke
|
325
|
+
task("#{project.name}:#{task.name}").invoke *args
|
325
326
|
end
|
326
327
|
end
|
327
328
|
end
|
@@ -0,0 +1,198 @@
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
# License for the specific language governing permissions and limitations under
|
14
|
+
# the License.
|
15
|
+
|
16
|
+
|
17
|
+
require 'buildr/shell'
|
18
|
+
require 'buildr/java/commands'
|
19
|
+
require 'buildr/core/util'
|
20
|
+
|
21
|
+
module Buildr
|
22
|
+
module Shell
|
23
|
+
|
24
|
+
class BeanShell < Base
|
25
|
+
|
26
|
+
include JavaRebel
|
27
|
+
|
28
|
+
VERSION = '2.0b4'
|
29
|
+
|
30
|
+
class << self
|
31
|
+
def version
|
32
|
+
Buildr.settings.build['bsh'] || VERSION
|
33
|
+
end
|
34
|
+
|
35
|
+
def artifact
|
36
|
+
"org.beanshell:bsh:jar:#{version}"
|
37
|
+
end
|
38
|
+
|
39
|
+
def lang
|
40
|
+
:java
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_sym
|
44
|
+
:bsh
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def launch
|
49
|
+
cp = project.compile.dependencies + [project.path_to(:target, :classes), Buildr.artifact(BeanShell.artifact)]
|
50
|
+
Java::Commands.java 'bsh.Console', {
|
51
|
+
:properties => rebel_props(project),
|
52
|
+
:classpath => cp,
|
53
|
+
:java_args => rebel_args
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
end # BeanShell
|
58
|
+
|
59
|
+
|
60
|
+
class JIRB < Base
|
61
|
+
include JavaRebel
|
62
|
+
|
63
|
+
JRUBY_VERSION = '1.3.1'
|
64
|
+
|
65
|
+
class << self
|
66
|
+
def lang
|
67
|
+
:none
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def launch
|
72
|
+
if jruby_home # if JRuby is installed, use it
|
73
|
+
cp = project.compile.dependencies +
|
74
|
+
[project.path_to(:target, :classes)] +
|
75
|
+
Dir.glob("#{jruby_home}#{File::SEPARATOR}lib#{File::SEPARATOR}*.jar")
|
76
|
+
|
77
|
+
props = {
|
78
|
+
'jruby.home' => jruby_home,
|
79
|
+
'jruby.lib' => "#{jruby_home}#{File::SEPARATOR}lib"
|
80
|
+
}
|
81
|
+
|
82
|
+
if not Util.win_os?
|
83
|
+
uname = `uname -m`
|
84
|
+
cpu = if uname =~ /i[34567]86/
|
85
|
+
'i386'
|
86
|
+
elsif uname == 'i86pc'
|
87
|
+
'x86'
|
88
|
+
elsif uname =~ /amd64|x86_64/
|
89
|
+
'amd64'
|
90
|
+
end
|
91
|
+
|
92
|
+
os = `uname -s | tr '[A-Z]' '[a-z]'`
|
93
|
+
path = if os == 'darwin'
|
94
|
+
'darwin'
|
95
|
+
else
|
96
|
+
"#{os}-#{cpu}"
|
97
|
+
end
|
98
|
+
|
99
|
+
props['jna.boot.library.path'] = "#{jruby_home}/lib/native/#{path}"
|
100
|
+
end
|
101
|
+
|
102
|
+
props['jruby.script'] = if Util.win_os? then 'jruby.bat' else 'jruby' end
|
103
|
+
props['jruby.shell'] = if Util.win_os? then 'cmd.exe' else '/bin/sh' end
|
104
|
+
|
105
|
+
args = [
|
106
|
+
"-Xbootclasspath/a:#{Dir.glob("#{jruby_home}#{File::SEPARATOR}lib#{File::SEPARATOR}jruby*.jar").join File::PATH_SEPARATOR}"
|
107
|
+
]
|
108
|
+
|
109
|
+
Java::Commands.java 'org.jruby.Main', "#{jruby_home}#{File::SEPARATOR}bin#{File::SEPARATOR}jirb", {
|
110
|
+
:properties => props.merge(rebel_props(project)),
|
111
|
+
:classpath => cp,
|
112
|
+
:java_args => args + rebel_args
|
113
|
+
}
|
114
|
+
else
|
115
|
+
cp = project.compile.dependencies + [
|
116
|
+
jruby_artifact,
|
117
|
+
project.path_to(:target, :classes)
|
118
|
+
]
|
119
|
+
|
120
|
+
Java::Commands.java 'org.jruby.Main', '--command', 'irb', {
|
121
|
+
:properties => rebel_props(project),
|
122
|
+
:classpath => cp,
|
123
|
+
:java_args => rebel_args
|
124
|
+
}
|
125
|
+
end
|
126
|
+
end
|
127
|
+
private
|
128
|
+
def jruby_home
|
129
|
+
@jruby_home ||= RUBY_PLATFORM =~ /java/ ? Config::CONFIG['prefix'] : ENV['JRUBY_HOME']
|
130
|
+
end
|
131
|
+
|
132
|
+
def jruby_artifact
|
133
|
+
version = Buildr.settings.build['jruby'] || JRUBY_VERSION
|
134
|
+
"org.jruby:jruby-complete:jar:#{version}"
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
class Clojure < Base
|
140
|
+
include JavaRebel
|
141
|
+
|
142
|
+
JLINE_VERSION = '0.9.94'
|
143
|
+
|
144
|
+
class << self
|
145
|
+
def lang
|
146
|
+
:none
|
147
|
+
end
|
148
|
+
|
149
|
+
def to_sym
|
150
|
+
:clj # more common than `clojure`
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# don't build if it's *only* Clojure sources
|
155
|
+
def build?
|
156
|
+
!has_source?(:clojure) or has_source?(:java) or has_source?(:scala) or has_source?(:groovy)
|
157
|
+
end
|
158
|
+
|
159
|
+
def launch
|
160
|
+
fail 'Are we forgetting something? CLOJURE_HOME not set.' unless clojure_home
|
161
|
+
|
162
|
+
cp = project.compile.dependencies +
|
163
|
+
[
|
164
|
+
if build?
|
165
|
+
project.path_to(:target, :classes)
|
166
|
+
else
|
167
|
+
project.path_to(:src, :main, :clojure)
|
168
|
+
end,
|
169
|
+
File.expand_path('clojure.jar', clojure_home),
|
170
|
+
'jline:jline:jar:0.9.94'
|
171
|
+
]
|
172
|
+
|
173
|
+
if build?
|
174
|
+
Java::Commands.java 'jline.ConsoleRunner', 'clojure.lang.Repl', {
|
175
|
+
:properties => rebel_props(project),
|
176
|
+
:classpath => cp,
|
177
|
+
:java_args => rebel_args
|
178
|
+
}
|
179
|
+
else
|
180
|
+
Java::Commands.java 'jline.ConsoleRunner', 'clojure.lang.Repl', :classpath => cp
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
private
|
185
|
+
def clojure_home
|
186
|
+
@home ||= ENV['CLOJURE_HOME']
|
187
|
+
end
|
188
|
+
|
189
|
+
def has_source?(lang)
|
190
|
+
File.exists? project.path_to(:src, :main, lang)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
Buildr::ShellProviders << Buildr::Shell::BeanShell
|
197
|
+
Buildr::ShellProviders << Buildr::Shell::JIRB
|
198
|
+
Buildr::ShellProviders << Buildr::Shell::Clojure
|