buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Boisvert <alex.boisv...@gmail.com>
Subject Re: download artifact() not working
Date Fri, 10 Dec 2010 19:36:48 GMT
Hi Rob,

In your code, the unzip task isn't run if the directory already exists, so
you would have to extract to a different directory than "target", such as
"target/mybatis".

In any case, I recommend doing the following which downloads and installs
the artifact in the local repo only if it doesn't already exist:

MYBATIS_SPRING = 'org.mybatis:mybatis-spring:jar:1.0.0-RC3'

# if MyBatis isn't available locally, download and install it in local
repository
artifact(MYBATIS_SPRING).enhance do |mybatis|
  unless File.exist? mybatis.to_s
    url = '
http://mybatis.googlecode.com/files/mybatis-spring-1.0.0-RC3-bundle.zip'
    zip = 'target/mybatis-spring-bundle.zip'
    download(zip => url).invoke()
    unzip('target/mybatis' => zip).extract()
    jar = Dir["target/mybatis/**//mybatis-spring-*.jar"].first
    mkpath File.dirname(mybatis.to_s)
    cp jar, mybatis.to_s
  end
end

BTW, I ran into an issue unzipping mybatis-spring-1.0.0-RC3-bundle.zip.  The
zip archive appears to be invalid (at least to Rubyzip) and I get a
"TypeError : can't dup NilClass" error during the unzip.  Looking inside the
zip archive, the directories seem to have an invalid file permission
attribute.  I wish rubyzip would handle that but at least on my system, it
breaks. A similar situation has been reported before:
http://www.ruby-forum.com/topic/211146

You can fix this locally by adding the following to your buildfile:

# Make rubyzip more tolerant to invalid zip entries
module Zip
  class ZipEntrySet
    def <<(entry)
      @entrySet[entry.to_s] = entry unless entry.nil?
    end
  end
end

Hope this gets you going.   I'll be updating the website to correct the
misleading information.

cheers,
alex

On Fri, Dec 10, 2010 at 8:04 AM, Rob van Oostrum <rvanoo@gmail.com> wrote:

