How do I get subproject jars into my zip?

42 views Asked by At

I'm trying to make a top-level zip in my buildr buildfile, but the jar files don't seem to end up in the resulting zip.

The project structure has sub-projects:

desc 'Main project'
define 'hex' do
  #... omitting top-level config ...

  desc 'Hex Utilities'
  define 'util' do
    package :jar
  end

  #... omitting other sub-projects, they're all the same ...

  binaries_id = "#{id}-components-#{version}"
  package(:zip, :file => _("target/#{binaries_id}.zip")).path(binaries_id).tap do |path|
    path.include 'COPYING', 'COPYING.LESSER', 'CHANGELOG', 'README.markdown'

    %w{anno binary interpreter util viewer}.each do |proj|
      path.include project(proj).packages
    end
  end
end

I have also tried:

      path.include project(proj).package(:jar)

explicitly selecting only the jar, though it's the only package anyway, and also:

      path.include project(proj).packages.map{|p| "#{p}"}

which maps them to strings, since I noticed all the other path.include lines take strings and suspected that it simply might not work with arrays of package objects, but this doesn't work either. Then my last thought was to just jam in the strings like what I am doing with the rest of the includes:

      path.include "#{proj}/target/hex-#{proj}-#{version}.jar"

But even this doesn't work, so I have no idea how to proceed.

1

There are 1 answers

0
Peter Donald On

I can not seem to reproduce the behaviour. With the most recent release of buildr I created a buildfile that looks like

define 'foo' do
  project.version = '1.0'

  define 'bar' do
    package :jar
  end

  package(:zip, :file => _("somepath.zip")).path('somepath').tap do |path|
    path.include project('bar').packages
  end
end

Run "buildr clean package" and then "unzip -t somepath.zip" produces;

Archive:  somepath.zip
    testing: somepath/                OK
    testing: somepath/foo-bar-1.0.jar   OK
No errors detected in compressed data of somepath.zip.

Which is what I would expect.