1
# Define a package task library to aid in the definition of GEM
1
# rake/gempackagetask is deprecated in favor of rubygems/package_task
3
warn 'rake/gempackagetask is deprecated. Use rubygems/package_task instead'
6
require 'rubygems/package_task'
6
require 'rake/packagetask'
7
require 'rubygems/user_interaction'
8
require 'rubygems/builder'
12
# Create a package based upon a Gem spec. Gem packages, as well as
13
# zip files and tar/gzipped packages can be produced by this task.
15
# In addition to the Rake targets generated by PackageTask, a
16
# GemPackageTask will also generate the following tasks:
18
# [<b>"<em>package_dir</em>/<em>name</em>-<em>version</em>.gem"</b>]
19
# Create a Ruby GEM package with the given name and version.
21
# Example using a Ruby GEM spec:
25
# spec = Gem::Specification.new do |s|
26
# s.platform = Gem::Platform::RUBY
27
# s.summary = "Ruby based make-like utility."
29
# s.version = PKG_VERSION
30
# s.requirements << 'none'
31
# s.require_path = 'lib'
32
# s.autorequire = 'rake'
34
# s.description = <<EOF
35
# Rake is a Make-like program implemented in Ruby. Tasks
36
# and dependencies are specified in standard Ruby syntax.
40
# Rake::GemPackageTask.new(spec) do |pkg|
45
class GemPackageTask < PackageTask
46
# Ruby GEM spec containing the metadata for this package. The
47
# name, version and package_files are automatically determined
48
# from the GEM spec and don't need to be explicitly provided.
49
attr_accessor :gem_spec
51
# Create a GEM Package task library. Automatically define the gem
52
# if a block is given. If no block is supplied, then +define+
53
# needs to be called to define the task.
54
def initialize(gem_spec)
56
yield self if block_given?
57
define if block_given?
60
# Initialization tasks without the "yield self" or define
63
super(gem.name, gem.version)
65
@package_files += gem_spec.files if gem_spec.files
68
# Create the Rake tasks and actions specified by this
69
# GemPackageTask. (+define+ is automatically called if a block is
73
task :package => [:gem]
74
desc "Build the gem file #{gem_file}"
75
task :gem => ["#{package_dir}/#{gem_file}"]
76
file "#{package_dir}/#{gem_file}" => [package_dir] + @gem_spec.files do
77
when_writing("Creating GEM") {
78
Gem::Builder.new(gem_spec).build
80
mv gem_file, "#{package_dir}/#{gem_file}"
87
if @gem_spec.platform == Gem::Platform::RUBY
90
"#{package_name}-#{@gem_spec.platform}.gem"
13
GemPackageTask = Gem::PackageTask