buildrizpack 0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,92 @@
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
+ begin
17
+ require 'rspec/core/rake_task'
18
+ directory '_reports'
19
+
20
+ def default_spec_opts
21
+ default = %w{--format documentation --out _reports/specs.txt --backtrace}
22
+ default << '--colour' if $stdout.isatty && !(Config::CONFIG['host_os'] =~ /mswin|win32|dos/i)
23
+ default
24
+ end
25
+
26
+ # RSpec doesn't support file exclusion, so hack our own.
27
+ class RSpec::Core::RakeTask
28
+ attr_accessor :rspec_files
29
+ private
30
+ def files_to_run
31
+ @rspec_files
32
+ end
33
+ end
34
+
35
+ desc "Run all specs"
36
+ RSpec::Core::RakeTask.new :spec=>['_reports'] do |task|
37
+ ENV['USE_FSC'] = 'no'
38
+ task.rspec_files = FileList['spec/**/*_spec.rb']
39
+ task.rspec_files.exclude('spec/groovy/*') if RUBY_PLATFORM[/java/]
40
+ task.rspec_opts = default_spec_opts
41
+ task.rspec_opts = %w{--format html --out _reports/specs.html --backtrace}
42
+ end
43
+ file('_reports/specs.html') { task(:spec).invoke }
44
+
45
+ desc 'Run RSpec and generate Spec and coverage reports (slow)'
46
+ RSpec::Core::RakeTask.new :coverage=>['_reports'] do |task|
47
+ ENV['USE_FSC'] = 'no'
48
+ task.rspec_files = FileList['spec/**/*_spec.rb']
49
+ task.rspec_files.exclude('spec/groovy/*') if RUBY_PLATFORM[/java/]
50
+ task.rspec_opts = default_spec_opts
51
+ task.rcov = true
52
+ task.rcov_opts = %w{-o _reports/coverage --exclude / --include-file ^lib --text-summary}
53
+ end
54
+ file('_reports/coverage') { task(:coverage).invoke }
55
+
56
+ task :load_ci_reporter do
57
+ gem 'ci_reporter'
58
+ ENV['CI_REPORTS'] = '_reports/ci'
59
+ # CI_Reporter does not quote the path to rspec_loader which causes problems when ruby is installed in C:/Program Files.
60
+ # However, newer versions of rspec don't like double quotes escaping as well, so removing them for now.
61
+ ci_rep_path = Gem.loaded_specs['ci_reporter'].full_gem_path
62
+ ENV["SPEC_OPTS"] = [ENV["SPEC_OPTS"], default_spec_opts, "--require", "#{ci_rep_path}/lib/ci/reporter/rake/rspec_loader.rb", "--format", "CI::Reporter::RSpec"].join(" ")
63
+ end
64
+
65
+ desc 'Run all specs with CI reporter'
66
+ task :ci=>[:load_ci_reporter, :spec]
67
+
68
+ # Useful for testing with JRuby when using Ruby and vice versa.
69
+ namespace :spec do
70
+ desc "Run all specs specifically with Ruby"
71
+ task :ruby do
72
+ puts "Running test suite using Ruby ..."
73
+ sh 'ruby -S rake spec'
74
+ end
75
+
76
+ desc "Run all specs specifically with JRuby"
77
+ task :jruby do
78
+ puts "Running test suite using JRuby ..."
79
+ sh 'jruby -S rake spec'
80
+ end
81
+ end
82
+
83
+ task :clobber do
84
+ rm_f 'failed'
85
+ rm_rf '_reports'
86
+ end
87
+
88
+ rescue LoadError => e
89
+ puts "Buildr uses RSpec. You can install it by running rake setup"
90
+ task(:setup) { install_gem 'rcov', :version=>'~>0.8' }
91
+ task(:setup) { install_gem 'win32console' if RUBY_PLATFORM[/win32/] } # Colors for RSpec, only on Windows platform.
92
+ end
@@ -0,0 +1,92 @@
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
+ begin
17
+ require 'rspec/core/rake_task'
18
+ directory '_reports'
19
+
20
+ def default_spec_opts
21
+ default = %w{--format documentation --out _reports/specs.txt --backtrace}
22
+ default << '--colour' if $stdout.isatty && !(Config::CONFIG['host_os'] =~ /mswin|win32|dos/i)
23
+ default
24
+ end
25
+
26
+ # RSpec doesn't support file exclusion, so hack our own.
27
+ class RSpec::Core::RakeTask
28
+ attr_accessor :rspec_files
29
+ private
30
+ def files_to_run
31
+ @rspec_files
32
+ end
33
+ end
34
+
35
+ desc "Run all specs"
36
+ RSpec::Core::RakeTask.new :spec=>['_reports', :compile] do |task|
37
+ ENV['USE_FSC'] = 'no'
38
+ task.rspec_files = FileList['spec/**/*_spec.rb']
39
+ task.rspec_files.exclude('spec/groovy/*') if RUBY_PLATFORM[/java/]
40
+ task.rspec_opts = default_spec_opts
41
+ task.rspec_opts = %w{--format html --out _reports/specs.html --backtrace}
42
+ end
43
+ file('_reports/specs.html') { task(:spec).invoke }
44
+
45
+ desc 'Run RSpec and generate Spec and coverage reports (slow)'
46
+ RSpec::Core::RakeTask.new :coverage=>['_reports'] do |task|
47
+ ENV['USE_FSC'] = 'no'
48
+ task.rspec_files = FileList['spec/**/*_spec.rb']
49
+ task.rspec_files.exclude('spec/groovy/*') if RUBY_PLATFORM[/java/]
50
+ task.rspec_opts = default_spec_opts
51
+ task.rcov = true
52
+ task.rcov_opts = %w{-o _reports/coverage --exclude / --include-file ^lib --text-summary}
53
+ end
54
+ file('_reports/coverage') { task(:coverage).invoke }
55
+
56
+ task :load_ci_reporter do
57
+ gem 'ci_reporter'
58
+ ENV['CI_REPORTS'] = '_reports/ci'
59
+ # CI_Reporter does not quote the path to rspec_loader which causes problems when ruby is installed in C:/Program Files.
60
+ # However, newer versions of rspec don't like double quotes escaping as well, so removing them for now.
61
+ ci_rep_path = Gem.loaded_specs['ci_reporter'].full_gem_path
62
+ ENV["SPEC_OPTS"] = [ENV["SPEC_OPTS"], default_spec_opts, "--require", "#{ci_rep_path}/lib/ci/reporter/rake/rspec_loader.rb", "--format", "CI::Reporter::RSpec"].join(" ")
63
+ end
64
+
65
+ desc 'Run all specs with CI reporter'
66
+ task :ci=>[:load_ci_reporter, :spec]
67
+
68
+ # Useful for testing with JRuby when using Ruby and vice versa.
69
+ namespace :spec do
70
+ desc "Run all specs specifically with Ruby"
71
+ task :ruby do
72
+ puts "Running test suite using Ruby ..."
73
+ sh 'ruby -S rake spec'
74
+ end
75
+
76
+ desc "Run all specs specifically with JRuby"
77
+ task :jruby do
78
+ puts "Running test suite using JRuby ..."
79
+ sh 'jruby -S rake spec'
80
+ end
81
+ end
82
+
83
+ task :clobber do
84
+ rm_f 'failed'
85
+ rm_rf '_reports'
86
+ end
87
+
88
+ rescue LoadError => e
89
+ puts "Buildr uses RSpec. You can install it by running rake setup"
90
+ task(:setup) { install_gem 'rcov', :version=>'~>0.8' }
91
+ task(:setup) { install_gem 'win32console' if RUBY_PLATFORM[/win32/] } # Colors for RSpec, only on Windows platform.
92
+ end
@@ -0,0 +1,217 @@
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 'rubyforge'
17
+ require 'digest/md5'
18
+ require 'digest/sha1'
19
+
20
+ gpg_cmd = 'gpg2'
21
+
22
+ task :prepare do |task, args|
23
+ gpg_arg = args.gpg || ENV['gpg']
24
+
25
+ # Make sure we're doing a release from checked code.
26
+ lambda do
27
+ puts "Checking there are no local changes ... "
28
+ svn = `svn status`
29
+ fail "Cannot release unless all local changes are in SVN:\n#{svn}" unless svn.empty?
30
+ git = `git status -s`
31
+ fail "Cannot release unless all local changes are in Git:\n#{git}" if git[/^ M/] && ENV["IGNORE_GIT"].nil?
32
+ puts "[X] There are no local changes, everything is in source control"
33
+ end.call
34
+
35
+ # Make sure we have a valid CHANGELOG entry for this release.
36
+ lambda do
37
+ puts "Checking that CHANGELOG indicates most recent version and today's date ... "
38
+ expecting = "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})"
39
+ header = File.readlines('CHANGELOG').first.chomp
40
+ fail "Expecting CHANGELOG to start with #{expecting}, but found #{header} instead" unless expecting == header
41
+ puts "[x] CHANGELOG indicates most recent version and today's date"
42
+ end.call
43
+
44
+ # Need GPG to sign the packages.
45
+ lambda do
46
+ gpg_arg or fail "Please run with gpg=<argument for gpg --local-user>"
47
+ gpg_ok = `gpg2 --list-keys #{gpg_arg}` rescue nil
48
+ if !$?.success?
49
+ gpg_ok = `gpg --list-keys #{gpg_arg}`
50
+ gpg_cmd = 'gpg'
51
+ end
52
+ fail "No GPG user #{gpg_arg}" if gpg_ok.empty?
53
+ end.call
54
+
55
+ task(:license).invoke
56
+
57
+ # Need JRuby, Scala and Groovy installed to run all the specs.
58
+ lambda do
59
+ puts "Checking that we have JRuby, Scala and Groovy available ... "
60
+ sh 'jruby --version'
61
+ `scala -version`
62
+ $?.exitstatus == 1 or fail "Scala is not installed"
63
+ sh 'groovy -version'
64
+ puts "[X] We have JRuby, Scala and Groovy"
65
+ end.call
66
+
67
+ # Need Prince to generate PDF
68
+ lambda do
69
+ puts "Checking that we have prince available ... "
70
+ sh 'prince --version'
71
+ puts "[X] We have prince available"
72
+ end.call
73
+
74
+ # Need RubyForge to upload new release files.
75
+ lambda do
76
+ puts "[!] Make sure you have admin privileges to make a release on RubyForge"
77
+ rubyforge = RubyForge.new.configure
78
+ rubyforge.login
79
+ rubyforge.scrape_project(spec.name)
80
+ end.call
81
+
82
+ # We will be speccing in one platform, so also spec the other one.
83
+ task(RUBY_PLATFORM =~ /java/ ? 'spec:ruby' : 'spec:jruby').invoke # Test the *other* platform
84
+ end
85
+
86
+
87
+ task :stage=>[:clobber, :prepare] do |task, args|
88
+ gpg_arg = args.gpg || ENV['gpg']
89
+ mkpath '_staged'
90
+
91
+ # Start by figuring out what has changed.
92
+ lambda do
93
+ puts "Looking for changes between this release and previous one ..."
94
+ pattern = /(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/
95
+ changes = File.read('CHANGELOG').scan(pattern).inject({}) { |hash, set| hash[set[1]] = set[2] ; hash }
96
+ current = changes[spec.version.to_s]
97
+ fail "No changeset found for version #{spec.version}" unless current
98
+ File.open '_staged/CHANGES', 'w' do |file|
99
+ file.write "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})\n"
100
+ file.write current
101
+ end
102
+ puts "[X] Listed most recent changed in _staged/CHANGES"
103
+ end.call
104
+
105
+ # Create the packages (gem, tarball) and sign them. This requires user
106
+ # intervention so the earlier we do it the better.
107
+ lambda do
108
+ puts "Creating and signing release packages ..."
109
+ task(:package).invoke
110
+ mkpath '_staged/dist'
111
+ FileList['pkg/*.{gem,zip,tgz}'].each do |source|
112
+ pkg = source.pathmap('_staged/dist/%n%x')
113
+ cp source, pkg
114
+ bytes = File.open(pkg, 'rb') { |file| file.read }
115
+ File.open(pkg + '.md5', 'w') { |file| file.write Digest::MD5.hexdigest(bytes) << ' ' << File.basename(pkg) }
116
+ File.open(pkg + '.sha1', 'w') { |file| file.write Digest::SHA1.hexdigest(bytes) << ' ' << File.basename(pkg) }
117
+ sh gpg_cmd, '--local-user', gpg_arg, '--armor', '--output', pkg + '.asc', '--detach-sig', pkg, :verbose=>true
118
+ end
119
+ cp 'etc/KEYS', '_staged/dist'
120
+ puts "[X] Created and signed release packages in _staged/dist"
121
+ end.call
122
+
123
+ # The download page should link to the new binaries/sources, and we
124
+ # want to do that before generating the site/documentation.
125
+ lambda do
126
+ puts "Updating download page with links to release packages ... "
127
+ mirror = "http://www.apache.org/dyn/closer.cgi/#{spec.name}/#{spec.version}"
128
+ official = "http://www.apache.org/dist/#{spec.name}/#{spec.version}"
129
+ rows = FileList['_staged/dist/*.{gem,tgz,zip}'].map { |pkg|
130
+ name, md5 = File.basename(pkg), Digest::MD5.file(pkg).to_s
131
+ %{| "#{name}":#{mirror}/#{name} | "#{md5}":#{official}/#{name}.md5 | "Sig":#{official}/#{name}.asc |}
132
+ }
133
+ textile = <<-TEXTILE
134
+ h3. #{spec.name} #{spec.version} (#{Time.now.strftime('%Y-%m-%d')})
135
+
136
+ |_. Package |_. MD5 Checksum |_. PGP |
137
+ #{rows.join("\n")}
138
+
139
+ p>. ("Release signing keys":#{official}/KEYS)
140
+ TEXTILE
141
+ file_name = 'doc/download.textile'
142
+ print "Adding download links to #{file_name} ... "
143
+ modified = File.read(file_name).sub(/^h2\(#dist\).*$/) { |header| "#{header}\n\n#{textile}" }
144
+ File.open file_name, 'w' do |file|
145
+ file.write modified
146
+ end
147
+ puts "[X] Updated #{file_name}"
148
+ end.call
149
+
150
+
151
+ # Now we can create the Web site, this includes running specs, coverage report, etc.
152
+ # This will take a while, so we want to do it as last step before upload.
153
+ lambda do
154
+ puts "Creating new Web site"
155
+ task(:site).invoke
156
+ cp_r '_site', '_staged/site'
157
+ puts "[X] Created new Web site in _staged/site"
158
+ end.call
159
+
160
+
161
+ # Move everything over to people.apache.org so we can vote on it.
162
+ lambda do
163
+ url = "people.apache.org:~/public_html/#{spec.name}/#{spec.version}"
164
+ puts "Uploading _staged directory to #{url} ..."
165
+ sh 'rsync', '--progress', '--recursive', '_staged/', url
166
+ puts "[X] Uploaded _staged directory to #{url}"
167
+ end.call
168
+
169
+
170
+ # Prepare a release vote email. In the distant future this will also send the
171
+ # email for you and vote on it.
172
+ lambda do
173
+ # Need to know who you are on Apache, local user may be different (see .ssh/config).
174
+ whoami = `ssh people.apache.org whoami`.strip
175
+ base_url = "http://people.apache.org/~#{whoami}/buildr/#{spec.version}"
176
+ # Need changes for this release only.
177
+ changelog = File.read('CHANGELOG').scan(/(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/)
178
+ changes = changelog[0][2]
179
+ previous_version = changelog[1][1]
180
+
181
+ email = <<-EMAIL
182
+ To: dev@buildr.apache.org
183
+ Subject: [VOTE] Buildr #{spec.version} release
184
+
185
+ We're voting on the source distributions available here:
186
+ #{base_url}/dist/
187
+
188
+ Specifically:
189
+ #{base_url}/dist/buildr-#{spec.version}.tgz
190
+ #{base_url}/dist/buildr-#{spec.version}.zip
191
+
192
+ The documentation generated for this release is available here:
193
+ #{base_url}/site/
194
+ #{base_url}/site/buildr.pdf
195
+
196
+ The official specification against which this release was tested:
197
+ #{base_url}/site/specs.html
198
+
199
+ Test coverage report:
200
+ #{base_url}/site/coverage/index.html
201
+
202
+
203
+ The following changes were made since #{previous_version}:
204
+
205
+ #{changes.gsub(/^/, ' ')}
206
+ EMAIL
207
+ File.open 'vote-email.txt', 'w' do |file|
208
+ file.write email
209
+ end
210
+ puts "[X] Created release vote email template in 'vote-email.txt'"
211
+ puts email
212
+ end.call
213
+
214
+ end
215
+
216
+
217
+ task(:clobber) { rm_rf '_staged' }
@@ -0,0 +1,7 @@
1
+ require 'buildrizpack'
2
+ Buildr::write "myProject/src/main/java/Hello.java", "public class Hello {}"
3
+ define 'myProject' do
4
+ package(:jar)
5
+ package(:izpack).locales = ['eng', 'fra', 'deu']
6
+ package(:izpack).include(package(:jar))
7
+ end
@@ -0,0 +1,8 @@
1
+ require 'buildrizpack'
2
+ define 'myProject' do
3
+ package(:jar)
4
+ # It is you responsability to specify correctly all dependencies!!
5
+ package(:izpack).input = path_to(:sources, :main, :ressources, 'myInstaller.xml')
6
+ package(:izpack)
7
+ end
8
+
@@ -0,0 +1,18 @@
1
+ require 'buildrizpack'
2
+ Buildr::write "example_3/src/main/java/Hello.java", "public class Hello {}"
3
+ define 'example_3' do
4
+ package(:jar)
5
+ package(:izpack).locales = ['eng', 'fra', 'deu']
6
+ Buildr.write(path_to(:target)+"/1_5.txt", "This is file 1_5.txt")
7
+ Buildr.write(path_to(:target)+"/3_7.txt", "This is file 3_7.txt")
8
+ s = ''
9
+ xm = Builder::XmlMarkup.new(:target=>s)
10
+ xm.packs {
11
+ xm.pack('name' => 'pack_3', 'required' => 'yes') {
12
+ xm.description("Niklau is testing")
13
+ xm.file('src'=> path_to(:target)+"/1_5.txt", 'targetdir' =>'1.5')
14
+ xm.file('src'=> path_to(:target)+"/3_7.txt", 'targetdir' =>'3.7')
15
+ }
16
+ }
17
+ package(:izpack).packs = s
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'buildrizpack'
2
+ Buildr::write "example_1/src/main/java/Hello.java", "public class Hello {}"
3
+ define 'example_1', :version => '0.9.8' do
4
+ package(:jar)
5
+ package(:izpack).locales = ['eng', 'fra', 'deu']
6
+ package(:izpack).include(package(:jar))
7
+ end