Class: RakeJava::JarTask
- Inherits:
-
Rake::Task
- Object
- Rake::Task
- RakeJava::JarTask
- Includes:
- RakeJavaUtil
- Defined in:
- lib/rakejava.rb
Instance Attribute Summary collapse
-
#files ⇒ Object
Returns the value of attribute files.
-
#main_class ⇒ Object
Returns the value of attribute main_class.
-
#manifest ⇒ Object
Returns the value of attribute manifest.
-
#sign_info ⇒ Object
Returns the value of attribute sign_info.
Instance Method Summary collapse
- #execute(args = nil) ⇒ Object
-
#initialize(name, app) ⇒ JarTask
constructor
A new instance of JarTask.
Methods included from RakeJavaUtil
#path_esc, #path_sep, #popd, #pushd, #pushd_stack, #separate, #space_sep
Constructor Details
#initialize(name, app) ⇒ JarTask
Returns a new instance of JarTask.
203 204 205 206 207 |
# File 'lib/rakejava.rb', line 203 def initialize name, app super @root = "." @files = [] end |
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
201 202 203 |
# File 'lib/rakejava.rb', line 201 def files @files end |
#main_class ⇒ Object
Returns the value of attribute main_class.
201 202 203 |
# File 'lib/rakejava.rb', line 201 def main_class @main_class end |
#manifest ⇒ Object
Returns the value of attribute manifest.
201 202 203 |
# File 'lib/rakejava.rb', line 201 def manifest @manifest end |
#sign_info ⇒ Object
Returns the value of attribute sign_info.
201 202 203 |
# File 'lib/rakejava.rb', line 201 def sign_info @sign_info end |
Instance Method Details
#execute(args = nil) ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/rakejava.rb', line 209 def execute args=nil super flags = "cf" jar = File.(@name) if @main_class unless @manifest @manifest = {} end @manifest["Main-Class"] = @main_class end manifest_path = " " if @manifest flags << "m" if @manifest.kind_of? Hash manifest_path << create_manifest elsif @manifest.kind_of? String manifest_path << File.(@manifest) end end cmd = "jar #{flags} #{@name}#{manifest_path}" @files.each do |file_list| cmd << " -C #{file_list.root} #{space_sep(path_esc(file_list))}" end max_cmd_len = 500 if cmd.length < max_cmd_len puts cmd else puts cmd[0..max_cmd_len] + "..." end puts `#{cmd}` # Now, sign the jar if we're asked to. This only supports the # arguments that I need for my project at the moment. if @sign_info cmd = "jarsigner" cmd << " -storetype #{@sign_info[:store_type]}" cmd << " -keystore #{@sign_info[:key_store]}" cmd << " -storepass #{@sign_info[:store_pass]}" cmd << " #{@name}" cmd << " #{@sign_info[:alias]}" puts cmd puts `#{cmd}` end end |