> So now following instructions found here:
> http://buildr.apache.org/artifacts.html
>
>  MYBATIS_SPRING = 'org.mybatis:mybatis-spring:jar:1.0.0-RC3'
>
>   mybatis_spring_url =
> 'http://mybatis.googlecode.com/files/mybatis-spring-1.0.0-RC3-bundle.zip'
>  mybatis_spring_zip =
> download('target/mybatis-spring-bundle.zip'=>mybatis_spring_url)
>  mybatis_spring_jar =
>
> file('target/mybatis-spring-bundle/mybatis-spring-1.0.0-RC3.jar'=>unzip('target'=>mybatis_spring_zip))
>
>  mybatis_spring_artifact =
> artifact(MYBATIS_SPRING).from(mybatis_spring_jar)
>
> For some reason, the unzip portion isn't firing. It download the ZIP
> file, apparently skips the unzip. and fails on the JAR file not being
> found.
>
> Any help would be greatly appreciated.
>
> -Rob
>
> On Thu, Dec 9, 2010 at 7:38 PM, Rob van Oostrum <rvanoo@gmail.com> wrote:
> > From here: http://buildr.apache.org/quick_start.html#dependencies
> >
> > "Almost magically, we can instruct Buildr to get the DBPool artifact
> > from this URL. Buildr will treat this download just like any other
> > artifact, retrieving it when requried by the compile task. However,
> > unlike a normal Maven artifact, Buildr will do some extra processing
> > once the download is complete. It will actually dig into the
> > downloaded archive, detect and extract the JAR file, installing it
> > into the local repository just like any other artifact:
> >
> > DBPOOL = 'net.snaq:dbpool:jar:4.8.3'
> > download artifact(DBPOOL) => '
> http://www.snaq.net/java/DBPool/DBPool_v4.8.3.zip'
> >
> > define 'killer-app' do
> >  project.version '0.1.0'
> >  compile.with DBPool
> >  package :jar
> > end"
> >
> > Is that not accurate? The documented behaviour is that Buildr is smart
> > enough to know that I'm looking for a JAR artifact, but downloading a
> > ZIP file, and so the JAR file must be somewhere inside the ZIP file.
> > If that is still correct, this functionality appears to be broken.
> >
> > - Rob
> >
> > On Thu, Dec 9, 2010 at 5:50 PM, Antoine Toulme <antoine@lunar-ocean.com>
> wrote:
> >>
> >> You downloaded a web resource and forced the extension by using jar in
> the artifact definition.
> >>
> >> You didn't ask Buildr to unzip it. That is done with a different set of
> instructions (see unzip).
> >>
> >> Antoine
> >>
> >>
> >> On Dec 10, 2010, at 5:56 AM, Rob van Oostrum wrote:
> >>
> >> > Following the Quick Start doc, I added the following dependency to my
> >> > project:
> >> >
> >> > MYBATIS_SPRING = 'org.mybatis:mybatis-spring:jar:1.0.0-RC3'
> >> > download artifact(MYBATIS_SPRING) => '
> >> >
> http://mybatis.googlecode.com/files/mybatis-spring-1.0.0-RC3-bundle.zip'
> >> >
> >> > The zip file contains the JAR file I'm really interested in:
> >> > mybatis-spring-1.0.0-RC3.jar
> >> >
> >> > My problem is when I use MYBATIS_SPRING as a compile dependency,
> buildr
> >> > downloads the ZIP file and renames it to .jar rather than unpacking it
> and
> >> > using the JAR file like the documentation suggests it should:
> >> >
> >> > compile.with COMMONS_LOGGING, MYBATIS_SPRING
> >> >
> >> > ** Execute
> >> >
> /Users/rob/.m2/repository/org/mybatis/mybatis-spring/1.0.0-RC3/mybatis-spring-1.0.0-RC3.jar
> >> > Requesting
> >> >
> http://mybatis.googlecode.com/files/mybatis-spring-1.0.0-RC3-bundle.zip
> >> > Downloading
> >> >
> http://mybatis.googlecode.com/files/mybatis-spring-1.0.0-RC3-bundle.zip
> >> >
> /Library/Ruby/Gems/1.8/gems/highline-1.5.1/lib/highline/system_extensions.rb:188:
> >> > warning: Insecure world writable dir /Users/rob/tools/maven/bin in
> PATH,
> >> > mode 040777
> >> > mybatis-spring-1.0.0-RC3-bundle.zip: 100%
> >> >
> |...............................................................................................................................|
> >> >   3.1MB/3.1MB Time: 00:00:03
> >> > mkdir -p
> /Users/rob/.m2/repository/org/mybatis/mybatis-spring/1.0.0-RC3
> >> > mv
> >> >
> /var/folders/Sv/SvE0dCbIF+GyXqj5nB3zLU+++TI/-Tmp-/mybatis-spring-1.0.0-RC3.jar20101209-12400-fw4rwz-0
> >> >
> /Users/rob/.m2/repository/org/mybatis/mybatis-spring/1.0.0-RC3/mybatis-spring-1.0.0-RC3.jar
> >> >
> >> > rob$ jar tvf
> >> >
> ~/.m2/repository/org/mybatis/mybatis-spring/1.0.0-RC3/mybatis-spring-1.0.0-RC3.jar
> >> >
> >> >    0 Mon Nov 22 19:02:02 EST 2010 mybatis-spring-1.0.0-RC3/
> >> >    0 Mon Nov 22 19:02:02 EST 2010 mybatis-spring-1.0.0-RC3/lib/
> >> > 627106 Thu Nov 18 20:18:14 EST 2010
> >> > mybatis-spring-1.0.0-RC3/lib/mybatis-3.0.3.jar
> >> > 382442 Thu Oct 21 21:35:58 EDT 2010
> >> > mybatis-spring-1.0.0-RC3/lib/spring-core-3.0.5.RELEASE.jar
> >> > 60686 Thu Apr 16 15:01:52 EDT 2009
> >> > mybatis-spring-1.0.0-RC3/lib/commons-logging-1.1.1.jar
> >> > 231922 Thu Oct 21 21:35:32 EDT 2010
> >> > mybatis-spring-1.0.0-RC3/lib/spring-tx-3.0.5.RELEASE.jar
> >> > 555410 Thu Oct 21 21:36:06 EDT 2010
> >> > mybatis-spring-1.0.0-RC3/lib/spring-beans-3.0.5.RELEASE.jar
> >> > 668861 Thu Oct 21 21:36:04 EDT 2010
> >> > mybatis-spring-1.0.0-RC3/lib/spring-context-3.0.5.RELEASE.jar
> >> > 169752 Thu Oct 21 21:36:02 EDT 2010
> >> > mybatis-spring-1.0.0-RC3/lib/spring-expression-3.0.5.RELEASE.jar
> >> > 53082 Thu Oct 21 21:36:02 EDT 2010
> >> > mybatis-spring-1.0.0-RC3/lib/spring-asm-3.0.5.RELEASE.jar
> >> > 385712 Thu Oct 21 21:35:58 EDT 2010
> >> > mybatis-spring-1.0.0-RC3/lib/spring-jdbc-3.0.5.RELEASE.jar
> >> > 321190 Thu Oct 21 21:35:54 EDT 2010
> >> > mybatis-spring-1.0.0-RC3/lib/spring-aop-3.0.5.RELEASE.jar
> >> > 4467 Fri Jan 29 21:19:58 EST 2010
> >> > mybatis-spring-1.0.0-RC3/lib/aopalliance-1.0.jar
> >> > * 31937 Mon Nov 22 18:59:46 EST 2010
> >> > mybatis-spring-1.0.0-RC3/mybatis-spring-1.0.0-RC3.jar*
> >> > 99344 Mon Nov 22 18:59:50 EST 2010
> >> > mybatis-spring-1.0.0-RC3/mybatis-spring-1.0.0-RC3-javadoc.jar
> >> > 30499 Mon Nov 22 18:59:46 EST 2010
> >> > mybatis-spring-1.0.0-RC3/mybatis-spring-1.0.0-RC3-sources.jar
> >> > 44469 Mon Nov 22 19:01:58 EST 2010
> >> > mybatis-spring-1.0.0-RC3/mybatis-spring-1.0.0-RC3-reference.pdf
> >> > 11358 Mon Nov 22 18:59:36 EST 2010 mybatis-spring-1.0.0-RC3/LICENSE
> >> > 1429 Mon Nov 22 18:59:36 EST 2010 mybatis-spring-1.0.0-RC3/NOTICE
> >> >
> >> >
> >> > Am I missing something here?
> >> >
> >> > I'm using Buildr 1.4.4 on Mac OS FWIW.
> >> >
> >> > Thanks
> >> > Rob
> >>
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message