buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Martin Grotzke <martin.grot...@javakaffee.de>
Subject Re: How to 'fix' bad pom when using transitive()
Date Tue, 03 Mar 2009 09:01:27 GMT
Hi Assaf,

thanx for your valuable tips!

I also updated the wiki ([1]).

Cheers,
Martin


[1] http://cwiki.apache.org/confluence/display/BUILDR/How+to+create+a+non-existent+pom

On Mon, 2009-03-02 at 11:02 -0800, Assaf Arkin wrote:
> On Mon, Mar 2, 2009 at 10:14 AM, Martin Grotzke <
> martin.grotzke@javakaffee.de> wrote:
> 
> > Ok, now I have it like this:
> >
> > artifact 'javax.ejb:ejb:pom:3.0' do |f|
> >  # Create the directory
> >   if(!(File.exist? f.name))
> >    File.makedirs(File.dirname(f.name))
> >    f = File.new(f.name, "w")
> >    f.write("<project>\n"+
> >      "  <modelVersion>4.0.0</modelVersion>\n"+
> >      "  <groupId>javax.ejb</groupId>\n"+
> >      "  <artifactId>ejb</artifactId>\n"+
> >      "  <version>3.0</version>\n"+
> >      "</project>\n")
> >    f.close
> >  end
> > end
> 
> 
> Few tips & tricks:
> 
> 1. You don't need parentheses except when you do (to disambiguate or
> combine). By convention, always use parentheses around function calls.
> 
> 2. Buildr includes FileUtils so you can use its methods, e.g. mkdir_p
> instead of File.makedirs.
> 
> 3. The File.open { block } convention has the added benefit that it closes
> the file when the block ends, whether it finished writing or failed on an
> exception.
> 
> 4. Here docs [1] make the text easier to read next to the code.
> 
> So taking all of these into account:
> 
> artifact 'javax.ejb:ejb:pom:3.0' do |t|
>   # Create the directory
>   if !File.exist?(t.name)
>     mkdir_p File.dirname(t.name)
>     File.open t.name, "w" do |f|
>       f.write <<-XML
> <project>
>  <modelVersion>4.0.0</modelVersion>
>  <groupId>javax.ejb</groupId>
>  <artifactId>ejb</artifactId>
>  <version>3.0</version>
> </project>
>       XML
>     end
>   end
> end
> 
> Assaf
> 
> [1] http://en.wikipedia.org/wiki/Heredoc
> 
> 
> >
> > I added this to the How-Tos:
> >
> > http://cwiki.apache.org/confluence/display/BUILDR/How+to+create+a+non-existent+pom
> >
> > Cheers,
> > Martin
> >
> >
> > On Mon, 2009-03-02 at 02:14 -0800, Assaf Arkin wrote:
> > >
> > > On Mar 2, 2009, at 1:30 AM, Martin Grotzke
> > > <martin.grotzke@javakaffee.de> wrote:
> > >
> > > > Hi Assaf,
> > > >
> > > > thanx for the pointer. Now it looks like this:
> > > >
> > > > artifact 'javax.ejb:ejb:pom:3.0' do |f|
> > > >  # Create the directory first
> > > >  Dir.mkdir(File.dirname(f.name))
> > > >  touch f.name
> > > > end
> > > >
> > > > and there's an empty ejb-3.0.pom at the expected place.
> > > >
> > > > However, now the build fails with this error:
> > > >
> > > > [Failed] Your build failed with an error: /home/grotzke/proj/
> > > > freiheit/mywebapp:
> > > > File does not exist: .
> > > > buildr aborted!
> > > > File does not exist: .
> > > > /usr/lib/ruby/gems/1.8/gems/xml-simple-1.0.11/lib/xmlsimple.rb:
> > > > 977:in `find_xml_file'
> > > > /usr/lib/ruby/gems/1.8/gems/xml-simple-1.0.11/lib/xmlsimple.rb:
> > > > 168:in `xml_in'
> > > > /usr/lib/ruby/gems/1.8/gems/xml-simple-1.0.11/lib/xmlsimple.rb:
> > > > 203:in `xml_in'
> > > > /usr/lib/ruby/gems/1.8/gems/buildr-1.3.3/lib/buildr/java/pom.rb:
> > > > 73:in `initialize'
> > > > /usr/lib/ruby/gems/1.8/gems/buildr-1.3.3/lib/buildr/java/pom.rb:
> > > > 55:in `new'
> > > > /usr/lib/ruby/gems/1.8/gems/buildr-1.3.3/lib/buildr/java/pom.rb:
> > > > 55:in `load'
> > > > /usr/lib/ruby/gems/1.8/gems/buildr-1.3.3/lib/buildr/java/pom.rb:
> > > > 47:in `load'
> > > > /usr/lib/ruby/gems/1.8/gems/buildr-1.3.3/lib/buildr/java/pom.rb:
> > > > 43:in `load'
> > > > /usr/lib/ruby/gems/1.8/gems/buildr-1.3.3/lib/buildr/java/pom.rb:
> > > > 99:in `dependencies'
> > > > /usr/lib/ruby/gems/1.8/gems/buildr-1.3.3/lib/buildr/java/pom.rb:
> > > > 88:in `map'
> > > > /usr/lib/ruby/gems/1.8/gems/buildr-1.3.3/lib/buildr/java/pom.rb:
> > > > 88:in `dependencies'
> > > > /usr/lib/ruby/gems/1.8/gems/buildr-1.3.3/lib/buildr/packaging/
> > > > artifact.rb:654:in `transitive'
> > > > /usr/lib/ruby/gems/1.8/gems/buildr-1.3.3/lib/buildr/java/pom.rb:
> > > > 87:in `inject'
> > > > /usr/lib/ruby/gems/1.8/gems/buildr-1.3.3/lib/buildr/packaging/
> > > > artifact.rb:649:in `each'
> > > > /usr/lib/ruby/gems/1.8/gems/buildr-1.3.3/lib/buildr/packaging/
> > > > artifact.rb:649:in `inject'
> > > > /usr/lib/ruby/gems/1.8/gems/buildr-1.3.3/lib/buildr/packaging/
> > > > artifact.rb:649:in `transitive'
> > > > ./dependencies.rb:35
> > > > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> > > > `gem_original_require'
> > > > /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
> > > >
> > > >
> > > > When I create the pom file with correct content everything's fine.
> > > >
> > > > So, for me as a ruby-nuby: what's the easiest way to create an xml
> > > > file?
> > >
> > >
> > > write "<pom>...</pom>"
> > >
> > > If you need something more generic that can escape characters, quote
> > > attributed and such, use Builder (with an er). Buildr uses it for POM
> > > and IDE files. For simpler cases, strings are easier to use.
> > >
> > > Assaf
> > >
> > >
> > >
> > > >
> > > >
> > > > Thanx && cheers,
> > > > Martin
> > > >
> > > >
> > > >
> > > >
> > > > On Mon, 2009-03-02 at 00:54 -0800, Assaf Arkin wrote:
> > > >> On Mon, Mar 2, 2009 at 12:02 AM, Martin Grotzke <
> > > >> martin.grotzke@javakaffee.de> wrote:
> > > >>
> > > >>> Hi Daniel,
> > > >>>
> > > >>> When I try
> > > >>>
> > > >>> artifact 'javax.ejb:ejb:pom:3.0' do |f|
> > > >>>  touch f
> > > >>
> > > >>
> > > >> touch f.name
> > > >>
> > > >> Assaf
> > > >>
> > > >>
> > > >>>
> > > >>> end
> > > >>>
> > > >>> (as buildr tries to download the pom first)
> > > >>>
> > > >>> I get this error:
> > > >>>
> > > >>> [Failed] Your build failed with an error:
> > > >>> /home/grotzke/proj/freiheit/mywebapp:
> > > >>> undefined method `to_str' for #<Buildr::Artifact:0xb79c31c0>
> > > >>> buildr aborted!
> > > >>> undefined method `to_str' for #<Buildr::Artifact:0xb79c31c0>
> > > >>> /usr/lib/ruby/1.8/fileutils.rb:1388:in `fu_list'
> > > >>> /usr/lib/ruby/1.8/fileutils.rb:1388:in `map'
> > > >>> /usr/lib/ruby/1.8/fileutils.rb:1388:in `fu_list'
> > > >>> /usr/lib/ruby/1.8/fileutils.rb:1019:in `touch'
> > > >>> ./dependencies.rb:25
> > > >>> /home/grotzke/.gem/ruby/1.8/gems/rake-0.8.1/lib/rake.rb:544:in
> > > >>> `call'
> > > >>> /home/grotzke/.gem/ruby/1.8/gems/rake-0.8.1/lib/rake.rb:544:in
> > > >>> `execute'
> > > >>> /home/grotzke/.gem/ruby/1.8/gems/rake-0.8.1/lib/rake.rb:541:in
> > > >>> `each'
> > > >>> /home/grotzke/.gem/ruby/1.8/gems/rake-0.8.1/lib/rake.rb:541:in
> > > >>> `execute'
> > > >>> /usr/lib/ruby/gems/1.8/gems/buildr-1.3.3/lib/buildr/core/
> > > >>> application.rb:482:in
> > > >>> `invoke_with_call_chain'
> > > >>> /usr/lib/ruby/gems/1.8/gems/buildr-1.3.3/lib/buildr/core/
> > > >>> application.rb:468:in
> > > >>> `synchronize'
> > > >>>
> > > >>> Do I have to create the pom.xml with the appropriate content,
or
> > > >>> what does
> > > >>> that mean?
> > > >>>
> > > >>> Thanx && cheers,
> > > >>> Martin
> > > >>>
> > > >>>
> > > >>> On Sun, 2009-03-01 at 17:37 -0600, Daniel Spiewak wrote:
> > > >>>> You could define the artifact task for that particular signature
to
> > > >>>> just create a dummy JAR file.  I forget the syntax, but I
think
> > > >>>> it is
> > > >>>> something like this:
> > > >>>>
> > > >>>> artifact 'javax.ejb:ejb:jar:3.0' do |f|
> > > >>>>   touch f
> > > >>>> end
> > > >>>>
> > > >>>> Daniel
> > > >>>>
> > > >>>> On Mar 1, 2009, at 5:32 PM, Martin Grotzke
> > > >>>> <martin.grotzke@javakaffee.de> wrote:
> > > >>>>
> > > >>>>> Hi,
> > > >>>>>
> > > >>>>> I just want to depend on spring-2.5.6 using transitive().
> > > >>>>>
> > > >>>>> Unfortunately, spring declares a dependency on 'javax.ejb:ejb:jar:
> > > >>>>> 3.0',
> > > >>>>> which seems to be not available in public maven repos.
> > > >>>>>
> > > >>>>> I already tried to do s.th. like this:
> > > >>>>>
> > > >>>>> transitive(SPRING).reject { |a| a.group == 'javax.ejb'
}
> > > >>>>>
> > > >>>>> but unfortunately buildr tries to get the javax.ejb:ejb
pom, so
> > > >>>>> that
> > > >>>>> my
> > > >>>>> build fails with
> > > >>>>>
> > > >>>>> buildr aborted!
> > > >>>>> Failed to download javax.ejb:ejb:pom:3.0
> > > >>>>>
> > > >>>>> Is there a way to fix this issue, e.g. with 'fixing' the
pom
> > > >>>>> when it's
> > > >>>>> loaded via transitive?
> > > >>>>>
> > > >>>>> Thanx && cheers,
> > > >>>>> Martin
> > > >>>>>
> > > >>>>
> > > >>>
> > >
> >

Mime
View raw message