Rake GemPackageTask Suggestion

Hi—

When using the GemPackageTask, one has to build the GemSpec in order
to define the task. For a large project and/or slow machine this
actualy can take a second or so. So everytime I run “rake -T” there’s
a very noticable delay (not to mention wasted CPU cycles). Not sure
what other solutions there might be, but one is to have GemPackageTask
accept the parameters that will build the GemSpec when needed, but not
before. So, instead of

 spec = Gem::Specification.new do |s|
   s.platform = Gem::Platform::RUBY
   s.summary = "Ruby based make-like utility."
   s.name = 'rake'
   s.files = FileList.new('**/*').to_a
   ...
 end

 Rake::GemPackageTask.new(spec) do |pkg|
   pkg.need_zip = true
   pkg.need_tar = true
 end

It could be:

 Rake::GemPackageTask.new do |pkg|
   pkg.platform = 'ruby'
   pkg.summary = "Ruby based make-like utility."
   pkg.name = 'rake'
   pkg.files.include '**/*'
   pkg.need_zip = true
   pkg.need_tar = true
 end

Note the difference in ‘platform’ and more importantly ‘files’. The
GemPackageTask would work those out and build the GemSpec at runtime
rather then definition time.

Thanks,
T.

On Jan 31, 2007, at 24:40, Trans wrote:

When using the GemPackageTask, one has to build the GemSpec in order
to define the task. For a large project and/or slow machine this
actualy can take a second or so.

 spec = Gem::Specification.new do |s|
   s.files = FileList.new('**/*').to_a

How many files do you have?

I solve this by using a Manifest.txt, that way I know exactly what I
want is included, and nothing I don’t:

s.files = File.read(‘Manifest.txt’).split

Plus the check_manifest task from Hoe to make sure everything is up-
to-date.

On Jan 31, 2007, at 2:35 AM, Trans wrote:

Plus the check_manifest task from Hoe to make sure everything is up-
to-date.

What does Hoe do to check the manifest?

The check_manifest task diffs what is on disk against the manifest
and reports the differences, so really Hoe doesn’t check the
manifest, humans do. That is what manifests are for.

On Jan 31, 2007, at 02:35, Trans wrote:

How many files do you have?

1,530

Scanning 1500 files is your time sink.

I solve this by using a Manifest.txt, that way I know exactly what I
want is included, and nothing I don’t:

It’s not an issue of knowing what is included. It is a matter of
efficency.

Its both. Since I have to verify what I’ve added to the Manifest.txt
and check it in, files won’t mysteriously appear in my releases that
shouldn’t have been there.

s.files = File.read(‘Manifest.txt’).split

Plus the check_manifest task from Hoe to make sure everything is up-
to-date.

What does Hoe do to check the manifest?

A Find.find followed by a diff. If you like the changes, you can
pipe it to patch.

On Jan 31, 1:59 pm, Eric H. [email protected] wrote:

   s.files = FileList.new('**/*').to_a

How many files do you have?

1,530

Scanning 1500 files is your time sink.

That is obvious. But not the point. Rake doesn’t need to scan these
files every time rake is run, only when the package task is run --and
that’s what I’m suggesting as an improvement to the task. Clearly the
noticablity of this delay and CPU cycle waste is not largely
discernable to those with small projects and/or faster computers, but
why would that disclude an improvement to Rake’s GempackageTask? That
seems to be what you are suggesting.

s.files = File.read(‘Manifest.txt’).split

Plus the check_manifest task from Hoe to make sure everything is up-
to-date.

What does Hoe do to check the manifest?

A Find.find followed by a diff. If you like the changes, you can
pipe it to patch.

I see. Thanks.

T.

The real problem is that GemPackageTask uses the FileList to create a
list of dependencies which is done prior to parsing and running a task
(line 82):

# File lib/rake/gempackagetask.rb, line 77

77: def define
78: super
79: task :package => [:gem]
80: desc “Build the gem file #{gem_file}”
81: task :gem => ["#{package_dir}/#{gem_file}"]
82: file “#{package_dir}/#{gem_file}” => [package_dir] +
@gem_spec.files do
83: when_writing(“Creating GEM”) {
84: Gem::Builder.new(gem_spec).build
85: verbose(true) {
86: mv gem_file, “#{package_dir}/#{gem_file}”
87: }
88: }
89: end
90: end

So your spec.files is read every time rake is ran.

This also has a side effect that you can not have your :package task
dependent upon any tasks that are responsible for creating files in the
gem_spec.files array, because the files array is read before any other
tasks are ran.

Kind of a bummer as what I’d really like is:

task :package => [:clean, :docs]

Have fun,
Roy

On Jan 31, 4:28 am, Eric H. [email protected] wrote:

On Jan 31, 2007, at 24:40, Trans wrote:

When using the GemPackageTask, one has to build the GemSpec in order
to define the task. For a large project and/or slow machine this
actualy can take a second or so.

 spec = Gem::Specification.new do |s|
   s.files = FileList.new('**/*').to_a

How many files do you have?

1,530

I solve this by using a Manifest.txt, that way I know exactly what I
want is included, and nothing I don’t:

It’s not an issue of knowing what is included. It is a matter of
efficency.

s.files = File.read(‘Manifest.txt’).split

Plus the check_manifest task from Hoe to make sure everything is up-
to-date.

What does Hoe do to check the manifest?

Thanks,
T.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs