capistrano-sbt 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -32,8 +32,9 @@ To build you sbt projects during Capistrano `deploy` tasks, add following in you
32
32
 
33
33
  Following options are available to manage your sbt build.
34
34
 
35
- * `:sbt_version` - project sbt version
36
- * `:sbt_archive_url` - download URL for specified sbt version
35
+ * `:sbt_use_extras` - Use [sbt-extras](https://github.com/paulp/sbt-extras) to manage sbt. `false` by default.
36
+ * `:sbt_version` - Project sbt version. This value may be discarded if `sbt_use_extras` is turned `true`.
37
+ * `:sbt_archive_url` - Download URL for specified sbt version. This value may be discarded if `sbt_use_extras` is turned `true`.
37
38
  * `:sbt_compile_locally` - compile project on localhost. false by default.
38
39
  * `:sbt_goals` - sbt commands and tasks to execute. default is "reload clean package".
39
40
  * `:sbt_update_settings` - update `*.sbt` or not. false by default.
@@ -43,6 +44,8 @@ Following options are available to manage your sbt build.
43
44
  * `:sbt_template_path` - specify ERB template path for `*.sbt`.
44
45
  * `:sbt_java_home` - optional `JAVA_HOME` settings for sbt commands.
45
46
  * `:sbt_java_home_local` - optional `JAVA_HOME` settings for sbt commands in localhost.
47
+ * `:sbt_extras_url` - Download URL of `sbt` script of sbt-extras.
48
+ * `:sbt_extras_check_interval` - Check updates of sbt-extras every specified seconds. `86400` by default.
46
49
 
47
50
  ## Contributing
48
51
 
@@ -26,18 +26,35 @@ module Capistrano
26
26
  _cset(:sbt_jar_file_local) {
27
27
  File.join(File.expand_path('.'), 'tools', 'sbt', "sbt-#{sbt_version}", File.basename(URI.parse(sbt_jar_url).path))
28
28
  }
29
+ _cset(:sbt_use_extras, false)
30
+ _cset(:sbt_extras_url, "https://raw.github.com/paulp/sbt-extras/master/sbt")
31
+ _cset(:sbt_extras_file) { File.join(shared_path, 'tools', 'sbt', 'sbt') }
32
+ _cset(:sbt_extras_file_local) { File.join(File.expand_path('.'), 'tools', 'sbt', 'sbt') }
33
+ _cset(:sbt_extras_check_interval, 86400)
34
+ _cset(:sbt_extras_check_timestamp) { (Time.now - sbt_extras_check_interval).strftime('%Y%m%d%H%M') }
29
35
  _cset(:sbt_cmd) {
30
36
  if fetch(:sbt_java_home, nil)
31
- "env JAVA_HOME=#{sbt_java_home} #{sbt_java_home}/bin/java -jar #{sbt_jar_file} #{sbt_options.join(' ')}"
37
+ env = "env JAVA_HOME=#{sbt_java_home.dump}"
38
+ java = "#{sbt_java_home}/bin/java"
32
39
  else
33
- "java -jar #{sbt_jar_file} #{sbt_options.join(' ')}"
40
+ env = ""
41
+ java = "java"
42
+ end
43
+ if sbt_use_extras
44
+ "#{env} #{sbt_extras_file} #{sbt_options.join(' ')}".strip
45
+ else
46
+ "#{env} #{java} -jar #{sbt_jar_file} #{sbt_options.join(' ')}".strip
34
47
  end
35
48
  }
36
49
  _cset(:sbt_cmd_local) {
37
50
  if fetch(:sbt_java_home_local, nil)
38
- "env JAVA_HOME=#{sbt_java_home_local} #{sbt_java_home_local}/bin/java -jar #{sbt_jar_file_local} #{sbt_options_local.join(' ')}"
51
+ env = "env JAVA_HOME=#{sbt_java_home_local.dump}"
52
+ java = "#{sbt_java_home_local}/bin/java"
53
+ end
54
+ if sbt_use_extras
55
+ "#{env} #{sbt_extras_file_local} #{sbt_options_local.join(' ')}".strip
39
56
  else
40
- "java -jar #{sbt_jar_file_local} #{sbt_options_local.join(' ')}"
57
+ "#{env} #{java} -jar #{sbt_jar_file_local} #{sbt_options_local.join(' ')}".strip
41
58
  end
42
59
  }
43
60
  _cset(:sbt_project_path) {
@@ -99,20 +116,30 @@ module Capistrano
99
116
 
100
117
  def _install(options={})
101
118
  execute = []
102
- jar_file = options.delete(:jar_file)
103
- jar_url = options.delete(:jar_url)
104
- execute << "mkdir -p #{File.dirname(jar_file)}"
105
- execute << "( test -f #{jar_file} || wget --no-verbose -O #{jar_file} #{jar_url} )"
106
- execute << "test -f #{jar_file}"
119
+ if sbt_use_extras
120
+ extras_file = options.delete(:extras_file)
121
+ execute << "mkdir -p #{File.dirname(extras_file)}"
122
+ x = "/tmp/sbt-extras.#{$$}"
123
+ execute << "touch -t #{sbt_extras_check_timestamp} #{x}"
124
+ execute << "( test #{extras_file} -nt #{x} || wget --no-verbose -O #{extras_file} #{sbt_extras_url} )"
125
+ execute << "touch #{extras_file}"
126
+ execute << "rm -f #{x}"
127
+ execute << "( test -x #{extras_file} || chmod a+x #{extras_file} )"
128
+ else
129
+ jar_file = options.delete(:jar_file)
130
+ execute << "mkdir -p #{File.dirname(jar_file)}"
131
+ execute << "( test -f #{jar_file} || wget --no-verbose -O #{jar_file} #{sbt_jar_url} )"
132
+ execute << "test -f #{jar_file}"
133
+ end
107
134
  execute.join(' && ')
108
135
  end
109
136
 
110
137
  task(:install, :roles => :app, :except => { :no_release => true }) {
111
- run(_install(:jar_file => sbt_jar_file, :jar_url => sbt_jar_url))
138
+ run(_install(:jar_file => sbt_jar_file, :extras_file => sbt_extras_file))
112
139
  }
113
140
 
114
141
  task(:install_locally, :except => { :no_release => true }) {
115
- run_locally(_install(:jar_file => sbt_jar_file_local, :jar_url => sbt_jar_url))
142
+ run_locally(_install(:jar_file => sbt_jar_file_local, :extras_file => sbt_extras_file_local))
116
143
  }
117
144
 
118
145
  def template(file)
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Sbt
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
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.3
4
+ version: 0.0.4
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-10-18 00:00:00.000000000 Z
12
+ date: 2012-10-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano