Bundler's rake tasks define no dependencies between eachother or any required files #2121

Closed
postmodern opened this Issue Oct 15, 2012 · 12 comments

Projects

None yet

4 participants

@postmodern
Contributor

Bundler appears to only use rake as an invocation mechanism for Bundler's internal gem building/releasing methods. The rake tasks lack proper dependencies between each other, and the files which they require. This prevents other rake tasks from hooking into Bundler's release process. For example, md2man needs to generate man-pages before Bundler creates a gem containing all files listed in the gemspec.

Bundler::GemHelper should either be rewritten to properly utilize Rake, or Bundler should consider deprecating it's Rake tasks in favour of an agnostic/lightweight set of Rake tasks; such as rubygems-tasks, mg or gem-release.

@indirect
Member

Uh. Hmm. So the reason that we refer to the Bundler tasks instead of directly outputting them into a generated gem's Rakefile is so that we can update and fix the tasks automatically for anyone who uses them. As for "proper dependencies", it does look like we should change the release and install tasks to depend on the build task. Is there other stuff that I'm missing there to make it "properly utilize Rake"?

@postmodern
Contributor

@indirect sorry if I wasn't clear. By "properly utilize Rake" I mean Bundler should make use of file and directory tasks, as well as define dependencies between the tasks/files. Generating the Rakefile with the tasks inlined would be silly :)

@indirect
Member

Sounds like a great improvement to me. I'll add that to my Bundler list, and note that we are open to pull requests implementing said changes. :)

On Oct 16, 2012, at 12:38 AM, Postmodern notifications@github.com wrote:

@indirect sorry if I wasn't clear. By "properly utilizing Rake" I mean Bundler should make use of file and directory tasks, as well as define dependencies between the tasks/files. Generating the Rakefile with the tasks inlined would be silly :)


Reply to this email directly or view it on GitHub.

@postmodern
Contributor

The first step would be to decouple the build_gem method from install_gem. Both install_gem and release_gem depend on the return value of build_gem. Then the install / release tasks can depend on build, and have the gem only built once.

@lwoggardner

Would a simple implementation be to have :build, :install and :release all depend on a no-op :pre-build task?

@indirect
Member
indirect commented Dec 7, 2012

@lwoggardner it's trivial to add your own pre-build task. Simply put a line like this in your Rakefile:

task :before_build { p "pre-build task" }
task :build => :before_build

No need for a patch to Bundler.

@indirect indirect closed this Dec 7, 2012
@lwoggardner

no, we have to do

task :before_build { p "pre-build task" }
task :build => :before_build
task :install => :before_build
task :release => :before_build

which is counterintuitive, since we expect :install and :release to already be dependant on :build

I was just suggesting that embedding this in bundler might be easier that actually making install_gem dependent on build_gem

@indirect
Member
indirect commented Dec 7, 2012

Ahhh, I understand. Yes, install and release will become dependent on build. The tasks will also be changed to use Rubygems' actual API to build gems, instead of shelling out to them.

@postmodern
Contributor

Also, the tasks should define a file tasks for the .gem file.

In the meantime, I encourage users of Bundler to use proper Rake tasks for building/releasing gems, such as rubygems-tasks or mg.

Gemfile

gem 'rubygems-tasks'

Rakefile

require 'rake'
require 'rubygems/tasks'
Gem::Tasks.new
@sunaku
Contributor
sunaku commented Dec 11, 2012

Please reopen this issue because it's still unresolved. 😓

@indirect indirect reopened this Dec 11, 2012
@sunaku
Contributor
sunaku commented Feb 23, 2013

I submitted a patch for this issue in pull request #2328.

@sunaku sunaku added a commit to sunaku/bundler that referenced this issue Feb 23, 2013
@sunaku sunaku make 'install' and 'build' tasks depend on 'build'
This patch attempts to fix issue #2121 in Bundler.
dcbbef7
@indirect indirect added a commit that referenced this issue Mar 3, 2013
@sunaku @indirect sunaku + indirect make 'install' and 'build' tasks depend on 'build'
This patch attempts to fix issue #2121 in Bundler.
71e14bc
@sunaku
Contributor
sunaku commented Mar 7, 2013

My pull request #2328 has been merged. We can close this issue now. 👮

@postmodern postmodern closed this Mar 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment