On Sat, Mar 20, 2010 at 2:12 AM, Peter Donald <[email protected]>wrote:

> On Sat, Mar 20, 2010 at 5:51 PM, Antoine Toulme <[email protected]>
> wrote:
> > I would say you call compile.invoke somewhere... anyhow we can't help you
> > without your Buildfile.
>
> Thanks. Found it. Almost all of my projects have a "dist" target that
> basically roles all the generated artifacts into one big zip and I
> have been doing it something like the following. My question is how do
> I change it so that the includes are deferred until the package is
> called on this project rather than as the project file is parsed?
>
>    package(:zip).tap do |zip|
>      prefix = "#{id}-#{version}"
>      zip.include( Buildr.artifacts([PAX_RUNNER]).each(&:invoke),
> :path => "#{prefix}/bin")
>      zip.include( Buildr.artifacts(EQUINOX).each(&:invoke), :path =>
> "#{prefix}/equinox")
>
>      to_deploy = [OSGI_CORE, OSGI_COMPENDIUM, PAX_LOGGING,
> PAX_LOGGING_SERVICE, CONFIG_ADMIN_SERVICE, PAX_CONFMAN] +
>          [BND_ANNOTATIONS, JMS] + projects('link', 'connection',
> 'com.sun.messaging.mq.imq', 'routes')
>
>      zip.include( Buildr.artifacts(to_deploy).each(&:invoke), :path
> => "#{prefix}/lib")
>      zip.include( _('src/main/etc/*'), :path => "#{prefix}")
>    end
>

You need to wire dependencies between tasks.   Instead of calling
task.invoke(), use task.enhance() on the task which depends this task.

package(:zip).tap do |zip|
  prefix = "#{id}-#{version}"

  artifact(PAX_RUNNER).tap do |a|
    zip.enhance a
    zip.include a, :path => "#{prefix}/bin")
  end

  artifact(EQUINOX).tap do |a|
    zip.enhance a
    zip.include a, :path => "#{prefix}/equinox")
  end

  libs = [OSGI_CORE, OSGI_COMPENDIUM, PAX_LOGGING,
          PAX_LOGGING_SERVICE, CONFIG_ADMIN_SERVICE,
          PAX_CONFMAN, BND_ANNOTATIONS, JMS].map { |a| artifact(a) }
  libs += projects('link', 'connection',
                   'com.sun.messaging.mq.imq',
                   'routes').map(&:packages)
  zip.enhance libs
  zip.include libs, :path => "#{prefix}/lib"

  zip.include _('src/main/etc/*'), :path => prefix
end

It wouldn't be a bad idea to have zip.include accept tasks and automatically
wire things up.  I'll look into this later.

Hope this helps... cheers,
alex

Reply via email to