capistrano-java 0.0.1 → 0.0.2

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/.gitignore CHANGED
@@ -19,3 +19,6 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
+ *.swp
23
+ *.sop
24
+ *.gem
data/README.rdoc CHANGED
@@ -1,17 +1,36 @@
1
1
  = capistrano-java
2
2
 
3
- Description goes here.
4
-
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Add tests for it. This is important so I don't break it in a
10
- future version unintentionally.
11
- * Commit, do not mess with rakefile, version, or history.
12
- (if you want to have your own version, that is fine but
13
- bump version in a commit by itself I can ignore when I pull)
14
- * Send me a pull request. Bonus points for topic branches.
3
+ build and deploy the java file
4
+
5
+ = install
6
+ gem update --system
7
+ gem install gemcutter
8
+ gem tumble
9
+ gem install -r capistrano-java
10
+
11
+ = deploy.rb sample
12
+ load 'deploy'
13
+ set :gateway, "gateway"
14
+ role :app,"app-server"
15
+ #role :app,*([1,2].map { |n| "app-server#{n}" }) # multi
16
+
17
+ set :application, "application"
18
+
19
+ # DEPLOYMENT SCHEME
20
+ set :scm, :git
21
+ set :deploy_via, :build_copy
22
+ set :repository, "."
23
+
24
+ # LOCAL
25
+ set :build_target_path, "target/sports" # Directory containing generated files after execute build command
26
+ #set :build_target_path, "target/sports.war" # package file
27
+ set :build_command, "make package" #build command
28
+ #set :java_home, "/usr/local/java" #if nil then ENV['JAVA_HOME'] directory
29
+
30
+ # USER / SHELL
31
+ #set :use_sudo, false
32
+
33
+
15
34
 
16
35
  == Copyright
17
36
 
@@ -19,9 +19,6 @@ module Capistrano
19
19
  system(source.checkout(revision, copy_cache))
20
20
  end
21
21
 
22
- logger.debug("start build command")
23
- system(build_command)
24
-
25
22
  logger.debug "copying cache to deployment staging area #{destination}"
26
23
  Dir.chdir(copy_cache) do
27
24
  FileUtils.mkdir_p(destination)
@@ -44,21 +41,31 @@ module Capistrano
44
41
  else
45
42
  logger.debug "getting (via #{copy_strategy}) revision #{revision} to #{destination}"
46
43
  system(command)
47
- logger.debug("start build command")
48
- system(build_command)
49
44
 
50
45
  if copy_exclude.any?
51
46
  logger.debug "processing exclusions..."
52
47
  copy_exclude.each { |pattern| FileUtils.rm_rf(File.join(destination, pattern)) }
53
48
  end
54
49
  end
55
-
50
+ logger.debug("start build command")
51
+ system(build_command)
56
52
  Dir.chdir(tmpdir)
57
- FileUtils.mv(build_target_path,destination_tmp)
58
- FileUtils.rm_rf(destination)
59
- FileUtils.mv(destination_tmp, destination)
53
+ if File.directory? build_target_path
54
+ FileUtils.mv(build_target_path,destination_tmp)
55
+ #Capistrano::CLI.ui.ask('break point')
56
+ FileUtils.rm_rf(destination)
57
+ FileUtils.mv(destination_tmp, destination)
58
+ else
59
+ FileUtils.mkdir_p(destination_tmp)
60
+ FileUtils.cp(build_target_path,File.join(destination_tmp,"/"))
61
+ Dir.chdir(destination_tmp)
62
+ system("#{decompress_package_file(build_target_path).join(" ")}")
63
+ FileUtils.rm(File.join(destination_tmp,File.basename(build_target_path)))
64
+ Dir.chdir(tmpdir)
65
+ FileUtils.rm_rf(destination)
66
+ FileUtils.mv(destination_tmp, destination)
67
+ end
60
68
  File.open(File.join(destination, "REVISION"), "w") { |f| f.puts(revision) }
