capistrano-sbt 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +62 -0
- data/Rakefile +2 -0
- data/capistrano-sbt.gemspec +19 -0
- data/lib/capistrano-sbt.rb +8 -0
- data/lib/capistrano-sbt/deploy.rb +210 -0
- data/lib/capistrano-sbt/templates/global.sbt +2 -0
- data/lib/capistrano-sbt/version.rb +5 -0
- metadata +72 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Yamashita Yuu
|
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,62 @@
|
|
1
|
+
# capistrano-sbt
|
2
|
+
|
3
|
+
a capistrano recipe to deploy [sbt](https://github.com/harrah/xsbt) based projects.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'capistrano-sbt'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install capistrano-sbt
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
This recipes will try to do following things during Capistrano `deploy:setup` and `deploy` tasks.
|
22
|
+
|
23
|
+
(1) Download and install sbt for current project
|
24
|
+
(2) Prepare optional `*.sbt` for current project (optional)
|
25
|
+
(3) Build sbt project remotely (default) or locally
|
26
|
+
|
27
|
+
To build you sbt projects during Capistrano `deploy` tasks, add following in you `config/deploy.rb`. By default, sbt build will run after the Capistrano's `deploy:finalize_update`.
|
28
|
+
|
29
|
+
# in "config/deploy.rb"
|
30
|
+
require 'capistrano-sbt'
|
31
|
+
set(:sbt_version, '0.11.2') # sbt version to build project
|
32
|
+
|
33
|
+
Following options are available to manage your sbt build.
|
34
|
+
|
35
|
+
* `:sbt_version` - project sbt version
|
36
|
+
* `:sbt_archive_url` - download URL for specified sbt version
|
37
|
+
* `:sbt_compile_locally` - compile project on localhost. false by default.
|
38
|
+
* `:sbt_goals` - sbt commands and tasks to execute. default is "reload clean package".
|
39
|
+
* `:sbt_update_settings` - update `*.sbt` or not. false by default.
|
40
|
+
* `:sbt_update_settings_locally` - udate `*.sbt` or not on local compilation. false by default.
|
41
|
+
* `:sbt_settings` - list of your optional `*.sbt` files
|
42
|
+
* `:sbt_settings_local` - list of your optional `*.sbt` files in on local compilation.
|
43
|
+
* `:sbt_template_path` - specify ERB template path for `*.sbt`.
|
44
|
+
* `:sbt_java_home` - optional `JAVA_HOME` settings for sbt commands.
|
45
|
+
* `:sbt_java_home_local` - optional `JAVA_HOME` settings for sbt commands in localhost.
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
1. Fork it
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
+
5. Create new Pull Request
|
54
|
+
|
55
|
+
## Author
|
56
|
+
|
57
|
+
- YAMASHITA Yuu (https://github.com/yyuu)
|
58
|
+
- Geisha Tokyo Entertainment Inc. (http://www.geishatokyo.com/)
|
59
|
+
|
60
|
+
## License
|
61
|
+
|
62
|
+
MIT
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/capistrano-sbt/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Yamashita Yuu"]
|
6
|
+
gem.email = ["yamashita@geishatokyo.com"]
|
7
|
+
gem.description = %q{a capistrano recipe to deploy sbt based projects.}
|
8
|
+
gem.summary = %q{a capistrano recipe to deploy sbt based projects.}
|
9
|
+
gem.homepage = "https://github.com/yyuu/capistrano-sbt"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "capistrano-sbt"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Capistrano::Sbt::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency("capistrano")
|
19
|
+
end
|
@@ -0,0 +1,210 @@
|
|
1
|
+
|
2
|
+
require 'capistrano'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
module Capistrano
|
6
|
+
module Sbt
|
7
|
+
def self.extended(configuration)
|
8
|
+
configuration.load {
|
9
|
+
namespace(:sbt) {
|
10
|
+
_cset(:sbt_version, '0.11.2')
|
11
|
+
_cset(:sbt_jar_url) {
|
12
|
+
"http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/#{sbt_version}/sbt-launch.jar"
|
13
|
+
}
|
14
|
+
_cset(:sbt_jar_file) {
|
15
|
+
File.join(shared_path, 'tools', 'sbt', "sbt-#{sbt_version}", File.basename(URI.parse(sbt_jar_url).path))
|
16
|
+
}
|
17
|
+
_cset(:sbt_jar_file_local) {
|
18
|
+
File.join(File.expand_path('.'), 'tools', 'sbt', "sbt-#{sbt_version}", File.basename(URI.parse(sbt_jar_url).path))
|
19
|
+
}
|
20
|
+
_cset(:sbt_cmd) {
|
21
|
+
if fetch(:sbt_java_home, nil)
|
22
|
+
"env JAVA_HOME=#{sbt_java_home} #{sbt_java_home}/bin/java -jar #{sbt_jar_file} #{sbt_options.join(' ')}"
|
23
|
+
else
|
24
|
+
"java -jar #{sbt_jar_file} #{sbt_options.join(' ')}"
|
25
|
+
end
|
26
|
+
}
|
27
|
+
_cset(:sbt_cmd_local) {
|
28
|
+
if fetch(:sbt_java_home_local, nil)
|
29
|
+
"env JAVA_HOME=#{sbt_java_home_local} #{sbt_java_home_local}/bin/java -jar #{sbt_jar_file_local} #{sbt_options_local.join(' ')}"
|
30
|
+
else
|
31
|
+
"java -jar #{sbt_jar_file_local} #{sbt_options_local.join(' ')}"
|
32
|
+
end
|
33
|
+
}
|
34
|
+
_cset(:sbt_project_path) {
|
35
|
+
release_path
|
36
|
+
}
|
37
|
+
_cset(:sbt_project_path_local) {
|
38
|
+
Dir.pwd
|
39
|
+
}
|
40
|
+
_cset(:sbt_target_path) {
|
41
|
+
File.join(sbt_project_path, 'target')
|
42
|
+
}
|
43
|
+
_cset(:sbt_target_path_local) {
|
44
|
+
File.join(sbt_project_path_local, File.basename(sbt_target_path))
|
45
|
+
}
|
46
|
+
_cset(:sbt_template_path, File.join(File.dirname(__FILE__), 'templates'))
|
47
|
+
_cset(:sbt_update_settings, false)
|
48
|
+
_cset(:sbt_update_settings_locally, false)
|
49
|
+
_cset(:sbt_settings_path) {
|
50
|
+
sbt_project_path
|
51
|
+
}
|
52
|
+
_cset(:sbt_settings_path_local) {
|
53
|
+
sbt_project_path_local
|
54
|
+
}
|
55
|
+
_cset(:sbt_settings, [])
|
56
|
+
_cset(:sbt_settings_local, [])
|
57
|
+
_cset(:sbt_cleanup_settings, [])
|
58
|
+
_cset(:sbt_cleanup_settings_local, [])
|
59
|
+
_cset(:sbt_compile_locally, false) # perform precompilation on localhost
|
60
|
+
_cset(:sbt_goals, %w(reload clean package))
|
61
|
+
_cset(:sbt_common_options, [])
|
62
|
+
_cset(:sbt_options) {
|
63
|
+
sbt_common_options + fetch(:sbt_extra_options, [])
|
64
|
+
}
|
65
|
+
_cset(:sbt_options_local) {
|
66
|
+
sbt_common_options + fetch(:sbt_extra_options_local, [])
|
67
|
+
}
|
68
|
+
|
69
|
+
desc("Setup sbt.")
|
70
|
+
task(:setup, :roles => :app, :except => { :no_release => true }) {
|
71
|
+
transaction {
|
72
|
+
install
|
73
|
+
update_settings if sbt_update_settings
|
74
|
+
setup_locally if sbt_compile_locally
|
75
|
+
}
|
76
|
+
}
|
77
|
+
after 'deploy:setup', 'sbt:setup'
|
78
|
+
|
79
|
+
desc("Setup sbt locally.")
|
80
|
+
task(:setup_locally, :except => { :no_release => true }) {
|
81
|
+
transaction {
|
82
|
+
install_locally
|
83
|
+
update_settings_locally if sbt_update_settings_locally
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
task(:install, :roles => :app, :except => { :no_release => true }) {
|
88
|
+
run(<<-E)
|
89
|
+
( test -d #{File.dirname(sbt_jar_file)} || mkdir -p #{File.dirname(sbt_jar_file)} ) &&
|
90
|
+
( test -f #{sbt_jar_file} || wget --no-verbose -O #{sbt_jar_file} #{sbt_jar_url} ) &&
|
91
|
+
test -f #{sbt_jar_file};
|
92
|
+
E
|
93
|
+
}
|
94
|
+
|
95
|
+
task(:install_locally, :except => { :no_release => true }) { # TODO: make install and install_locally together
|
96
|
+
run_locally(<<-E)
|
97
|
+
( test -d #{File.dirname(sbt_jar_file_local)} || mkdir -p #{File.dirname(sbt_jar_file_local)} ) &&
|
98
|
+
( test -f #{sbt_jar_file_local} || wget --no-verbose -O #{sbt_jar_file_local} #{sbt_jar_url} ) &&
|
99
|
+
test -f #{sbt_jar_file_local};
|
100
|
+
E
|
101
|
+
}
|
102
|
+
|
103
|
+
task(:update_settings, :roles => :app, :except => { :no_release => true }) {
|
104
|
+
tmp_files = []
|
105
|
+
on_rollback {
|
106
|
+
run("rm -f #{tmp_files.join(' ')}") unless tmp_files.empty?
|
107
|
+
}
|
108
|
+
sbt_settings.each { |file|
|
109
|
+
tmp_files << tmp_file = File.join('/tmp', File.basename(file))
|
110
|
+
src_file = File.join(sbt_template_path, file)
|
111
|
+
dst_file = File.join(sbt_settings_path, file)
|
112
|
+
run(<<-E)
|
113
|
+
( test -d #{File.dirname(dst_file)} || mkdir -p #{File.dirname(dst_file)} ) &&
|
114
|
+
( test -f #{dst_file} && mv -f #{dst_file} #{dst_file}.orig; true );
|
115
|
+
E
|
116
|
+
if File.file?(src_file)
|
117
|
+
put(File.read(src_file), tmp_file)
|
118
|
+
elsif File.file?("#{src_file}.erb")
|
119
|
+
put(ERB.new(File.read("#{src_file}.erb")).result(binding), tmp_file)
|
120
|
+
else
|
121
|
+
abort("sbt:update_settings: no such template found: #{src_file} or #{src_file}.erb")
|
122
|
+
end
|
123
|
+
run("diff #{dst_file} #{tmp_file} || mv -f #{tmp_file} #{dst_file}")
|
124
|
+
}
|
125
|
+
run("rm -f #{sbt_cleanup_settings.join(' ')}") unless sbt_cleanup_settings.empty?
|
126
|
+
}
|
127
|
+
|
128
|
+
task(:update_settings_locally, :except => { :no_release => true }) {
|
129
|
+
sbt_settings_local.each { |file|
|
130
|
+
src_file = File.join(sbt_template_path, file)
|
131
|
+
dst_file = File.join(sbt_settings_path_local, file)
|
132
|
+
run_locally(<<-E)
|
133
|
+
( test -d #{File.dirname(dst_file)} || mkdir -p #{File.dirname(dst_file)} ) &&
|
134
|
+
( test -f #{dst_file} && mv -f #{dst_file} #{dst_file}.orig; true );
|
135
|
+
E
|
136
|
+
if File.file?(src_file)
|
137
|
+
File.open(dst_file, 'w') { |fp|
|
138
|
+
fp.write(File.read(src_file))
|
139
|
+
}
|
140
|
+
elsif File.file?("#{src_file}.erb")
|
141
|
+
File.open(dst_file, 'w') { |fp|
|
142
|
+
fp.write(ERB.new(File.read("#{src_file}.erb")).result(binding))
|
143
|
+
}
|
144
|
+
else
|
145
|
+
abort("sbt:update_settings_locally: no such template: #{src_file} or #{src_file}.erb")
|
146
|
+
end
|
147
|
+
}
|
148
|
+
run_locally("rm -f #{sbt_cleanup_settings_local.join(' ')}") unless sbt_cleanup_settings_local.empty?
|
149
|
+
}
|
150
|
+
|
151
|
+
desc("Update sbt build.")
|
152
|
+
task(:update, :roles => :app, :except => { :no_release => true }) {
|
153
|
+
transaction {
|
154
|
+
if sbt_compile_locally
|
155
|
+
update_locally
|
156
|
+
else
|
157
|
+
execute
|
158
|
+
end
|
159
|
+
}
|
160
|
+
}
|
161
|
+
after 'deploy:finalize_update', 'sbt:update'
|
162
|
+
|
163
|
+
desc("Update sbt build locally.")
|
164
|
+
task(:update_locally, :except => { :no_release => true }) {
|
165
|
+
transaction {
|
166
|
+
execute_locally
|
167
|
+
upload_locally
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
desc("Perform sbt build.")
|
172
|
+
task(:execute, :roles => :app, :except => { :no_release => true }) {
|
173
|
+
on_rollback {
|
174
|
+
run("cd #{sbt_project_path} && #{sbt_cmd} clean")
|
175
|
+
}
|
176
|
+
run("cd #{sbt_project_path} && #{sbt_cmd} #{sbt_goals.join(' ')}")
|
177
|
+
}
|
178
|
+
|
179
|
+
desc("Perform sbt build locally.")
|
180
|
+
task(:execute_locally, :roles => :app, :except => { :no_release => true }) {
|
181
|
+
setup_locally
|
182
|
+
on_rollback {
|
183
|
+
run_locally("cd #{sbt_project_path_local} && #{sbt_cmd_local} clean")
|
184
|
+
}
|
185
|
+
cmd = "cd #{sbt_project_path_local} && #{sbt_cmd_local} #{sbt_goals.join(' ')}"
|
186
|
+
logger.info(cmd)
|
187
|
+
abort("execution failure") unless system(cmd)
|
188
|
+
}
|
189
|
+
|
190
|
+
task(:upload_locally, :roles => :app, :except => { :no_release => true }) {
|
191
|
+
on_rollback {
|
192
|
+
run("rm -rf #{sbt_target_path}")
|
193
|
+
}
|
194
|
+
run_locally("test -d #{sbt_target_path_local}")
|
195
|
+
run("mkdir -p #{sbt_target_path}")
|
196
|
+
find_servers_for_task(current_task).each { |server|
|
197
|
+
run_locally("rsync -lrt --chmod=u+rwX,go+rX #{sbt_target_path_local}/ #{user}@#{server.host}:#{sbt_target_path}/")
|
198
|
+
}
|
199
|
+
}
|
200
|
+
}
|
201
|
+
}
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
if Capistrano::Configuration.instance
|
207
|
+
Capistrano::Configuration.instance.extend(Capistrano::Sbt)
|
208
|
+
end
|
209
|
+
|
210
|
+
# vim:set ft=ruby :
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-sbt
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yamashita Yuu
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: a capistrano recipe to deploy sbt based projects.
|
31
|
+
email:
|
32
|
+
- yamashita@geishatokyo.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- capistrano-sbt.gemspec
|
43
|
+
- lib/capistrano-sbt.rb
|
44
|
+
- lib/capistrano-sbt/deploy.rb
|
45
|
+
- lib/capistrano-sbt/templates/global.sbt
|
46
|
+
- lib/capistrano-sbt/version.rb
|
47
|
+
homepage: https://github.com/yyuu/capistrano-sbt
|
48
|
+
licenses: []
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.8.23
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: a capistrano recipe to deploy sbt based projects.
|
71
|
+
test_files: []
|
72
|
+
has_rdoc:
|