capistrano-mvn 0.1.0
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.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +88 -0
- data/Rakefile +1 -0
- data/capistrano-mvn.gemspec +24 -0
- data/lib/capistrano-mvn.rb +0 -0
- data/lib/capistrano/mvn.rb +1 -0
- data/lib/capistrano/mvn/version.rb +5 -0
- data/lib/capistrano/tasks/mvn.rake +194 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YzZhOWFjMWU2MjViZGRmZmJhNDQzMmQ0Njc4MDViYjkzZDk0NDM1Yg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NTgwMGY1Y2E0MTQzMDVlOGZjOTM1YTRhMTdiMzY1MDdlYTQwZWM3OA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Y2EwNmNlM2YxZjQ1NTM3NWRjYjRhMTY2NDc3YjBiZGZhNDUyZjE2ZjY2OWQ5
|
10
|
+
MGRkM2VkNGQyZmFkNDYyZWJiNzExMjc3N2QwY2Q3NDg2NDgzYmRjM2ZjZjBk
|
11
|
+
MDhkZDY5ODAxMjJhZGYzNWNkNTlmZTljMDI0MTBiYWFkN2UwMzg=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZGRkNmM3MTE4MTQzNzA0YTgyMWIyYzA5NTA3MzY5MWMyOTZmZTRjY2RjNzYz
|
14
|
+
YTgyYTU0Zjc2MzBkNmZiYWI0MDllNjEyYWY4YTk1NTBkYTZmMDljMWRhN2U3
|
15
|
+
OTUxM2M2NzM0NDI3MDg0ZDA2ZTdkZjJlYTE2MjMxNmMzNDAzZDU=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Dmitry Geurkov (d.geurkov@gmail.com)
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# Capistrano::Mvn
|
2
|
+
|
3
|
+
maven helper gem for deploying artifacts using capistrano v3
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'capistrano-mvn'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install capistrano-mvn
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Add this line to your Capfile:
|
22
|
+
|
23
|
+
require 'capistrano/mvn'
|
24
|
+
|
25
|
+
Examples:
|
26
|
+
|
27
|
+
desc "package and deploy artifact"
|
28
|
+
task :deploy do
|
29
|
+
artifact = nil
|
30
|
+
run_locally do
|
31
|
+
mvn :package
|
32
|
+
artifact = mvn_project_artifact_path
|
33
|
+
end
|
34
|
+
|
35
|
+
on roles(:all) do
|
36
|
+
deploy artifact, "/deploy/to/#{basename(artifact)}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "deploy dependencies"
|
41
|
+
task :deploy do
|
42
|
+
dependencies = []
|
43
|
+
run_locally do
|
44
|
+
dependencies = mvn_dependency_classpath
|
45
|
+
end
|
46
|
+
|
47
|
+
on roles(:all) do
|
48
|
+
dependencies.each do |artifact|
|
49
|
+
deploy artifact, "/deploy/to/#{basename(artifact)}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "deploy dependencies except junit"
|
55
|
+
task :deploy do
|
56
|
+
dependencies = []
|
57
|
+
run_locally do
|
58
|
+
dependencies = mvn_dependency_classpath
|
59
|
+
end
|
60
|
+
|
61
|
+
on roles(:all) do
|
62
|
+
except(dependencies, "*junit*").each do |artifact|
|
63
|
+
deploy artifact, "/deploy/to/#{basename(artifact)}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
desc "deploy only apache commons and mysql-connector dependencies"
|
69
|
+
task :deploy do
|
70
|
+
dependencies = []
|
71
|
+
run_locally do
|
72
|
+
dependencies = mvn_dependency_classpath
|
73
|
+
end
|
74
|
+
|
75
|
+
on roles(:all) do
|
76
|
+
only(dependencies, ["*commons-*", "*mysql-connector*"]).each do |artifact|
|
77
|
+
deploy artifact, "/deploy/to/#{basename(artifact)}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
## Contributing
|
83
|
+
|
84
|
+
1. Fork it
|
85
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
86
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
87
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
88
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capistrano/mvn/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "capistrano-mvn"
|
8
|
+
spec.version = Capistrano::Mvn::VERSION
|
9
|
+
spec.authors = ["Dmitry Geurkov (troydm)"]
|
10
|
+
spec.email = ["d.geurkov@gmail.com"]
|
11
|
+
spec.description = %q{maven deployment tasks for capistrano v3}
|
12
|
+
spec.summary = %q{capistrano maven deployment}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "capistrano", "~> 3.0"
|
21
|
+
spec.add_dependency "sshkit", "~> 1.2"
|
22
|
+
spec.add_development_dependency "bundler"
|
23
|
+
spec.add_development_dependency "rake"
|
24
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path("../tasks/mvn.rake", __FILE__)
|
@@ -0,0 +1,194 @@
|
|
1
|
+
require 'sshkit'
|
2
|
+
|
3
|
+
module SSHKit
|
4
|
+
|
5
|
+
module CommandHelper
|
6
|
+
|
7
|
+
def mvn_prepare
|
8
|
+
# determine mvn location
|
9
|
+
if !fetch(:m2_home).nil?
|
10
|
+
SSHKit.config.command_map[:mvn] = "#{fetch(:m2_home)}/bin/mvn"
|
11
|
+
else
|
12
|
+
m2_home = capture('echo $M2_HOME')
|
13
|
+
if m2_home != '' and test("[ -d #{m2_home} ]")
|
14
|
+
SSHKit.config.command_map[:mvn] = "#{m2_home}/bin/mvn"
|
15
|
+
else
|
16
|
+
SSHKit.config.command_map[:mvn] = "env mvn"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def mvn(tasks=[])
|
22
|
+
mvn_prepare
|
23
|
+
execute :mvn, tasks
|
24
|
+
end
|
25
|
+
|
26
|
+
def mvn_parse_output(output)
|
27
|
+
flag = false
|
28
|
+
data = []
|
29
|
+
output.split("\n").each do |line|
|
30
|
+
if line.start_with?('[')
|
31
|
+
flag = false
|
32
|
+
end
|
33
|
+
if flag
|
34
|
+
data << line
|
35
|
+
end
|
36
|
+
if line.start_with?('[')
|
37
|
+
flag = true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
return data
|
41
|
+
end
|
42
|
+
|
43
|
+
def mvn_dependency_classpath
|
44
|
+
mvn_prepare
|
45
|
+
classpath_list = mvn_parse_output(capture(:mvn, 'dependency:build-classpath'))[0]
|
46
|
+
return classpath_list.split(':')
|
47
|
+
end
|
48
|
+
|
49
|
+
def mvn_property(name)
|
50
|
+
return mvn_parse_output(capture(:mvn, "help:evaluate -Dexpression=#{name}"))[0]
|
51
|
+
end
|
52
|
+
|
53
|
+
def mvn_project_version
|
54
|
+
return mvn_property('project.version')
|
55
|
+
end
|
56
|
+
|
57
|
+
def mvn_project_build_directory
|
58
|
+
return mvn_property('project.build.directory')
|
59
|
+
end
|
60
|
+
|
61
|
+
def mvn_project_build_final_name
|
62
|
+
return mvn_property('project.build.finalName')
|
63
|
+
end
|
64
|
+
|
65
|
+
def mvn_project_packaging
|
66
|
+
return mvn_property('project.packaging')
|
67
|
+
end
|
68
|
+
|
69
|
+
def mvn_project_file
|
70
|
+
return mvn_property('project.file')
|
71
|
+
end
|
72
|
+
|
73
|
+
def mvn_project_artifact_path
|
74
|
+
return "#{mvn_project_build_directory}#{File::SEPARATOR}#{mvn_project_build_final_name}.#{mvn_project_packaging}"
|
75
|
+
end
|
76
|
+
|
77
|
+
def basename(name)
|
78
|
+
File.basename(name)
|
79
|
+
end
|
80
|
+
|
81
|
+
# compute md5sum
|
82
|
+
def md5sum(file)
|
83
|
+
return capture(:md5sum,file).split(' ')[0]
|
84
|
+
end
|
85
|
+
|
86
|
+
# deploy file
|
87
|
+
def deploy(local_file, remote_file)
|
88
|
+
# compute local file md5sum
|
89
|
+
local_md5sum = nil
|
90
|
+
run_locally do
|
91
|
+
local_md5sum = md5sum(local_file)
|
92
|
+
end
|
93
|
+
# compute remote file md5sum
|
94
|
+
remote_md5sum = 'nil'
|
95
|
+
if test("[ -f #{remote_file} ]")
|
96
|
+
remote_md5sum = md5sum(remote_file)
|
97
|
+
end
|
98
|
+
# check md5sums
|
99
|
+
if local_md5sum != remote_md5sum
|
100
|
+
# deploy file
|
101
|
+
info "md5sums #{local_md5sum} #{remote_md5sum} do not match"
|
102
|
+
info "deploy #{local_file} to #{remote_file}"
|
103
|
+
upload!(local_file,remote_file)
|
104
|
+
else
|
105
|
+
info "#{remote_file} is up to date!"
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# deploy file remotely
|
110
|
+
def remote_deploy(from_file, to_file)
|
111
|
+
# compute from file md5sum
|
112
|
+
from_md5sum = md5sum(from_file)
|
113
|
+
# compute remote file md5sum
|
114
|
+
to_md5sum = 'nil'
|
115
|
+
if test("[ -f #{to_file} ]")
|
116
|
+
to_md5sum = md5sum(to_file)
|
117
|
+
end
|
118
|
+
# check md5sums
|
119
|
+
if from_md5sum != to_md5sum
|
120
|
+
# deploy file
|
121
|
+
info "md5sums #{from_md5sum} #{to_md5sum} do not match"
|
122
|
+
info "deploy #{from_file} to #{to_file}"
|
123
|
+
execute :cp, "#{from_file} #{to_file}"
|
124
|
+
else
|
125
|
+
info "#{to_file} is up to date!"
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# deploy directory recursively
|
130
|
+
def deploy_directory(local_directory, remote_directory)
|
131
|
+
execute :mkdir, "-p #{remote_directory}"
|
132
|
+
Dir.foreach(local_directory) do |file|
|
133
|
+
next if file == '.' or file == '..'
|
134
|
+
path = "#{local_directory}#{File::SEPARATOR}#{file}"
|
135
|
+
if File.directory?(path)
|
136
|
+
deploy_directory(path,"#{remote_directory}#{File::SEPARATOR}#{file}")
|
137
|
+
else
|
138
|
+
deploy(path,"#{remote_directory}#{File::SEPARATOR}#{file}")
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
# remotely deploy directory recursively
|
144
|
+
def remote_deploy_directory(from_directory, to_directory)
|
145
|
+
execute :mkdir, "-p #{to_directory}"
|
146
|
+
Dir.foreach(from_directory) do |file|
|
147
|
+
next if file == '.' or file == '..'
|
148
|
+
path = "#{from_directory}#{File::SEPARATOR}#{file}"
|
149
|
+
if File.directory?(path)
|
150
|
+
remote_deploy_directory(path,"#{to_directory}#{File::SEPARATOR}#{file}")
|
151
|
+
else
|
152
|
+
remote_deploy(path,"#{to_directory}#{File::SEPARATOR}#{file}")
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# file list filter
|
158
|
+
# returns only files that match any of patterns
|
159
|
+
def only(files,patterns)
|
160
|
+
if !patterns.kind_of?(Array)
|
161
|
+
patterns = [patterns]
|
162
|
+
end
|
163
|
+
files.select do |file|
|
164
|
+
matches = false
|
165
|
+
patterns.each do |pattern|
|
166
|
+
if File.fnmatch(pattern,file)
|
167
|
+
matches = true
|
168
|
+
break
|
169
|
+
end
|
170
|
+
end
|
171
|
+
matches
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# file list filter
|
176
|
+
# returns files except any that matches patterns
|
177
|
+
def except(files,patterns)
|
178
|
+
if !patterns.kind_of?(Array)
|
179
|
+
patterns = [patterns]
|
180
|
+
end
|
181
|
+
files.select do |file|
|
182
|
+
matches = true
|
183
|
+
patterns.each do |pattern|
|
184
|
+
if File.fnmatch(pattern,file)
|
185
|
+
matches = false
|
186
|
+
break
|
187
|
+
end
|
188
|
+
end
|
189
|
+
matches
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-mvn
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dmitry Geurkov (troydm)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: capistrano
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sshkit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: maven deployment tasks for capistrano v3
|
70
|
+
email:
|
71
|
+
- d.geurkov@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- capistrano-mvn.gemspec
|
82
|
+
- lib/capistrano-mvn.rb
|
83
|
+
- lib/capistrano/mvn.rb
|
84
|
+
- lib/capistrano/mvn/version.rb
|
85
|
+
- lib/capistrano/tasks/mvn.rake
|
86
|
+
homepage: ''
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.1.11
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: capistrano maven deployment
|
110
|
+
test_files: []
|