# Rake GemPackageTask Suggestion

**URL:** <https://www.ruby-forum.com/t/rake-gempackagetask-suggestion/83989>\
**Category:** Ruby\
**Created:** [January 31, 2007, 11:28am UTC](https://www.ruby-forum.com/t/rake-gempackagetask-suggestion/83989 "2007-01-31T11:28:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [January 31, 2007, 11:28am UTC](https://www.ruby-forum.com/t/rake-gempackagetask-suggestion/83989/1 "2007-01-31T11:28:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [January 31, 2007, 11:44am UTC](https://www.ruby-forum.com/t/rake-gempackagetask-suggestion/83989/2 "2007-01-31T11:44:53Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [September 25, 2007, 11:02pm UTC](https://www.ruby-forum.com/t/rake-gempackagetask-suggestion/83989/3 "2007-09-25T23:02:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [September 25, 2007, 11:05pm UTC](https://www.ruby-forum.com/t/rake-gempackagetask-suggestion/83989/4 "2007-09-25T23:05:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [September 25, 2007, 11:05pm UTC](https://www.ruby-forum.com/t/rake-gempackagetask-suggestion/83989/5 "2007-09-25T23:05:32Z")

</div>

On Jan 31, 1:59 pm, Eric H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [July 23, 2008, 1:43am UTC](https://www.ruby-forum.com/t/rake-gempackagetask-suggestion/83989/6 "2008-07-23T01:43:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Trans](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/dfb087/32.png) [@Trans](https://www.ruby-forum.com/u/Trans)\
**Post date:** [September 25, 2007, 11:07pm UTC](https://www.ruby-forum.com/t/rake-gempackagetask-suggestion/83989/7 "2007-09-25T23:07:20Z")

</div>

On Jan 31, 4:28 am, Eric H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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.