61
-
62
69
  logger.trace "compressing #{destination} to #{filename} at #{tmpdir}"
63
70
  Dir.chdir(tmpdir) { system(compress(File.basename(destination), File.basename(filename)).join(" ")) }
64
71
 
@@ -90,35 +97,16 @@ module Capistrano
90
97
  end
91
98
 
92
99
  private
100
+
101
+ def java_home
102
+ configuration['java_home'] || ENV['JAVA_HOME']
103
+ end
93
104
 
94
105
  def build_command
95
106
  Dir.chdir("#{destination}")
96
107
  configuration[:build_command] || Capistrano::CLI.ui.ask('build command:')
97
108
  end
98
109
 
99
- #def remove_dir(dir, excludes)
100
- # Find.find(dir) do |path|
101
- # if dir.eql?path
102
- # next
103
- # else
104
- # if File.directory?path
105
- # if excludes.include?path
106
- # Find.prune
107
- # else
108
- # logger.debug(path)
109
- # FileUtils.rm_rf(path)
110
- # Find.prune
111
- # end
112
- # else
113
- # logger.debug(path)
114
- # FileUtils.rm_rf(path)
115
- # Find.prune
116
- # end
117
- # end
118
- # end
119
- #end
120
-
121
-
122
110
  def build_target_path
123
111
  File.join(destination, configuration[:build_target_path])
124
112
  end
@@ -162,6 +150,7 @@ module Capistrano
162
150
  end
163
151
  end
164
152
 
153
+
165
154
  # Returns the name of the file that the source code will be
166
155
  # compressed to.
167
156
  def filename
@@ -187,9 +176,12 @@ module Capistrano
187
176
 
188
177
  # The compression method to use, defaults to :gzip.
189
178
  def compression
190
- configuration[:copy_compression] || :gzip
179
+ @compression ||= configuration[:copy_compression] || :gzip
191
180
  end
192
181
 
182
+ def package_file_compression
183
+ @package_file_compression ||= configuration[:copy_compression] || "#{File.extname(build_target_path)}" || :gzip
184
+ end
193
185
  # Returns the file extension used for the compression method in
194
186
  # question.
195
187
  def compression_extension
@@ -209,6 +201,8 @@ module Capistrano
209
201
  when :gzip, :gz then ["tar", "czf", file, directory]
210
202
  when :bzip2, :bz2 then ["tar", "cjf", file, directory]
211
203
  when :zip then ["zip", "-qr", file, directory]
204
+ when :war then [File.join(java_home,"/bin/jar"), "-cf", file]
205
+ when :jar then [File.join(java_home,"/bin/jar"), "-cf", file]
212
206
  else raise ArgumentError, "invalid compression type #{compression.inspect}"
213
207
  end
214
208
  end
@@ -227,6 +221,17 @@ module Capistrano
227
221
  end
228
222
  end
229
223
 
224
+ def decompress_package_file(file)
225
+ case package_file_compression
226
+ when :gzip, :gz then ["tar", "xzf", file]
227
+ when :bzip2, :bz2 then ["tar", "xjf", file]
228
+ when :zip then ["unzip", "-q", file]
229
+ when ".war" then [File.join(java_home,"/bin/jar"), "-xf", file]
230
+ when ".jar" then [File.join(java_home,"/bin/jar"), "-xf", file]
231
+ else raise ArgumentError, "invalid compression type #{package_file_compression.inspect}"
232
+ end
233
+ end
234
+
230
235
  end
231
236
 
232
237
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-java
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - keebeom kim
@@ -9,20 +9,20 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-09 00:00:00 +09:00
12
+ date: 2009-11-10 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: thoughtbot-shoulda
16
+ name: capistrano
17
17
  type: :development
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: "0"
23
+ version: 2.0.0
24
24
  version:
25
- description: "supports java build file or directory "
25
+ description: "build and deploy the java file "
26
26
  email: badaboda@gmail.com
27
27
  executables: []
28
28