Hi,

On Oct 9, 2013, at 4:29 AM, Diggory Hardy <[email protected]> wrote:

> Hello list,
> 
> I'm trying to add some extra operations to tasks. What I'm doing at the 
> moment 
> is:
> 
> define 'myproject' do
>       ...
>       package(:jar).tap to |jar|
>               # do stuff here
>               ...
>       end
> end

This:

package(:jar).tap do |jar|
  jar.stuff
end

Is roughly equivalent to:

jar = package(:jar)
jar.stuff

i.e., the contents of a block provided to `tap` are evaluated immediately, as 
the buildfile is evaluated. 

If you want to add stuff to run after a task executes, use enhance:

package(:jar).enhance do |jar|
  jar.stuff
end

Rhett

> 
> but I notice that these operations happen even when not running the 'package' 
> task — even when I run 'buildr clean'! On the contrary, if I remove the 
> '.tap' 
> bit my code never gets run.
> 
> Actually, that appears to be the case for the 'package' task. Same if I 
> remove 
> the '(:jar)' part. But for the 'compile' task, this works fine (only run when 
> compiling):
> 
> compile do ||
>       # extra stuff...
> end
> 
> So what gives with the 'package' task?

Reply via email to