capistrano-sbt 0.0.5 → 0.0.6

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/README.md CHANGED
@@ -49,6 +49,7 @@ Following options are available to manage your sbt build.
49
49
  * `:sbt_extras_url` - Download URL of `sbt` script of sbt-extras.
50
50
  * `:sbt_extras_check_interval` - Check updates of sbt-extras every specified seconds. `86400` by default.
51
51
  * `:sbt_log_noformat` - Do not colorize sbt outputs. `true` by default.
52
+ * `:sbt_release_build` - Skip building on SNAPSHOT version. `false` by default.
52
53
 
53
54
  ## Contributing
54
55
 
@@ -1,6 +1,5 @@
1
1
 
2
2
  require 'capistrano'
3
- require 'tempfile'
4
3
  require 'uri'
5
4
 
6
5
  module Capistrano
@@ -8,7 +7,7 @@ module Capistrano
8
7
  def self.extended(configuration)
9
8
  configuration.load {
10
9
  namespace(:sbt) {
11
- _cset(:sbt_version, '0.11.2')
10
+ _cset(:sbt_version, '0.12.2')
12
11
  _cset(:sbt_group_id) {
13
12
  case sbt_version
14
13
  when /^0\.(?:7|10)\.\d+$/, /^0\.11\.[0-2]$/
@@ -184,7 +183,7 @@ module Capistrano
184
183
 
185
184
  task(:update_settings, :roles => :app, :except => { :no_release => true }) {
186
185
  srcs = sbt_settings.map { |f| File.join(sbt_template_path, f) }
187
- tmps = sbt_settings.map { |f| t=Tempfile.new('sbt');s=t.path;t.close(true);s }
186
+ tmps = sbt_settings.map { |f| capture("mktemp").chomp }
188
187
  dsts = sbt_settings.map { |f| File.join(sbt_settings_path, f) }
189
188
  begin
190
189
  srcs.zip(tmps).each do |src, tmp|
@@ -198,7 +197,7 @@ module Capistrano
198
197
 
199
198
  task(:update_settings_locally, :except => { :no_release => true }) {
200
199
  srcs = sbt_settings_local.map { |f| File.join(sbt_template_path, f) }
201
- tmps = sbt_settings.map { |f| t=Tempfile.new('sbt');s=t.path;t.close(true);s }
200
+ tmps = sbt_settings.map { |f| `mktemp`.chomp }
202
201
  dsts = sbt_settings_local.map { |f| File.join(sbt_settings_path_local, f) }
203
202
  begin
204
203
  srcs.zip(tmps).each do |src, tmp|
@@ -230,22 +229,52 @@ module Capistrano
230
229
  }
231
230
  }
232
231
 
232
+ def _sbt(cmd, path, goals=[])
233
+ "cd #{path.dump} && #{cmd} #{goals.map { |s| s.dump }.join(' ')}"
234
+ end
235
+
236
+ def _sbt_parse_version(s)
237
+ # FIXME: is there any better way to get project version?
238
+ lastline = s.split(/(?:\r?\n)+/)[-1]
239
+ lastline.split[-1]
240
+ end
241
+
242
+ _cset(:sbt_release_build, false)
243
+ _cset(:sbt_snapshot_pattern, /-SNAPSHOT$/i)
244
+ _cset(:sbt_project_version) {
245
+ _sbt_parse_version(capture(_sbt(sbt_cmd, sbt_project_path, ["show version"])))
246
+ }
247
+ _cset(:sbt_project_version_local) {
248
+ _sbt_parse_version(run_locally(_sbt(sbt_cmd_local, sbt_project_path_local, ["show version"])))
249
+ }
250
+
251
+ def _validate_project_version(version_key)
252
+ if sbt_release_build
253
+ version = fetch(version_key)
254
+ if sbt_snapshot_pattern === version
255
+ abort("Skip to build project since \`#{version}' is a SNAPSHOT version.")
256
+ end
257
+ end
258
+ end
259
+
233
260
  desc("Perform sbt build.")
234
261
  task(:execute, :roles => :app, :except => { :no_release => true }) {
235
262
  on_rollback {
236
- run("cd #{sbt_project_path} && #{sbt_cmd} clean")
263
+ run(_sbt(sbt_cmd, sbt_project_path, %w(clean)))
237
264
  }
238
- run("cd #{sbt_project_path} && #{sbt_cmd} #{sbt_goals.join(' ')}")
265
+ _validate_project_version(:sbt_project_version)
266
+ run(_sbt(sbt_cmd, sbt_project_path, sbt_goals))
239
267
  }
240
268
 
241
269
  desc("Perform sbt build locally.")
242
270
  task(:execute_locally, :roles => :app, :except => { :no_release => true }) {
243
271
  on_rollback {
244
- run_locally("cd #{sbt_project_path_local} && #{sbt_cmd_local} clean")
272
+ run_locally(_sbt(sbt_cmd_local, sbt_project_path_local, %w(clean)))
245
273
  }
246
- cmd = "cd #{sbt_project_path_local} && #{sbt_cmd_local} #{sbt_goals.join(' ')}"
247
- logger.info(cmd)
248
- abort("execution failure") unless system(cmd)
274
+ _validate_project_version(:sbt_project_version_local)
275
+ cmdline = _sbt(sbt_cmd_local, sbt_project_path_local, sbt_goals)
276
+ logger.info(cmdline)
277
+ abort("execution failure") unless system(cmdline)
249
278
  }
250
279
 
251
280
  _cset(:sbt_tar, 'tar')
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Sbt
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-sbt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-01 00:00:00.000000000 Z
12
+ date: 2013-02-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -69,3 +69,4 @@ signing_key:
69
69
  specification_version: 3
70
70
  summary: a capistrano recipe to deploy sbt based projects.
71
71
  test_files: []
72
+ has_rdoc: