buildr 1.4.7.pre2-java → 1.4.8-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 +65 -2
- data/Rakefile +3 -6
- data/addon/buildr/bnd.rb +13 -3
- data/addon/buildr/{checkstyle.rake → checkstyle.rb} +1 -1
- data/addon/buildr/{findbugs.rake → findbugs.rb} +0 -0
- data/addon/buildr/git_auto_version.rb +33 -0
- data/addon/buildr/gwt.rb +82 -0
- data/addon/buildr/jacoco.rb +194 -0
- data/addon/buildr/{javancss.rake → javancss.rb} +0 -0
- data/addon/buildr/nailgun.rb +2 -2
- data/addon/buildr/{pmd.rake → pmd.rb} +3 -1
- data/addon/buildr/sonar.rb +142 -0
- data/buildr.buildfile +1 -1
- data/buildr.gemspec +37 -26
- data/doc/_layouts/default.html +0 -2
- data/doc/contributing.textile +47 -0
- data/doc/download.textile +24 -0
- data/doc/index.textile +43 -23
- data/doc/languages.textile +65 -6
- data/doc/more_stuff.textile +43 -0
- data/doc/packaging.textile +2 -0
- data/doc/settings_profiles.textile +1 -1
- data/etc/KEYS +44 -0
- data/lib/buildr.rb +3 -7
- data/lib/buildr/core/application.rb +41 -8
- data/lib/buildr/core/build.rb +102 -1
- data/lib/buildr/core/cc.rb +14 -8
- data/lib/buildr/core/doc.rb +9 -3
- data/lib/buildr/core/generate.rb +150 -9
- data/lib/buildr/core/run.rb +1 -1
- data/lib/buildr/core/shell.rb +1 -1
- data/lib/buildr/core/test.rb +1 -1
- data/lib/buildr/core/util.rb +5 -5
- data/lib/buildr/ide/eclipse.rb +118 -4
- data/lib/buildr/ide/idea.rb +278 -1
- data/lib/buildr/java/ant.rb +2 -3
- data/lib/buildr/java/bdd.rb +4 -4
- data/lib/buildr/java/commands.rb +1 -1
- data/lib/buildr/java/pom.rb +5 -4
- data/lib/buildr/java/rjb.rb +5 -4
- data/lib/buildr/java/test_result.rb +4 -0
- data/lib/buildr/packaging/artifact.rb +1 -1
- data/lib/buildr/packaging/version_requirement.rb +1 -1
- data/lib/buildr/packaging/zip.rb +1 -1
- data/lib/buildr/packaging/ziptask.rb +2 -2
- data/lib/buildr/run.rb +3 -2
- data/lib/buildr/scala.rb +1 -1
- data/lib/buildr/scala/bdd.rb +9 -2
- data/lib/buildr/scala/compiler.rb +94 -4
- data/lib/buildr/scala/doc.rb +17 -5
- data/lib/buildr/scala/org/apache/buildr/Specs2Runner.class +0 -0
- data/lib/buildr/scala/tests.rb +15 -4
- data/lib/buildr/version.rb +1 -1
- data/rakelib/all-in-one.rake +50 -47
- data/rakelib/checks.rake +4 -4
- data/rakelib/doc.rake +84 -87
- data/rakelib/metrics.rake +9 -9
- data/rakelib/package.rake +14 -35
- data/rakelib/release.rake +11 -12
- data/rakelib/rspec.rake +73 -60
- data/rakelib/stage.rake +32 -54
- data/spec/addon/bnd_spec.rb +61 -7
- data/spec/core/application_spec.rb +1 -1
- data/spec/core/build_spec.rb +117 -0
- data/spec/core/cc_spec.rb +37 -15
- data/spec/core/common_spec.rb +3 -2
- data/spec/core/compile_spec.rb +3 -3
- data/spec/core/doc_spec.rb +1 -1
- data/spec/core/generate_from_eclipse_spec.rb +280 -0
- data/spec/core/run_spec.rb +17 -4
- data/spec/core/test_spec.rb +5 -3
- data/spec/ide/idea_spec.rb +2 -2
- data/spec/java/bdd_spec.rb +2 -2
- data/spec/java/cobertura_spec.rb +4 -0
- data/spec/java/emma_spec.rb +4 -1
- data/spec/java/java_spec.rb +1 -1
- data/spec/java/packaging_spec.rb +2 -1
- data/spec/java/pom_spec.rb +125 -0
- data/spec/packaging/archive_spec.rb +25 -2
- data/spec/packaging/artifact_spec.rb +3 -3
- data/spec/sandbox.rb +7 -2
- data/spec/scala/compiler_spec.rb +41 -0
- data/spec/scala/doc_spec.rb +22 -3
- data/spec/scala/scala.rb +2 -2
- data/spec/scala/tests_spec.rb +2 -2
- data/spec/spec_helpers.rb +6 -1
- data/spec/version_requirement_spec.rb +2 -0
- metadata +651 -480
- data/lib/buildr/ide/eclipse/java.rb +0 -49
- data/lib/buildr/ide/eclipse/plugin.rb +0 -67
- data/lib/buildr/ide/eclipse/scala.rb +0 -64
data/rakelib/stage.rake
CHANGED
@@ -13,80 +13,67 @@
|
|
13
13
|
# License for the specific language governing permissions and limitations under
|
14
14
|
# the License.
|
15
15
|
|
16
|
-
|
16
|
+
require 'rubyforge'
|
17
17
|
require 'digest/md5'
|
18
18
|
require 'digest/sha1'
|
19
19
|
|
20
20
|
gpg_cmd = 'gpg2'
|
21
21
|
|
22
|
-
task
|
22
|
+
task 'prepare' do |task, args|
|
23
|
+
gpg_arg = args.gpg || ENV['gpg']
|
24
|
+
|
25
|
+
if false
|
23
26
|
# Make sure we're doing a release from checked code.
|
24
27
|
lambda do
|
25
|
-
puts
|
28
|
+
puts 'Checking there are no local changes ... '
|
26
29
|
svn = `svn status`
|
27
30
|
fail "Cannot release unless all local changes are in SVN:\n#{svn}" unless svn.empty?
|
28
31
|
git = `git status -s`
|
29
32
|
fail "Cannot release unless all local changes are in Git:\n#{git}" if git[/^ M/] && ENV["IGNORE_GIT"].nil?
|
30
|
-
puts
|
33
|
+
puts '[X] There are no local changes, everything is in source control'
|
31
34
|
end.call
|
32
35
|
|
33
36
|
# Make sure we have a valid CHANGELOG entry for this release.
|
34
37
|
lambda do
|
35
|
-
puts
|
38
|
+
puts 'Checking that CHANGELOG indicates most recent version and today''s date ... '
|
36
39
|
expecting = "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})"
|
37
40
|
header = File.readlines('CHANGELOG').first.chomp
|
38
41
|
fail "Expecting CHANGELOG to start with #{expecting}, but found #{header} instead" unless expecting == header
|
39
|
-
puts
|
42
|
+
puts '[x] CHANGELOG indicates most recent version and today''s date'
|
40
43
|
end.call
|
44
|
+
end
|
41
45
|
|
42
46
|
# Need GPG to sign the packages.
|
43
47
|
lambda do
|
44
|
-
|
45
|
-
gpg_ok = `gpg2 --list-keys #{
|
48
|
+
gpg_arg or fail 'Please run with gpg=<argument for gpg --local-user>'
|
49
|
+
gpg_ok = `gpg2 --list-keys #{gpg_arg}` rescue nil
|
46
50
|
if !$?.success?
|
47
|
-
gpg_ok = `gpg --list-keys #{
|
51
|
+
gpg_ok = `gpg --list-keys #{gpg_arg}`
|
48
52
|
gpg_cmd = 'gpg'
|
49
53
|
end
|
50
|
-
fail "No GPG user #{
|
54
|
+
fail "No GPG user #{gpg_arg}" if gpg_ok.empty?
|
51
55
|
end.call
|
52
56
|
|
53
|
-
task(
|
54
|
-
|
55
|
-
# Need JRuby, Scala and Groovy installed to run all the specs.
|
56
|
-
lambda do
|
57
|
-
puts "Checking that we have JRuby, Scala and Groovy available ... "
|
58
|
-
sh 'jruby --version'
|
59
|
-
sh 'scala -version'
|
60
|
-
sh 'groovy -version'
|
61
|
-
puts "[X] We have JRuby, Scala and Groovy"
|
62
|
-
end.call
|
57
|
+
task('license').invoke
|
63
58
|
|
64
59
|
# Need Prince to generate PDF
|
65
60
|
lambda do
|
66
|
-
puts
|
61
|
+
puts 'Checking that we have prince available ... '
|
67
62
|
sh 'prince --version'
|
68
|
-
puts
|
69
|
-
end.call
|
70
|
-
|
71
|
-
# Need RubyForge to upload new release files.
|
72
|
-
lambda do
|
73
|
-
puts "[!] Make sure you have admin privileges to make a release on RubyForge"
|
74
|
-
rubyforge = RubyForge.new.configure
|
75
|
-
rubyforge.login
|
76
|
-
rubyforge.scrape_project(spec.name)
|
63
|
+
puts '[X] We have prince available'
|
77
64
|
end.call
|
78
65
|
|
79
|
-
|
80
|
-
|
66
|
+
raise "Can not run stage process under jruby" if RUBY_PLATFORM[/java/]
|
67
|
+
raise "Can not run staging process under older rubies" unless RUBY_VERSION >= '1.9'
|
81
68
|
end
|
82
69
|
|
83
|
-
|
84
|
-
|
70
|
+
task 'stage' => %w(clobber prepare) do |task, args|
|
71
|
+
gpg_arg = args.gpg || ENV['gpg']
|
85
72
|
mkpath '_staged'
|
86
73
|
|
87
74
|
# Start by figuring out what has changed.
|
88
75
|
lambda do
|
89
|
-
puts
|
76
|
+
puts 'Looking for changes between this release and previous one ...'
|
90
77
|
pattern = /(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/
|
91
78
|
changes = File.read('CHANGELOG').scan(pattern).inject({}) { |hash, set| hash[set[1]] = set[2] ; hash }
|
92
79
|
current = changes[spec.version.to_s]
|
@@ -95,14 +82,14 @@ task :stage=>[:clobber, :prepare] do |task, args|
|
|
95
82
|
file.write "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})\n"
|
96
83
|
file.write current
|
97
84
|
end
|
98
|
-
puts
|
85
|
+
puts '[X] Listed most recent changed in _staged/CHANGES'
|
99
86
|
end.call
|
100
87
|
|
101
88
|
# Create the packages (gem, tarball) and sign them. This requires user
|
102
89
|
# intervention so the earlier we do it the better.
|
103
90
|
lambda do
|
104
|
-
puts
|
105
|
-
task(
|
91
|
+
puts 'Creating and signing release packages ...'
|
92
|
+
task('package').invoke
|
106
93
|
mkpath '_staged/dist'
|
107
94
|
FileList['pkg/*.{gem,zip,tgz}'].each do |source|
|
108
95
|
pkg = source.pathmap('_staged/dist/%n%x')
|
@@ -110,16 +97,16 @@ task :stage=>[:clobber, :prepare] do |task, args|
|
|
110
97
|
bytes = File.open(pkg, 'rb') { |file| file.read }
|
111
98
|
File.open(pkg + '.md5', 'w') { |file| file.write Digest::MD5.hexdigest(bytes) << ' ' << File.basename(pkg) }
|
112
99
|
File.open(pkg + '.sha1', 'w') { |file| file.write Digest::SHA1.hexdigest(bytes) << ' ' << File.basename(pkg) }
|
113
|
-
sh gpg_cmd, '--local-user',
|
100
|
+
sh gpg_cmd, '--local-user', gpg_arg, '--armor', '--output', pkg + '.asc', '--detach-sig', pkg, :verbose=>true
|
114
101
|
end
|
115
102
|
cp 'etc/KEYS', '_staged/dist'
|
116
|
-
puts
|
103
|
+
puts '[X] Created and signed release packages in _staged/dist'
|
117
104
|
end.call
|
118
105
|
|
119
106
|
# The download page should link to the new binaries/sources, and we
|
120
107
|
# want to do that before generating the site/documentation.
|
121
108
|
lambda do
|
122
|
-
puts
|
109
|
+
puts 'Updating download page with links to release packages ... '
|
123
110
|
mirror = "http://www.apache.org/dyn/closer.cgi/#{spec.name}/#{spec.version}"
|
124
111
|
official = "http://www.apache.org/dist/#{spec.name}/#{spec.version}"
|
125
112
|
rows = FileList['_staged/dist/*.{gem,tgz,zip}'].map { |pkg|
|
@@ -147,10 +134,10 @@ p>. ("Release signing keys":#{official}/KEYS)
|
|
147
134
|
# Now we can create the Web site, this includes running specs, coverage report, etc.
|
148
135
|
# This will take a while, so we want to do it as last step before upload.
|
149
136
|
lambda do
|
150
|
-
puts
|
137
|
+
puts 'Creating new Web site'
|
151
138
|
task(:site).invoke
|
152
139
|
cp_r '_site', '_staged/site'
|
153
|
-
puts
|
140
|
+
puts '[X] Created new Web site in _staged/site'
|
154
141
|
end.call
|
155
142
|
|
156
143
|
|
@@ -189,13 +176,6 @@ The documentation generated for this release is available here:
|
|
189
176
|
#{base_url}/site/
|
190
177
|
#{base_url}/site/buildr.pdf
|
191
178
|
|
192
|
-
The official specification against which this release was tested:
|
193
|
-
#{base_url}/site/specs.html
|
194
|
-
|
195
|
-
Test coverage report:
|
196
|
-
#{base_url}/site/coverage/index.html
|
197
|
-
|
198
|
-
|
199
179
|
The following changes were made since #{previous_version}:
|
200
180
|
|
201
181
|
#{changes.gsub(/^/, ' ')}
|
@@ -203,11 +183,9 @@ The following changes were made since #{previous_version}:
|
|
203
183
|
File.open 'vote-email.txt', 'w' do |file|
|
204
184
|
file.write email
|
205
185
|
end
|
206
|
-
puts
|
186
|
+
puts '[X] Created release vote email template in ''vote-email.txt'''
|
207
187
|
puts email
|
208
188
|
end.call
|
209
|
-
|
210
189
|
end
|
211
190
|
|
212
|
-
|
213
|
-
task(:clobber) { rm_rf '_staged' }
|
191
|
+
task('clobber') { rm_rf '_staged' }
|
data/spec/addon/bnd_spec.rb
CHANGED
@@ -32,6 +32,59 @@ def open_main_manifest_section(file = 'target/foo-2.1.3.jar')
|
|
32
32
|
end
|
33
33
|
|
34
34
|
describe Buildr::Bnd do
|
35
|
+
before do
|
36
|
+
repositories.remote << Buildr::Bnd.remote_repository
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "project.bnd version (assure backward compatibility)" do
|
40
|
+
|
41
|
+
after do
|
42
|
+
STDERR.puts("backward compatibility: used #{Buildr::Bnd.version} restoring #{@savedVersion}")
|
43
|
+
Buildr::Bnd.version = @savedVersion
|
44
|
+
end
|
45
|
+
|
46
|
+
before do
|
47
|
+
@savedVersion = Buildr::Bnd.version
|
48
|
+
Buildr::Bnd.version = '0.0.384'
|
49
|
+
write "src/main/java/com/biz/Foo.java", <<SRC
|
50
|
+
package com.biz;
|
51
|
+
public class Foo {}
|
52
|
+
SRC
|
53
|
+
write "bar/src/main/java/com/biz/bar/Bar.java", <<SRC
|
54
|
+
package com.biz.bar;
|
55
|
+
public class Bar {}
|
56
|
+
SRC
|
57
|
+
|
58
|
+
@foo = define "foo" do
|
59
|
+
project.version = "2.1.3"
|
60
|
+
project.group = "mygroup"
|
61
|
+
manifest["Magic-Food"] = "Chocolate"
|
62
|
+
manifest["Magic-Drink"] = "Wine"
|
63
|
+
package(:bundle).tap do |bnd|
|
64
|
+
bnd["Export-Package"] = "com.*"
|
65
|
+
end
|
66
|
+
|
67
|
+
define "bar" do
|
68
|
+
project.version = "2.2"
|
69
|
+
package(:bundle).tap do |bnd|
|
70
|
+
bnd["Magic-Food"] = "Cheese"
|
71
|
+
bnd["Export-Package"] = "com.*"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
task('package').invoke
|
76
|
+
end
|
77
|
+
|
78
|
+
it "version 0.0.384 does not export the version and wrong import-package" do
|
79
|
+
open_main_manifest_section do |attribs|
|
80
|
+
attribs['Bundle-Name'].should eql('foo')
|
81
|
+
attribs['Bundle-Version'].should eql('2.1.3')
|
82
|
+
attribs['Bundle-SymbolicName'].should eql('mygroup.foo')
|
83
|
+
attribs['Export-Package'].should eql('com.biz')
|
84
|
+
attribs['Import-Package'].should eql('com.biz')
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
35
88
|
|
36
89
|
describe "package :bundle" do
|
37
90
|
describe "with a valid bundle" do
|
@@ -92,8 +145,8 @@ SRC
|
|
92
145
|
attribs['Bundle-Name'].should eql('foo')
|
93
146
|
attribs['Bundle-Version'].should eql('2.1.3')
|
94
147
|
attribs['Bundle-SymbolicName'].should eql('mygroup.foo')
|
95
|
-
attribs['Export-Package'].should eql('com.biz')
|
96
|
-
attribs['Import-Package'].should
|
148
|
+
attribs['Export-Package'].should eql('com.biz;version="2.1.3"')
|
149
|
+
attribs['Import-Package'].should be_nil
|
97
150
|
end
|
98
151
|
end
|
99
152
|
|
@@ -123,8 +176,8 @@ SRC
|
|
123
176
|
attribs['Bundle-Name'].should eql('foo:bar')
|
124
177
|
attribs['Bundle-Version'].should eql('2.2')
|
125
178
|
attribs['Bundle-SymbolicName'].should eql('mygroup.foo.bar')
|
126
|
-
attribs['Export-Package'].should eql('com.biz.bar')
|
127
|
-
attribs['Import-Package'].should
|
179
|
+
attribs['Export-Package'].should eql('com.biz.bar;version="2.2"')
|
180
|
+
attribs['Import-Package'].should be_nil
|
128
181
|
end
|
129
182
|
end
|
130
183
|
|
@@ -179,7 +232,7 @@ SRC
|
|
179
232
|
it "should generate package with files exported from dependency" do
|
180
233
|
task('package').invoke
|
181
234
|
open_main_manifest_section do |attribs|
|
182
|
-
attribs['Export-Package'].should eql('org.apache.tools.zip')
|
235
|
+
attribs['Export-Package'].should eql('org.apache.tools.zip;version="2.1.3"')
|
183
236
|
end
|
184
237
|
end
|
185
238
|
end
|
@@ -211,7 +264,7 @@ SRC
|
|
211
264
|
it "should generate package with files exported from dependency" do
|
212
265
|
task('package').invoke
|
213
266
|
open_main_manifest_section do |attribs|
|
214
|
-
attribs['Export-Package'].should eql('org.apache.tools.zip')
|
267
|
+
attribs['Export-Package'].should eql('org.apache.tools.zip;version="2.1.3"')
|
215
268
|
end
|
216
269
|
end
|
217
270
|
end
|
@@ -235,7 +288,7 @@ SRC
|
|
235
288
|
it "should generate package with files exported from dependency" do
|
236
289
|
task('package').invoke
|
237
290
|
open_main_manifest_section do |attribs|
|
238
|
-
attribs['Export-Package'].should eql('org.apache.tools.zip')
|
291
|
+
attribs['Export-Package'].should eql('org.apache.tools.zip;version="2.1.3"')
|
239
292
|
end
|
240
293
|
end
|
241
294
|
end
|
@@ -327,4 +380,5 @@ SRC
|
|
327
380
|
Rake::Task.tasks.detect { |task| task.to_s == "bnd:print" }.comment.should_not be_nil
|
328
381
|
end
|
329
382
|
end
|
383
|
+
|
330
384
|
end
|
@@ -133,7 +133,7 @@ describe Buildr::Application do
|
|
133
133
|
write 'build.yaml', <<-YAML
|
134
134
|
gems:
|
135
135
|
- rake
|
136
|
-
- rspec ~> 2.
|
136
|
+
- rspec ~> 2.9.0
|
137
137
|
YAML
|
138
138
|
Buildr.application.should_receive(:listed_gems).and_return([[Gem.loaded_specs['rspec'],Gem.loaded_specs['rake']],[]])
|
139
139
|
Buildr.application.load_gems
|
data/spec/core/build_spec.rb
CHANGED
@@ -200,6 +200,66 @@ describe Project, '#reports' do
|
|
200
200
|
end
|
201
201
|
|
202
202
|
|
203
|
+
describe Hg do
|
204
|
+
describe '#current_branch' do
|
205
|
+
it 'should return the correct branch' do
|
206
|
+
Hg.should_receive(:hg).with('branch').and_return("default\n")
|
207
|
+
Hg.send(:current_branch).should == 'default'
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
describe '#uncommitted_files' do
|
212
|
+
it 'should return an array of modified files' do
|
213
|
+
Hg.should_receive(:`).with('hg status').and_return <<-EOF
|
214
|
+
M abc.txt
|
215
|
+
M xyz.txt
|
216
|
+
R hello
|
217
|
+
R removed
|
218
|
+
! conflict
|
219
|
+
A README
|
220
|
+
? ignore.txt
|
221
|
+
EOF
|
222
|
+
Hg.uncommitted_files.should include('abc.txt', 'xyz.txt', 'hello', 'README', 'conflict', 'ignore.txt')
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
describe '#uncommitted_files' do
|
227
|
+
it 'should return an empty array on a clean repository' do
|
228
|
+
Hg.should_receive(:`).with('hg status').and_return "\n"
|
229
|
+
Hg.uncommitted_files.should be_empty
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
describe '#remote' do
|
234
|
+
it 'should return the aliases of the default remote repositories' do
|
235
|
+
Hg.should_receive(:hg).with('paths').and_return <<-EOF
|
236
|
+
default = https://hg.apache.org/repo/my-repo
|
237
|
+
EOF
|
238
|
+
Hg.send(:remote).should include('https://hg.apache.org/repo/my-repo')
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'should return the aliases of the default push remote repositories' do
|
242
|
+
Hg.should_receive(:hg).with('paths').and_return <<-EOF
|
243
|
+
default-push = https://hg.apache.org/repo/my-repo
|
244
|
+
EOF
|
245
|
+
Hg.send(:remote).should include('https://hg.apache.org/repo/my-repo')
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'should return empty array when no remote repositories found' do
|
249
|
+
Hg.should_receive(:hg).with('paths').and_return "\n"
|
250
|
+
Hg.send(:remote).should be_empty
|
251
|
+
end
|
252
|
+
|
253
|
+
it 'should return empty array when no default-push remote repository found' do
|
254
|
+
Hg.should_receive(:hg).with('paths').and_return <<-EOF
|
255
|
+
blah = https://bitbucket.org/sample-repo
|
256
|
+
EOF
|
257
|
+
Hg.send(:remote).should be_empty
|
258
|
+
end
|
259
|
+
end
|
260
|
+
end # end of Hg
|
261
|
+
|
262
|
+
|
203
263
|
describe Git do
|
204
264
|
describe '#uncommitted_files' do
|
205
265
|
it 'should return an empty array on a clean repository' do
|
@@ -346,6 +406,11 @@ end # of Buildr::Svn
|
|
346
406
|
|
347
407
|
describe Release do
|
348
408
|
describe 'find' do
|
409
|
+
it 'should return HgRelease if project uses Hg' do
|
410
|
+
write '.hg/requires'
|
411
|
+
Release.find.should be_instance_of(HgRelease)
|
412
|
+
end
|
413
|
+
|
349
414
|
it 'should return GitRelease if project uses Git' do
|
350
415
|
write '.git/config'
|
351
416
|
Release.find.should be_instance_of(GitRelease)
|
@@ -679,6 +744,58 @@ shared_examples_for 'a release process' do
|
|
679
744
|
end
|
680
745
|
|
681
746
|
|
747
|
+
describe HgRelease do
|
748
|
+
it_should_behave_like 'a release process'
|
749
|
+
|
750
|
+
before do
|
751
|
+
write 'buildfile', "VERSION_NUMBER = '1.0.0-SNAPSHOT'"
|
752
|
+
@release = HgRelease.new
|
753
|
+
Hg.stub!(:hg)
|
754
|
+
Hg.stub!(:remote).and_return('https://bitbucket.org/sample-repo')
|
755
|
+
Hg.stub!(:current_branch).and_return('default')
|
756
|
+
end
|
757
|
+
|
758
|
+
describe '#applies_to?' do
|
759
|
+
it 'should reject a non-hg repo' do
|
760
|
+
Dir.chdir(Dir.tmpdir) do
|
761
|
+
HgRelease.applies_to?.should be_false
|
762
|
+
end
|
763
|
+
end
|
764
|
+
|
765
|
+
it 'should accept a hg repo' do
|
766
|
+
FileUtils.mkdir '.hg'
|
767
|
+
FileUtils.touch File.join('.hg', 'requires')
|
768
|
+
HgRelease.applies_to?.should be_true
|
769
|
+
end
|
770
|
+
end
|
771
|
+
|
772
|
+
describe '#check' do
|
773
|
+
before do
|
774
|
+
@release = HgRelease.new
|
775
|
+
@release.send(:this_version=, '1.0.0-SNAPSHOT')
|
776
|
+
end
|
777
|
+
|
778
|
+
it 'should accept a clean repo' do
|
779
|
+
Hg.should_receive(:uncommitted_files).and_return([])
|
780
|
+
Hg.should_receive(:remote).and_return(["http://bitbucket.org/sample-repo"])
|
781
|
+
lambda { @release.check }.should_not raise_error
|
782
|
+
end
|
783
|
+
|
784
|
+
it 'should reject a dirty repo' do
|
785
|
+
Hg.should_receive(:uncommitted_files).and_return(['dirty_file.txt'])
|
786
|
+
lambda { @release.check }.should raise_error(RuntimeError, /uncommitted files/i)
|
787
|
+
end
|
788
|
+
|
789
|
+
it 'should reject a local branch not tracking a remote repo' do
|
790
|
+
Hg.should_receive(:uncommitted_files).and_return([])
|
791
|
+
Hg.should_receive(:remote).and_return([])
|
792
|
+
lambda{ @release.check }.should raise_error(RuntimeError,
|
793
|
+
"You are releasing from a local branch that does not track a remote!")
|
794
|
+
end
|
795
|
+
end
|
796
|
+
end
|
797
|
+
|
798
|
+
|
682
799
|
describe GitRelease do
|
683
800
|
it_should_behave_like 'a release process'
|
684
801
|
|
data/spec/core/cc_spec.rb
CHANGED
@@ -72,7 +72,7 @@ describe Buildr::CCTask do
|
|
72
72
|
foo.cc.invoke
|
73
73
|
end
|
74
74
|
|
75
|
-
|
75
|
+
wait_while { foo.test.compile.run_count != 1 }
|
76
76
|
|
77
77
|
foo.compile.run_count.should == 1
|
78
78
|
foo.test.compile.run_count.should == 1
|
@@ -92,21 +92,19 @@ describe Buildr::CCTask do
|
|
92
92
|
foo.cc.invoke
|
93
93
|
rescue => e
|
94
94
|
p "unexpected exception #{e.inspect}"
|
95
|
-
p e.backtrace.join("\n")
|
95
|
+
p e.backtrace.join("\n")
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
-
|
99
|
+
wait_while { foo.test.compile.run_count != 1 }
|
100
100
|
|
101
101
|
foo.compile.run_count.should == 1
|
102
102
|
foo.test.compile.run_count.should == 1
|
103
103
|
foo.resources.run_count.should == 1
|
104
104
|
|
105
|
-
|
106
|
-
|
107
|
-
touch File.join(Dir.pwd, 'src/main/java/Example.java')
|
105
|
+
modify_file_times(File.join(Dir.pwd, 'src/main/java/Example.java'))
|
108
106
|
|
109
|
-
|
107
|
+
wait_while { foo.test.compile.run_count != 2 }
|
110
108
|
|
111
109
|
foo.compile.run_count.should == 2
|
112
110
|
foo.test.compile.run_count.should == 2
|
@@ -134,17 +132,18 @@ describe Buildr::CCTask do
|
|
134
132
|
end
|
135
133
|
end
|
136
134
|
|
137
|
-
|
135
|
+
wait_while { foo.test.compile.run_count != 1 }
|
138
136
|
|
139
137
|
foo.compile.run_count.should == 1
|
140
138
|
foo.test.compile.run_count.should == 1
|
141
139
|
foo.resources.run_count.should == 1
|
142
140
|
|
143
141
|
file("foo/target/classes/Example.class").should exist
|
142
|
+
|
144
143
|
tstamp = File.mtime("foo/target/classes/Example.class")
|
145
|
-
touch File.join(Dir.pwd, 'foo/src/main/java/Example.java')
|
146
144
|
|
147
|
-
|
145
|
+
modify_file_times(File.join(Dir.pwd, 'foo/src/main/java/Example.java'))
|
146
|
+
wait_while { foo.test.compile.run_count != 2 }
|
148
147
|
|
149
148
|
foo.compile.run_count.should == 2
|
150
149
|
foo.test.compile.run_count.should == 2
|
@@ -154,6 +153,23 @@ describe Buildr::CCTask do
|
|
154
153
|
thread.exit
|
155
154
|
end
|
156
155
|
|
156
|
+
def modify_file_times(filename)
|
157
|
+
# Sleep prior to touch so works with filesystems with low resolutions
|
158
|
+
t1 = File.mtime(filename)
|
159
|
+
while t1 == File.mtime(filename)
|
160
|
+
sleep 1
|
161
|
+
touch filename
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def wait_while(&block)
|
166
|
+
sleep_count = 0
|
167
|
+
while block.call && sleep_count < 15
|
168
|
+
sleep 1
|
169
|
+
sleep_count += 1
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
157
173
|
it 'should support parent and subprojects' do |spec|
|
158
174
|
write 'foo/src/main/java/Example.java', "public class Example {}"
|
159
175
|
write 'foo/src/test/java/ExampleTest.java', "public class ExampleTest {}"
|
@@ -171,6 +187,8 @@ describe Buildr::CCTask do
|
|
171
187
|
define('bar')
|
172
188
|
end
|
173
189
|
|
190
|
+
time = Time.now
|
191
|
+
|
174
192
|
all = projects("container", "container:foo", "container:bar")
|
175
193
|
all.each { |p| instrument_project(p) }
|
176
194
|
|
@@ -183,7 +201,7 @@ describe Buildr::CCTask do
|
|
183
201
|
end
|
184
202
|
end
|
185
203
|
|
186
|
-
|
204
|
+
wait_while { all.any? { |p| p.test.compile.run_count != 1 } }
|
187
205
|
|
188
206
|
all.each do |p|
|
189
207
|
p.compile.run_count.should == 1
|
@@ -194,14 +212,17 @@ describe Buildr::CCTask do
|
|
194
212
|
file("foo/target/classes/Example.class").should exist
|
195
213
|
tstamp = File.mtime("foo/target/classes/Example.class")
|
196
214
|
|
197
|
-
|
198
|
-
|
215
|
+
modify_file_times('foo/src/main/java/Example.java')
|
216
|
+
wait_while { project("container:foo").test.compile.run_count != 2 }
|
199
217
|
|
200
218
|
project("container:foo").tap do |p|
|
201
219
|
p.compile.run_count.should == 2
|
202
220
|
p.test.compile.run_count.should == 2
|
203
221
|
p.resources.run_count.should == 2
|
204
222
|
end
|
223
|
+
|
224
|
+
wait_while { project("container").resources.run_count != 2 }
|
225
|
+
|
205
226
|
project("container").tap do |p|
|
206
227
|
p.compile.run_count.should == 1 # not_needed
|
207
228
|
p.test.compile.run_count.should == 1 # not_needed
|
@@ -209,8 +230,9 @@ describe Buildr::CCTask do
|
|
209
230
|
end
|
210
231
|
File.mtime("foo/target/classes/Example.class").should_not == tstamp
|
211
232
|
|
212
|
-
|
213
|
-
|
233
|
+
modify_file_times('src/main/java/Example.java')
|
234
|
+
|
235
|
+
wait_while { project("container").resources.run_count != 3 }
|
214
236
|
|
215
237
|
project("container").tap do |p|
|
216
238
|
p.compile.run_count.should == 2
|