capistrano-maven 0.0.7 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +17 -18
- data/capistrano-maven.gemspec +6 -2
- data/lib/capistrano-maven.rb +259 -197
- data/lib/capistrano-maven/version.rb +1 -1
- data/test/centos6-64/.gitignore +5 -0
- data/test/centos6-64/Capfile +2 -0
- data/test/centos6-64/Gemfile +2 -0
- data/test/centos6-64/Vagrantfile +99 -0
- data/test/centos6-64/run.sh +7 -0
- data/test/config/deploy.rb +361 -0
- data/{lib/templates/settings.xml → test/config/templates/settings.xml.erb} +0 -0
- data/test/precise64/.gitignore +5 -0
- data/test/precise64/Capfile +2 -0
- data/test/precise64/Gemfile +2 -0
- data/test/precise64/Vagrantfile +99 -0
- data/test/precise64/run.sh +7 -0
- data/test/project/.gitignore +3 -0
- data/test/project/pom.xml +7 -0
- data/test/project/release.xml +7 -0
- data/test/project/snapshot.xml +7 -0
- data/test/project/src/main/java/com/github/yyuu/Main.java +7 -0
- metadata +105 -8
@@ -0,0 +1,99 @@
|
|
1
|
+
# -*- mode: ruby -*-
|
2
|
+
# vi: set ft=ruby :
|
3
|
+
|
4
|
+
Vagrant::Config.run do |config|
|
5
|
+
# All Vagrant configuration is done here. The most common configuration
|
6
|
+
# options are documented and commented below. For a complete reference,
|
7
|
+
# please see the online documentation at vagrantup.com.
|
8
|
+
|
9
|
+
# Every Vagrant virtual environment requires a box to build off of.
|
10
|
+
config.vm.box = "centos6-64"
|
11
|
+
|
12
|
+
# The url from where the 'config.vm.box' box will be fetched if it
|
13
|
+
# doesn't already exist on the user's system.
|
14
|
+
config.vm.box_url = "http://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.3-x86_64-v20130101.box"
|
15
|
+
|
16
|
+
# Boot with a GUI so you can see the screen. (Default is headless)
|
17
|
+
# config.vm.boot_mode = :gui
|
18
|
+
|
19
|
+
# Assign this VM to a host-only network IP, allowing you to access it
|
20
|
+
# via the IP. Host-only networks can talk to the host machine as well as
|
21
|
+
# any other machines on the same network, but cannot be accessed (through this
|
22
|
+
# network interface) by any external networks.
|
23
|
+
config.vm.network :hostonly, "192.168.33.10"
|
24
|
+
|
25
|
+
# Assign this VM to a bridged network, allowing you to connect directly to a
|
26
|
+
# network using the host's network device. This makes the VM appear as another
|
27
|
+
# physical device on your network.
|
28
|
+
# config.vm.network :bridged
|
29
|
+
|
30
|
+
# Forward a port from the guest to the host, which allows for outside
|
31
|
+
# computers to access the VM, whereas host only networking does not.
|
32
|
+
# config.vm.forward_port 80, 8080
|
33
|
+
|
34
|
+
# Share an additional folder to the guest VM. The first argument is
|
35
|
+
# an identifier, the second is the path on the guest to mount the
|
36
|
+
# folder, and the third is the path on the host to the actual folder.
|
37
|
+
# config.vm.share_folder "v-data", "/vagrant_data", "../data"
|
38
|
+
|
39
|
+
# Enable provisioning with Puppet stand alone. Puppet manifests
|
40
|
+
# are contained in a directory path relative to this Vagrantfile.
|
41
|
+
# You will need to create the manifests directory and a manifest in
|
42
|
+
# the file precise-amd64.pp in the manifests_path directory.
|
43
|
+
#
|
44
|
+
# An example Puppet manifest to provision the message of the day:
|
45
|
+
#
|
46
|
+
# # group { "puppet":
|
47
|
+
# # ensure => "present",
|
48
|
+
# # }
|
49
|
+
# #
|
50
|
+
# # File { owner => 0, group => 0, mode => 0644 }
|
51
|
+
# #
|
52
|
+
# # file { '/etc/motd':
|
53
|
+
# # content => "Welcome to your Vagrant-built virtual machine!
|
54
|
+
# # Managed by Puppet.\n"
|
55
|
+
# # }
|
56
|
+
#
|
57
|
+
# config.vm.provision :puppet do |puppet|
|
58
|
+
# puppet.manifests_path = "manifests"
|
59
|
+
# puppet.manifest_file = "precise-amd64.pp"
|
60
|
+
# end
|
61
|
+
|
62
|
+
# Enable provisioning with chef solo, specifying a cookbooks path, roles
|
63
|
+
# path, and data_bags path (all relative to this Vagrantfile), and adding
|
64
|
+
# some recipes and/or roles.
|
65
|
+
#
|
66
|
+
# config.vm.provision :chef_solo do |chef|
|
67
|
+
# chef.cookbooks_path = "../my-recipes/cookbooks"
|
68
|
+
# chef.roles_path = "../my-recipes/roles"
|
69
|
+
# chef.data_bags_path = "../my-recipes/data_bags"
|
70
|
+
# chef.add_recipe "mysql"
|
71
|
+
# chef.add_role "web"
|
72
|
+
#
|
73
|
+
# # You may also specify custom JSON attributes:
|
74
|
+
# chef.json = { :mysql_password => "foo" }
|
75
|
+
# end
|
76
|
+
|
77
|
+
# Enable provisioning with chef server, specifying the chef server URL,
|
78
|
+
# and the path to the validation key (relative to this Vagrantfile).
|
79
|
+
#
|
80
|
+
# The Opscode Platform uses HTTPS. Substitute your organization for
|
81
|
+
# ORGNAME in the URL and validation key.
|
82
|
+
#
|
83
|
+
# If you have your own Chef Server, use the appropriate URL, which may be
|
84
|
+
# HTTP instead of HTTPS depending on your configuration. Also change the
|
85
|
+
# validation key to validation.pem.
|
86
|
+
#
|
87
|
+
# config.vm.provision :chef_client do |chef|
|
88
|
+
# chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
|
89
|
+
# chef.validation_key_path = "ORGNAME-validator.pem"
|
90
|
+
# end
|
91
|
+
#
|
92
|
+
# If you're using the Opscode platform, your validator client is
|
93
|
+
# ORGNAME-validator, replacing ORGNAME with your organization name.
|
94
|
+
#
|
95
|
+
# IF you have your own Chef Server, the default validation client name is
|
96
|
+
# chef-validator, unless you changed the configuration.
|
97
|
+
#
|
98
|
+
# chef.validation_client_name = "ORGNAME-validator"
|
99
|
+
end
|
@@ -0,0 +1,361 @@
|
|
1
|
+
set :application, "capistrano-maven"
|
2
|
+
set :repository, File.expand_path("../project", File.dirname(__FILE__))
|
3
|
+
set :deploy_to do
|
4
|
+
File.join("/home", user, application)
|
5
|
+
end
|
6
|
+
set :deploy_via, :copy
|
7
|
+
set :scm, :none
|
8
|
+
set :use_sudo, false
|
9
|
+
set :user, "vagrant"
|
10
|
+
set :password, "vagrant"
|
11
|
+
set :ssh_options, {:user_known_hosts_file => "/dev/null"}
|
12
|
+
|
13
|
+
## java ##
|
14
|
+
require "capistrano-jdk-installer"
|
15
|
+
set(:java_version_name, "7u15")
|
16
|
+
set(:java_oracle_username) { ENV["JAVA_ORACLE_USERNAME"] || abort("java_oracle_username was not set") }
|
17
|
+
set(:java_oracle_password) { ENV["JAVA_ORACLE_PASSWORD"] || abort("java_oracle_password was not set") }
|
18
|
+
set(:java_tools_path_local) { File.expand_path("tmp/java") }
|
19
|
+
set(:java_accept_license, true)
|
20
|
+
set(:java_license_title, "Oracle Binary Code License Agreement for Java SE")
|
21
|
+
set(:java_setup_remotely, true)
|
22
|
+
set(:java_setup_locally, true)
|
23
|
+
|
24
|
+
## mvn ##
|
25
|
+
set(:mvn_tools_path_local, File.expand_path("tmp/mvn"))
|
26
|
+
set(:mvn_project_path) { release_path }
|
27
|
+
set(:mvn_project_path_local, repository)
|
28
|
+
|
29
|
+
role :web, "192.168.33.10"
|
30
|
+
role :app, "192.168.33.10"
|
31
|
+
role :db, "192.168.33.10", :primary => true
|
32
|
+
|
33
|
+
$LOAD_PATH.push(File.expand_path("../../lib", File.dirname(__FILE__)))
|
34
|
+
require "capistrano-maven"
|
35
|
+
|
36
|
+
def _invoke_command(cmdline, options={})
|
37
|
+
if options[:via] == :run_locally
|
38
|
+
run_locally(cmdline)
|
39
|
+
else
|
40
|
+
invoke_command(cmdline, options)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def assert_file_exists(file, options={})
|
45
|
+
begin
|
46
|
+
_invoke_command("test -f #{file.dump}", options)
|
47
|
+
rescue
|
48
|
+
logger.debug("assert_file_exists(#{file}) failed.")
|
49
|
+
_invoke_command("ls #{File.dirname(file).dump}", options)
|
50
|
+
raise
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def assert_file_not_exists(file, options={})
|
55
|
+
begin
|
56
|
+
_invoke_command("test \! -f #{file.dump}", options)
|
57
|
+
rescue
|
58
|
+
logger.debug("assert_file_not_exists(#{file}) failed.")
|
59
|
+
_invoke_command("ls #{File.dirname(file).dump}", options)
|
60
|
+
raise
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def assert_command(cmdline, options={})
|
65
|
+
begin
|
66
|
+
_invoke_command(cmdline, options)
|
67
|
+
rescue
|
68
|
+
logger.debug("assert_command(#{cmdline}) failed.")
|
69
|
+
raise
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def assert_command_fails(cmdline, options={})
|
74
|
+
failed = false
|
75
|
+
begin
|
76
|
+
_invoke_command(cmdline, options)
|
77
|
+
rescue
|
78
|
+
logger.debug("assert_command_fails(#{cmdline}) failed.")
|
79
|
+
failed = true
|
80
|
+
ensure
|
81
|
+
abort unless failed
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def reset_mvn!
|
86
|
+
variables.each_key do |key|
|
87
|
+
reset!(key) if /^mvn_/ =~ key
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def uninstall_mvn!
|
92
|
+
run("rm -rf #{mvn_path.dump}")
|
93
|
+
run("rm -f #{mvn_archive_file.dump}")
|
94
|
+
run_locally("rm -rf #{mvn_path_local.dump}")
|
95
|
+
run("rm -f #{mvn_settings.map { |x| File.join(mvn_settings_path, x).dump }.join(" ")}") unless mvn_settings.empty?
|
96
|
+
run_locally("rm -f #{mvn_settings_local.map { |x| File.join(mvn_settings_path_local, x).dump }.join(" ")}") unless mvn_settings_local.empty?
|
97
|
+
run("rm -rf #{mvn_target_path.dump}")
|
98
|
+
run_locally("rm -rf #{mvn_target_path_local.dump}")
|
99
|
+
reset_mvn!
|
100
|
+
end
|
101
|
+
|
102
|
+
task(:test_all) {
|
103
|
+
find_and_execute_task("test_default")
|
104
|
+
find_and_execute_task("test_with_remote")
|
105
|
+
find_and_execute_task("test_with_local")
|
106
|
+
find_and_execute_task("test_with_release_build")
|
107
|
+
}
|
108
|
+
|
109
|
+
on(:start) {
|
110
|
+
run("rm -rf #{deploy_to.dump}")
|
111
|
+
}
|
112
|
+
|
113
|
+
namespace(:test_default) {
|
114
|
+
task(:default) {
|
115
|
+
methods.grep(/^test_/).each do |m|
|
116
|
+
send(m)
|
117
|
+
end
|
118
|
+
}
|
119
|
+
before "test_default", "test_default:setup"
|
120
|
+
after "test_default", "test_default:teardown"
|
121
|
+
|
122
|
+
task(:setup) {
|
123
|
+
uninstall_mvn!
|
124
|
+
set(:mvn_version, "3.0.5")
|
125
|
+
set(:mvn_skip_tests, true)
|
126
|
+
set(:mvn_setup_remotely, true)
|
127
|
+
set(:mvn_setup_locally, true)
|
128
|
+
set(:mvn_update_remotely, true)
|
129
|
+
set(:mvn_update_locally, true)
|
130
|
+
set(:mvn_template_path, File.join(File.dirname(__FILE__), "templates"))
|
131
|
+
set(:mvn_settings, %w(settings.xml))
|
132
|
+
set(:mvn_release_build, false)
|
133
|
+
find_and_execute_task("mvn:setup_default_environment")
|
134
|
+
find_and_execute_task("deploy:setup")
|
135
|
+
find_and_execute_task("deploy")
|
136
|
+
}
|
137
|
+
|
138
|
+
task(:teardown) {
|
139
|
+
uninstall_mvn!
|
140
|
+
}
|
141
|
+
|
142
|
+
task(:test_run_mvn) {
|
143
|
+
assert_file_exists(mvn_bin)
|
144
|
+
assert_file_exists(File.join(mvn_settings_path, "settings.xml"))
|
145
|
+
assert_command("#{mvn_cmd} --version")
|
146
|
+
}
|
147
|
+
|
148
|
+
task(:test_run_mvn_via_sudo) {
|
149
|
+
assert_command("#{mvn_cmd} --version", :via => :sudo)
|
150
|
+
}
|
151
|
+
|
152
|
+
task(:test_run_mvn_without_path) {
|
153
|
+
assert_command("mvn --version")
|
154
|
+
}
|
155
|
+
|
156
|
+
task(:test_run_mvn_via_run_locally) {
|
157
|
+
assert_file_exists(mvn_bin_local, :via => :run_locally)
|
158
|
+
assert_file_exists(File.join(mvn_settings_path_local, "settings.xml"), :via => :run_locally)
|
159
|
+
assert_command("#{mvn_cmd_local} --version", :via => :run_locally)
|
160
|
+
}
|
161
|
+
|
162
|
+
task(:test_mvn_exec) {
|
163
|
+
mvn.exec("--version")
|
164
|
+
}
|
165
|
+
|
166
|
+
task(:test_mvn_exec_locally) {
|
167
|
+
mvn.exec_locally("--version")
|
168
|
+
}
|
169
|
+
|
170
|
+
task(:test_mvn_artifact) {
|
171
|
+
assert_file_exists(File.join(mvn_target_path, "capistrano-maven-0.0.1-SNAPSHOT.jar"))
|
172
|
+
}
|
173
|
+
|
174
|
+
task(:test_mvn_artifact_locally) {
|
175
|
+
assert_file_exists(File.join(mvn_target_path_local, "capistrano-maven-0.0.1-SNAPSHOT.jar"), :via => :run_locally)
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
namespace(:test_with_remote) {
|
180
|
+
task(:default) {
|
181
|
+
methods.grep(/^test_/).each do |m|
|
182
|
+
send(m)
|
183
|
+
end
|
184
|
+
}
|
185
|
+
before "test_with_remote", "test_with_remote:setup"
|
186
|
+
after "test_with_remote", "test_with_remote:teardown"
|
187
|
+
|
188
|
+
task(:setup) {
|
189
|
+
uninstall_mvn!
|
190
|
+
set(:mvn_version, "3.0.5")
|
191
|
+
set(:mvn_skip_tests, true)
|
192
|
+
set(:mvn_setup_remotely, true)
|
193
|
+
set(:mvn_setup_locally, false)
|
194
|
+
set(:mvn_update_remotely, true)
|
195
|
+
set(:mvn_update_locally, false)
|
196
|
+
set(:mvn_template_path, File.join(File.dirname(__FILE__), "templates"))
|
197
|
+
set(:mvn_settings, %w(settings.xml))
|
198
|
+
set(:mvn_release_build, false)
|
199
|
+
find_and_execute_task("mvn:setup_default_environment")
|
200
|
+
find_and_execute_task("deploy:setup")
|
201
|
+
find_and_execute_task("deploy")
|
202
|
+
}
|
203
|
+
|
204
|
+
task(:teardown) {
|
205
|
+
uninstall_mvn!
|
206
|
+
}
|
207
|
+
|
208
|
+
task(:test_run_mvn) {
|
209
|
+
assert_file_exists(mvn_bin)
|
210
|
+
assert_file_exists(File.join(mvn_settings_path, "settings.xml"))
|
211
|
+
assert_command("#{mvn_cmd} --version")
|
212
|
+
}
|
213
|
+
|
214
|
+
task(:test_run_mvn_via_sudo) {
|
215
|
+
assert_command("#{mvn_cmd} --version", :via => :sudo)
|
216
|
+
}
|
217
|
+
|
218
|
+
task(:test_run_mvn_without_path) {
|
219
|
+
assert_command("mvn --version")
|
220
|
+
}
|
221
|
+
|
222
|
+
task(:test_run_mvn_via_run_locally) {
|
223
|
+
assert_file_not_exists(mvn_bin_local, :via => :run_locally)
|
224
|
+
assert_file_not_exists(File.join(mvn_settings_path_local, "settings.xml"), :via => :run_locally)
|
225
|
+
assert_command_fails("#{mvn_cmd_local} --version", :via => :run_locally)
|
226
|
+
}
|
227
|
+
|
228
|
+
task(:test_mvn_exec) {
|
229
|
+
mvn.exec("--version")
|
230
|
+
}
|
231
|
+
|
232
|
+
# task(:test_mvn_exec_locally) {
|
233
|
+
# mvn.exec_locally("--version")
|
234
|
+
# }
|
235
|
+
|
236
|
+
task(:test_mvn_artifact) {
|
237
|
+
assert_file_exists(File.join(mvn_target_path, "capistrano-maven-0.0.1-SNAPSHOT.jar"))
|
238
|
+
}
|
239
|
+
|
240
|
+
task(:test_mvn_artifact_locally) {
|
241
|
+
assert_file_not_exists(File.join(mvn_target_path_local, "capistrano-maven-0.0.1-SNAPSHOT.jar"), :via => :run_locally)
|
242
|
+
}
|
243
|
+
}
|
244
|
+
|
245
|
+
namespace(:test_with_local) {
|
246
|
+
task(:default) {
|
247
|
+
methods.grep(/^test_/).each do |m|
|
248
|
+
send(m)
|
249
|
+
end
|
250
|
+
}
|
251
|
+
before "test_with_local", "test_with_local:setup"
|
252
|
+
after "test_with_local", "test_with_local:teardown"
|
253
|
+
|
254
|
+
task(:setup) {
|
255
|
+
uninstall_mvn!
|
256
|
+
set(:mvn_version, "3.0.5")
|
257
|
+
set(:mvn_skip_tests, true)
|
258
|
+
set(:mvn_setup_remotely, false)
|
259
|
+
set(:mvn_setup_locally, true)
|
260
|
+
set(:mvn_update_remotely, false)
|
261
|
+
set(:mvn_update_locally, true)
|
262
|
+
set(:mvn_template_path, File.join(File.dirname(__FILE__), "templates"))
|
263
|
+
set(:mvn_settings, %w(settings.xml))
|
264
|
+
set(:mvn_release_build, false)
|
265
|
+
find_and_execute_task("mvn:setup_default_environment")
|
266
|
+
find_and_execute_task("deploy:setup")
|
267
|
+
find_and_execute_task("deploy")
|
268
|
+
}
|
269
|
+
|
270
|
+
task(:teardown) {
|
271
|
+
uninstall_mvn!
|
272
|
+
}
|
273
|
+
|
274
|
+
task(:test_run_mvn) {
|
275
|
+
assert_file_not_exists(mvn_bin)
|
276
|
+
assert_file_not_exists(File.join(mvn_settings_path, "settings.xml"))
|
277
|
+
assert_command_fails("#{mvn_cmd} --version")
|
278
|
+
}
|
279
|
+
|
280
|
+
task(:test_run_mvn_via_sudo) {
|
281
|
+
assert_command_fails("#{mvn_cmd} --version", :via => :sudo)
|
282
|
+
}
|
283
|
+
|
284
|
+
task(:test_run_mvn_without_path) {
|
285
|
+
assert_command_fails("mvn --version")
|
286
|
+
}
|
287
|
+
|
288
|
+
task(:test_run_mvn_via_run_locally) {
|
289
|
+
assert_file_exists(mvn_bin_local, :via => :run_locally)
|
290
|
+
assert_file_exists(File.join(mvn_settings_path_local, "settings.xml"), :via => :run_locally)
|
291
|
+
assert_command("#{mvn_cmd_local} --version", :via => :run_locally)
|
292
|
+
}
|
293
|
+
|
294
|
+
# task(:test_mvn_exec) {
|
295
|
+
# mvn.exec("--version")
|
296
|
+
# }
|
297
|
+
|
298
|
+
task(:test_mvn_exec_locally) {
|
299
|
+
mvn.exec_locally("--version")
|
300
|
+
}
|
301
|
+
|
302
|
+
task(:test_mvn_artifact) {
|
303
|
+
assert_file_exists(File.join(mvn_target_path, "capistrano-maven-0.0.1-SNAPSHOT.jar"))
|
304
|
+
}
|
305
|
+
|
306
|
+
task(:test_mvn_artifact_locally) {
|
307
|
+
assert_file_exists(File.join(mvn_target_path_local, "capistrano-maven-0.0.1-SNAPSHOT.jar"), :via => :run_locally)
|
308
|
+
}
|
309
|
+
}
|
310
|
+
|
311
|
+
namespace(:test_with_release_build) {
|
312
|
+
task(:default) {
|
313
|
+
methods.grep(/^test_/).each do |m|
|
314
|
+
send(m)
|
315
|
+
end
|
316
|
+
}
|
317
|
+
before "test_with_release_build", "test_with_release_build:setup"
|
318
|
+
after "test_with_release_build", "test_with_release_build:teardown"
|
319
|
+
|
320
|
+
task(:setup) {
|
321
|
+
uninstall_mvn!
|
322
|
+
set(:mvn_version, "3.0.5")
|
323
|
+
set(:mvn_skip_tests, true)
|
324
|
+
set(:mvn_setup_remotely, true)
|
325
|
+
set(:mvn_setup_locally, true)
|
326
|
+
set(:mvn_update_remotely, true)
|
327
|
+
set(:mvn_update_locally, true)
|
328
|
+
set(:mvn_template_path, File.join(File.dirname(__FILE__), "templates"))
|
329
|
+
set(:mvn_settings, %w(settings.xml))
|
330
|
+
set(:mvn_release_build, true)
|
331
|
+
find_and_execute_task("mvn:setup_default_environment")
|
332
|
+
find_and_execute_task("deploy:setup")
|
333
|
+
# find_and_execute_task("deploy")
|
334
|
+
}
|
335
|
+
|
336
|
+
task(:teardown) {
|
337
|
+
uninstall_mvn!
|
338
|
+
}
|
339
|
+
|
340
|
+
task(:test_build_release) {
|
341
|
+
set(:mvn_extra_options, %w(-f release.xml))
|
342
|
+
set(:mvn_extra_options_local, %w(-f release.xml))
|
343
|
+
reset_mvn!
|
344
|
+
find_and_execute_task("deploy")
|
345
|
+
}
|
346
|
+
|
347
|
+
task(:test_build_snapshot) {
|
348
|
+
set(:mvn_extra_options, %w(-f snapshot.xml))
|
349
|
+
set(:mvn_extra_options_local, %w(-f snapshot.xml))
|
350
|
+
reset_mvn!
|
351
|
+
begin
|
352
|
+
find_and_execute_task("deploy")
|
353
|
+
rescue SystemExit
|
354
|
+
aborted = true
|
355
|
+
ensure
|
356
|
+
abort("must fail with SNAPSHOT version") unless aborted
|
357
|
+
end
|
358
|
+
}
|
359
|
+
}
|
360
|
+
|
361
|
+
# vim:set ft=ruby sw=2 ts=2 :
|