Rake GemPackageTask Suggestion

T

Trans

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.
 
E

Eric Hodel

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.
 
T

Trans

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.
 
R

Ryan Davis

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.
 
E

Eric Hodel


Scanning 1500 files is your time sink.
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.
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.
 
T

Trans

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.
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.



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

I see. Thanks.

T.
 
R

Roy Wright

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top