| Class | Raven::GemWrapTask |
| In: |
lib/raven/java_tasks.rb
|
| Parent: | Rake::Task |
Wraps a jar file around a Gem. Useful for distributing it around. The jar is taken from the target directory. You must at least specify version to produce the Gem. The artifact name and group name default to the current directory name and its parent directory name respectively. Convenient if you follow the classic project/module directory structure. Otherwise, just set the artifact and project to any value that suits you.
| artifact | [W] | |
| project | [W] | |
| version | [W] |
# File lib/raven/java_tasks.rb, line 302
302: def execute
303: super
304: puts "Wrapping jar in a Gem" if RakeFileUtils.verbose_flag
305: unless @version
306: puts "A version must be provided to produce a Gem!"
307: end
308: pwd = Dir.pwd
309: @artifact = pwd[(pwd.rindex('/') + 1)..pwd.length] unless @artifact
310: pwd = pwd[0..pwd.rindex('/') - 1]
311: @group = pwd[(pwd.rindex('/') + 1)..pwd.length] unless @group
312: Raven.mkdir_recurse('target/gem/ext')
313: FileUtils.cp(Dir.glob('target/*.jar'), 'target/gem/ext')
314:
315: Dir.chdir('target/gem') do
316: spec = Gem::Specification.new do |s|
317: s.platform = Gem::Platform::JAVA
318: s.summary = "Raven wrapped library #{@artifact} from project #{@group}."
319: s.name = "#{@group}-#{@artifact}"
320: s.version = @version
321: s.requirements << 'none'
322: s.require_path = 'ext'
323: s.autorequire = 'rake'
324: s.files = Dir.glob("{ext}/**/*")
325: end
326: Gem::Builder.new(spec).build
327: end
328: FileUtils.mv("target/gem/#{@group}-#{@artifact}-#{@version}-java.gem", 'target')
329: end