You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Khristian <de...@gmail.com> on 2012/03/08 18:36:32 UTC

Reading POM files

I'm trying to read an existing Maven 2 POM file in an application I'm
developing. For this, I tried to use Buildr in the following ways:

----------------------
require 'rubygems'
require 'buildr'

path="F:/project/pom.xml"

# POM.load:
pom=Buildr::POM.load(path)

# Generate:
Buildr::Generate::from_maven2_pom(path)
-----------------------
Both ways fail in the same way (from pom.rb:52):
>jruby  pom.rb
TypeError: can't convert nil into String
      expand_path at org/jruby/RubyFile.java:1100
        buildfile at
c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:171
        load_from at
c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:108
             user at
c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:76
            local at
c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:594
           locate at
c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:622
         artifact at
c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:758
             load at
c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:39
       initialize at
c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:74
             load at
c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:52
  from_maven2_pom at
c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/generate.rb:95
           (root) at pom.rb:7

I am using Buildr 1.4.6 (JRuby 1.6.5.1).

Any idea what might be happening/being done wrong?

Thanks,
-- 
Khristian Alexander Schönrock

Re: Reading POM files

Posted by Khristian <de...@gmail.com>.
I did use Buildr::POM.load(path) before, but had the same errors.
After these tests, I found out that the M2_REPO var not being defined
was causing the error in this case.

Now it works like a charm! Thanks!

On Thu, Mar 8, 2012 at 4:38 PM, Antoine Toulme <an...@lunar-ocean.com> wrote:
> If you look up pom.rb, its method POM.load does the heavy lifting.
>
> Then see the methods on the POM class to access dependencies, properties and
> whatnot.
>
> Best of luck!
>
> Antoine
>
>
> On Thu, Mar 8, 2012 at 11:30, Khristian <de...@gmail.com> wrote:
>>
>> Hi Antoine,
>> thanks for the tips, it's close to what I'm trying to do. I'm trying
>> to parse the POM file to get dependencies, artifact names and other
>> stuff to use in an application that is not primarily maven-related
>> (for acessing Jira info, for example).
>>
>> As for going through buildr's guts, calling
>> "Buildr::Generate::from_maven2_pom(path)" was my best idea so far =/
>> Could you direct me to a more fruitful strategy?
>>
>> Thanks a lot,
>>
>>
>> On Thu, Mar 8, 2012 at 4:19 PM, Antoine Toulme <an...@lunar-ocean.com>
>> wrote:
>> > That clears things up for me a bit, so here is some general advice I
>> > hope
>> > can help:
>> >
>> > You cannot use buildr without a Buildfile - except if you use the buildr
>> > task to generate one.
>> > Buildr has a builtin task to create a Buildfile from a pom.xml file,
>> > just
>> > go buildr -T for more information.
>> > You cannot use buildr within a ruby script. Buildr is packaged as an
>> > application and expects to behave in that setting.
>> >
>> > If you are interested in using a specific functionality of Buildr, like
>> > reading pom files, you probably will have to fork or require some of the
>> > buildr ruby files individually.
>> >
>> > On Thu, Mar 8, 2012 at 11:13, Khristian <de...@gmail.com> wrote:
>> >
>> >> After some more code inspecting, I found that the "rakefile" var used
>> >> in the "application.rb->Application->buildfile" is nil, but I couldn't
>> >> figure out where it comes from.
>> >> The method:
>> >>
>> >> https://github.com/apache/buildr/blob/1.4.6/lib/buildr/core/application.rb#L167
>> >> The POM file is very basic: http://pastie.org/3550371
>> >>
>> >> Any suggestions?
>> >>
>> >> On Thu, Mar 8, 2012 at 3:46 PM, Khristian <de...@gmail.com> wrote:
>> >> > After testing with different path formats (single-quoted,
>> >> > double-quoted, with forward slashes and backslashes), I noticed that
>> >> > File.expand_path always expands the path to "F:/project/pom.xml".
>> >> >
>> >> > It seems the error has something to do with my local maven
>> >> > configuration (M2_REPO, etc), based on the stacktrace. After setting
>> >> > the M2_REPO environment variable, the stacktrace changed, but not the
>> >> > final exception. I will investigate further and post results later.
>> >> > Thanks for the help so far!
>> >> >
>> >> > On Thu, Mar 8, 2012 at 3:12 PM, Antoine Toulme
>> >> > <an...@lunar-ocean.com>
>> >> wrote:
>> >> >> I think the path you pass along is invalid.
>> >> >>
>> >> >> The path in Windows is expected to use backticks,
>> >> >> F:\project\pom.xml.
>> >> >>
>> >> >> jruby, trying to read this path, fails in the expand_path method.
>> >> >>
>> >> >> That's all I can tell at first sight (and without a Windows
>> >> >> machine).
>> >> >>
>> >> >> You can try to read the JRuby source code for that method to find
>> >> >> out
>> >> more.
>> >> >>
>> >>
>> >> https://github.com/jruby/jruby/blob/1.6.5.1/src/org/jruby/RubyFile.java#L1100
>> >> >>
>> >> >> On Thu, Mar 8, 2012 at 09:36, Khristian <de...@gmail.com> wrote:
>> >> >>
>> >> >>> I'm trying to read an existing Maven 2 POM file in an application
>> >> >>> I'm
>> >> >>> developing. For this, I tried to use Buildr in the following ways:
>> >> >>>
>> >> >>> ----------------------
>> >> >>> require 'rubygems'
>> >> >>> require 'buildr'
>> >> >>>
>> >> >>> path="F:/project/pom.xml"
>> >> >>>
>> >> >>> # POM.load:
>> >> >>> pom=Buildr::POM.load(path)
>> >> >>>
>> >> >>> # Generate:
>> >> >>> Buildr::Generate::from_maven2_pom(path)
>> >> >>> -----------------------
>> >> >>> Both ways fail in the same way (from pom.rb:52):
>> >> >>> >jruby  pom.rb
>> >> >>> TypeError: can't convert nil into String
>> >> >>>      expand_path at org/jruby/RubyFile.java:1100
>> >> >>>        buildfile at
>> >> >>>
>> >> >>>
>> >>
>> >> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:171
>> >> >>>        load_from at
>> >> >>>
>> >> >>>
>> >>
>> >> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:108
>> >> >>>             user at
>> >> >>>
>> >> >>>
>> >>
>> >> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:76
>> >> >>>            local at
>> >> >>>
>> >> >>>
>> >>
>> >> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:594
>> >> >>>           locate at
>> >> >>>
>> >> >>>
>> >>
>> >> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:622
>> >> >>>         artifact at
>> >> >>>
>> >> >>>
>> >>
>> >> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:758
>> >> >>>             load at
>> >> >>>
>> >> >>>
>> >>
>> >> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:39
>> >> >>>       initialize at
>> >> >>>
>> >> >>>
>> >>
>> >> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:74
>> >> >>>             load at
>> >> >>>
>> >> >>>
>> >>
>> >> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:52
>> >> >>>  from_maven2_pom at
>> >> >>>
>> >> >>>
>> >>
>> >> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/generate.rb:95
>> >> >>>           (root) at pom.rb:7
>> >> >>>
>> >> >>> I am using Buildr 1.4.6 (JRuby 1.6.5.1).
>> >> >>>
>> >> >>> Any idea what might be happening/being done wrong?
>> >> >>>
>> >> >>> Thanks,
>> >> >>> --
>> >> >>> Khristian Alexander Schönrock
>> >> >>>
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Khristian Alexander Schönrock
>> >> > http://derkosak.blogspot.com - Meu blógue!
>> >>
>> >>
>> >>
>> >> --
>> >> Khristian Alexander Schönrock
>> >>
>>
>>
>>
>> --
>> Khristian Alexander Schönrock
>
>
-- 
Khristian Alexander Schönrock

Re: Reading POM files

Posted by Antoine Toulme <an...@lunar-ocean.com>.
If you look up pom.rb, its method POM.load does the heavy lifting.

Then see the methods on the POM class to access dependencies, properties
and whatnot.

Best of luck!

Antoine

On Thu, Mar 8, 2012 at 11:30, Khristian <de...@gmail.com> wrote:

> Hi Antoine,
> thanks for the tips, it's close to what I'm trying to do. I'm trying
> to parse the POM file to get dependencies, artifact names and other
> stuff to use in an application that is not primarily maven-related
> (for acessing Jira info, for example).
>
> As for going through buildr's guts, calling
> "Buildr::Generate::from_maven2_pom(path)" was my best idea so far =/
> Could you direct me to a more fruitful strategy?
>
> Thanks a lot,
>
>
> On Thu, Mar 8, 2012 at 4:19 PM, Antoine Toulme <an...@lunar-ocean.com>
> wrote:
> > That clears things up for me a bit, so here is some general advice I hope
> > can help:
> >
> > You cannot use buildr without a Buildfile - except if you use the buildr
> > task to generate one.
> > Buildr has a builtin task to create a Buildfile from a pom.xml file, just
> > go buildr -T for more information.
> > You cannot use buildr within a ruby script. Buildr is packaged as an
> > application and expects to behave in that setting.
> >
> > If you are interested in using a specific functionality of Buildr, like
> > reading pom files, you probably will have to fork or require some of the
> > buildr ruby files individually.
> >
> > On Thu, Mar 8, 2012 at 11:13, Khristian <de...@gmail.com> wrote:
> >
> >> After some more code inspecting, I found that the "rakefile" var used
> >> in the "application.rb->Application->buildfile" is nil, but I couldn't
> >> figure out where it comes from.
> >> The method:
> >>
> https://github.com/apache/buildr/blob/1.4.6/lib/buildr/core/application.rb#L167
> >> The POM file is very basic: http://pastie.org/3550371
> >>
> >> Any suggestions?
> >>
> >> On Thu, Mar 8, 2012 at 3:46 PM, Khristian <de...@gmail.com> wrote:
> >> > After testing with different path formats (single-quoted,
> >> > double-quoted, with forward slashes and backslashes), I noticed that
> >> > File.expand_path always expands the path to "F:/project/pom.xml".
> >> >
> >> > It seems the error has something to do with my local maven
> >> > configuration (M2_REPO, etc), based on the stacktrace. After setting
> >> > the M2_REPO environment variable, the stacktrace changed, but not the
> >> > final exception. I will investigate further and post results later.
> >> > Thanks for the help so far!
> >> >
> >> > On Thu, Mar 8, 2012 at 3:12 PM, Antoine Toulme <
> antoine@lunar-ocean.com>
> >> wrote:
> >> >> I think the path you pass along is invalid.
> >> >>
> >> >> The path in Windows is expected to use backticks, F:\project\pom.xml.
> >> >>
> >> >> jruby, trying to read this path, fails in the expand_path method.
> >> >>
> >> >> That's all I can tell at first sight (and without a Windows machine).
> >> >>
> >> >> You can try to read the JRuby source code for that method to find out
> >> more.
> >> >>
> >>
> https://github.com/jruby/jruby/blob/1.6.5.1/src/org/jruby/RubyFile.java#L1100
> >> >>
> >> >> On Thu, Mar 8, 2012 at 09:36, Khristian <de...@gmail.com> wrote:
> >> >>
> >> >>> I'm trying to read an existing Maven 2 POM file in an application
> I'm
> >> >>> developing. For this, I tried to use Buildr in the following ways:
> >> >>>
> >> >>> ----------------------
> >> >>> require 'rubygems'
> >> >>> require 'buildr'
> >> >>>
> >> >>> path="F:/project/pom.xml"
> >> >>>
> >> >>> # POM.load:
> >> >>> pom=Buildr::POM.load(path)
> >> >>>
> >> >>> # Generate:
> >> >>> Buildr::Generate::from_maven2_pom(path)
> >> >>> -----------------------
> >> >>> Both ways fail in the same way (from pom.rb:52):
> >> >>> >jruby  pom.rb
> >> >>> TypeError: can't convert nil into String
> >> >>>      expand_path at org/jruby/RubyFile.java:1100
> >> >>>        buildfile at
> >> >>>
> >> >>>
> >>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:171
> >> >>>        load_from at
> >> >>>
> >> >>>
> >>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:108
> >> >>>             user at
> >> >>>
> >> >>>
> >>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:76
> >> >>>            local at
> >> >>>
> >> >>>
> >>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:594
> >> >>>           locate at
> >> >>>
> >> >>>
> >>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:622
> >> >>>         artifact at
> >> >>>
> >> >>>
> >>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:758
> >> >>>             load at
> >> >>>
> >> >>>
> >>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:39
> >> >>>       initialize at
> >> >>>
> >> >>>
> >>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:74
> >> >>>             load at
> >> >>>
> >> >>>
> >>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:52
> >> >>>  from_maven2_pom at
> >> >>>
> >> >>>
> >>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/generate.rb:95
> >> >>>           (root) at pom.rb:7
> >> >>>
> >> >>> I am using Buildr 1.4.6 (JRuby 1.6.5.1).
> >> >>>
> >> >>> Any idea what might be happening/being done wrong?
> >> >>>
> >> >>> Thanks,
> >> >>> --
> >> >>> Khristian Alexander Schönrock
> >> >>>
> >> >
> >> >
> >> >
> >> > --
> >> > Khristian Alexander Schönrock
> >> > http://derkosak.blogspot.com - Meu blógue!
> >>
> >>
> >>
> >> --
> >> Khristian Alexander Schönrock
> >>
>
>
>
> --
> Khristian Alexander Schönrock
>

Re: Reading POM files

Posted by Khristian <de...@gmail.com>.
Hi Antoine,
thanks for the tips, it's close to what I'm trying to do. I'm trying
to parse the POM file to get dependencies, artifact names and other
stuff to use in an application that is not primarily maven-related
(for acessing Jira info, for example).

As for going through buildr's guts, calling
"Buildr::Generate::from_maven2_pom(path)" was my best idea so far =/
Could you direct me to a more fruitful strategy?

Thanks a lot,


On Thu, Mar 8, 2012 at 4:19 PM, Antoine Toulme <an...@lunar-ocean.com> wrote:
> That clears things up for me a bit, so here is some general advice I hope
> can help:
>
> You cannot use buildr without a Buildfile - except if you use the buildr
> task to generate one.
> Buildr has a builtin task to create a Buildfile from a pom.xml file, just
> go buildr -T for more information.
> You cannot use buildr within a ruby script. Buildr is packaged as an
> application and expects to behave in that setting.
>
> If you are interested in using a specific functionality of Buildr, like
> reading pom files, you probably will have to fork or require some of the
> buildr ruby files individually.
>
> On Thu, Mar 8, 2012 at 11:13, Khristian <de...@gmail.com> wrote:
>
>> After some more code inspecting, I found that the "rakefile" var used
>> in the "application.rb->Application->buildfile" is nil, but I couldn't
>> figure out where it comes from.
>> The method:
>> https://github.com/apache/buildr/blob/1.4.6/lib/buildr/core/application.rb#L167
>> The POM file is very basic: http://pastie.org/3550371
>>
>> Any suggestions?
>>
>> On Thu, Mar 8, 2012 at 3:46 PM, Khristian <de...@gmail.com> wrote:
>> > After testing with different path formats (single-quoted,
>> > double-quoted, with forward slashes and backslashes), I noticed that
>> > File.expand_path always expands the path to "F:/project/pom.xml".
>> >
>> > It seems the error has something to do with my local maven
>> > configuration (M2_REPO, etc), based on the stacktrace. After setting
>> > the M2_REPO environment variable, the stacktrace changed, but not the
>> > final exception. I will investigate further and post results later.
>> > Thanks for the help so far!
>> >
>> > On Thu, Mar 8, 2012 at 3:12 PM, Antoine Toulme <an...@lunar-ocean.com>
>> wrote:
>> >> I think the path you pass along is invalid.
>> >>
>> >> The path in Windows is expected to use backticks, F:\project\pom.xml.
>> >>
>> >> jruby, trying to read this path, fails in the expand_path method.
>> >>
>> >> That's all I can tell at first sight (and without a Windows machine).
>> >>
>> >> You can try to read the JRuby source code for that method to find out
>> more.
>> >>
>> https://github.com/jruby/jruby/blob/1.6.5.1/src/org/jruby/RubyFile.java#L1100
>> >>
>> >> On Thu, Mar 8, 2012 at 09:36, Khristian <de...@gmail.com> wrote:
>> >>
>> >>> I'm trying to read an existing Maven 2 POM file in an application I'm
>> >>> developing. For this, I tried to use Buildr in the following ways:
>> >>>
>> >>> ----------------------
>> >>> require 'rubygems'
>> >>> require 'buildr'
>> >>>
>> >>> path="F:/project/pom.xml"
>> >>>
>> >>> # POM.load:
>> >>> pom=Buildr::POM.load(path)
>> >>>
>> >>> # Generate:
>> >>> Buildr::Generate::from_maven2_pom(path)
>> >>> -----------------------
>> >>> Both ways fail in the same way (from pom.rb:52):
>> >>> >jruby  pom.rb
>> >>> TypeError: can't convert nil into String
>> >>>      expand_path at org/jruby/RubyFile.java:1100
>> >>>        buildfile at
>> >>>
>> >>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:171
>> >>>        load_from at
>> >>>
>> >>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:108
>> >>>             user at
>> >>>
>> >>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:76
>> >>>            local at
>> >>>
>> >>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:594
>> >>>           locate at
>> >>>
>> >>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:622
>> >>>         artifact at
>> >>>
>> >>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:758
>> >>>             load at
>> >>>
>> >>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:39
>> >>>       initialize at
>> >>>
>> >>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:74
>> >>>             load at
>> >>>
>> >>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:52
>> >>>  from_maven2_pom at
>> >>>
>> >>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/generate.rb:95
>> >>>           (root) at pom.rb:7
>> >>>
>> >>> I am using Buildr 1.4.6 (JRuby 1.6.5.1).
>> >>>
>> >>> Any idea what might be happening/being done wrong?
>> >>>
>> >>> Thanks,
>> >>> --
>> >>> Khristian Alexander Schönrock
>> >>>
>> >
>> >
>> >
>> > --
>> > Khristian Alexander Schönrock
>> > http://derkosak.blogspot.com - Meu blógue!
>>
>>
>>
>> --
>> Khristian Alexander Schönrock
>>



-- 
Khristian Alexander Schönrock

Re: Reading POM files

Posted by Antoine Toulme <an...@lunar-ocean.com>.
That clears things up for me a bit, so here is some general advice I hope
can help:

You cannot use buildr without a Buildfile - except if you use the buildr
task to generate one.
Buildr has a builtin task to create a Buildfile from a pom.xml file, just
go buildr -T for more information.
You cannot use buildr within a ruby script. Buildr is packaged as an
application and expects to behave in that setting.

If you are interested in using a specific functionality of Buildr, like
reading pom files, you probably will have to fork or require some of the
buildr ruby files individually.

On Thu, Mar 8, 2012 at 11:13, Khristian <de...@gmail.com> wrote:

> After some more code inspecting, I found that the "rakefile" var used
> in the "application.rb->Application->buildfile" is nil, but I couldn't
> figure out where it comes from.
> The method:
> https://github.com/apache/buildr/blob/1.4.6/lib/buildr/core/application.rb#L167
> The POM file is very basic: http://pastie.org/3550371
>
> Any suggestions?
>
> On Thu, Mar 8, 2012 at 3:46 PM, Khristian <de...@gmail.com> wrote:
> > After testing with different path formats (single-quoted,
> > double-quoted, with forward slashes and backslashes), I noticed that
> > File.expand_path always expands the path to "F:/project/pom.xml".
> >
> > It seems the error has something to do with my local maven
> > configuration (M2_REPO, etc), based on the stacktrace. After setting
> > the M2_REPO environment variable, the stacktrace changed, but not the
> > final exception. I will investigate further and post results later.
> > Thanks for the help so far!
> >
> > On Thu, Mar 8, 2012 at 3:12 PM, Antoine Toulme <an...@lunar-ocean.com>
> wrote:
> >> I think the path you pass along is invalid.
> >>
> >> The path in Windows is expected to use backticks, F:\project\pom.xml.
> >>
> >> jruby, trying to read this path, fails in the expand_path method.
> >>
> >> That's all I can tell at first sight (and without a Windows machine).
> >>
> >> You can try to read the JRuby source code for that method to find out
> more.
> >>
> https://github.com/jruby/jruby/blob/1.6.5.1/src/org/jruby/RubyFile.java#L1100
> >>
> >> On Thu, Mar 8, 2012 at 09:36, Khristian <de...@gmail.com> wrote:
> >>
> >>> I'm trying to read an existing Maven 2 POM file in an application I'm
> >>> developing. For this, I tried to use Buildr in the following ways:
> >>>
> >>> ----------------------
> >>> require 'rubygems'
> >>> require 'buildr'
> >>>
> >>> path="F:/project/pom.xml"
> >>>
> >>> # POM.load:
> >>> pom=Buildr::POM.load(path)
> >>>
> >>> # Generate:
> >>> Buildr::Generate::from_maven2_pom(path)
> >>> -----------------------
> >>> Both ways fail in the same way (from pom.rb:52):
> >>> >jruby  pom.rb
> >>> TypeError: can't convert nil into String
> >>>      expand_path at org/jruby/RubyFile.java:1100
> >>>        buildfile at
> >>>
> >>>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:171
> >>>        load_from at
> >>>
> >>>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:108
> >>>             user at
> >>>
> >>>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:76
> >>>            local at
> >>>
> >>>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:594
> >>>           locate at
> >>>
> >>>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:622
> >>>         artifact at
> >>>
> >>>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:758
> >>>             load at
> >>>
> >>>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:39
> >>>       initialize at
> >>>
> >>>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:74
> >>>             load at
> >>>
> >>>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:52
> >>>  from_maven2_pom at
> >>>
> >>>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/generate.rb:95
> >>>           (root) at pom.rb:7
> >>>
> >>> I am using Buildr 1.4.6 (JRuby 1.6.5.1).
> >>>
> >>> Any idea what might be happening/being done wrong?
> >>>
> >>> Thanks,
> >>> --
> >>> Khristian Alexander Schönrock
> >>>
> >
> >
> >
> > --
> > Khristian Alexander Schönrock
> > http://derkosak.blogspot.com - Meu blógue!
>
>
>
> --
> Khristian Alexander Schönrock
> http://derkosak.blogspot.com - Meu blógue!
>

Re: Reading POM files

Posted by Khristian <de...@gmail.com>.
After some more code inspecting, I found that the "rakefile" var used
in the "application.rb->Application->buildfile" is nil, but I couldn't
figure out where it comes from.
The method: https://github.com/apache/buildr/blob/1.4.6/lib/buildr/core/application.rb#L167
The POM file is very basic: http://pastie.org/3550371

Any suggestions?

On Thu, Mar 8, 2012 at 3:46 PM, Khristian <de...@gmail.com> wrote:
> After testing with different path formats (single-quoted,
> double-quoted, with forward slashes and backslashes), I noticed that
> File.expand_path always expands the path to "F:/project/pom.xml".
>
> It seems the error has something to do with my local maven
> configuration (M2_REPO, etc), based on the stacktrace. After setting
> the M2_REPO environment variable, the stacktrace changed, but not the
> final exception. I will investigate further and post results later.
> Thanks for the help so far!
>
> On Thu, Mar 8, 2012 at 3:12 PM, Antoine Toulme <an...@lunar-ocean.com> wrote:
>> I think the path you pass along is invalid.
>>
>> The path in Windows is expected to use backticks, F:\project\pom.xml.
>>
>> jruby, trying to read this path, fails in the expand_path method.
>>
>> That's all I can tell at first sight (and without a Windows machine).
>>
>> You can try to read the JRuby source code for that method to find out more.
>> https://github.com/jruby/jruby/blob/1.6.5.1/src/org/jruby/RubyFile.java#L1100
>>
>> On Thu, Mar 8, 2012 at 09:36, Khristian <de...@gmail.com> wrote:
>>
>>> I'm trying to read an existing Maven 2 POM file in an application I'm
>>> developing. For this, I tried to use Buildr in the following ways:
>>>
>>> ----------------------
>>> require 'rubygems'
>>> require 'buildr'
>>>
>>> path="F:/project/pom.xml"
>>>
>>> # POM.load:
>>> pom=Buildr::POM.load(path)
>>>
>>> # Generate:
>>> Buildr::Generate::from_maven2_pom(path)
>>> -----------------------
>>> Both ways fail in the same way (from pom.rb:52):
>>> >jruby  pom.rb
>>> TypeError: can't convert nil into String
>>>      expand_path at org/jruby/RubyFile.java:1100
>>>        buildfile at
>>>
>>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:171
>>>        load_from at
>>>
>>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:108
>>>             user at
>>>
>>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:76
>>>            local at
>>>
>>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:594
>>>           locate at
>>>
>>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:622
>>>         artifact at
>>>
>>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:758
>>>             load at
>>>
>>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:39
>>>       initialize at
>>>
>>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:74
>>>             load at
>>>
>>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:52
>>>  from_maven2_pom at
>>>
>>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/generate.rb:95
>>>           (root) at pom.rb:7
>>>
>>> I am using Buildr 1.4.6 (JRuby 1.6.5.1).
>>>
>>> Any idea what might be happening/being done wrong?
>>>
>>> Thanks,
>>> --
>>> Khristian Alexander Schönrock
>>>
>
>
>
> --
> Khristian Alexander Schönrock
> http://derkosak.blogspot.com - Meu blógue!



-- 
Khristian Alexander Schönrock
http://derkosak.blogspot.com - Meu blógue!

Re: Reading POM files

Posted by Khristian <de...@gmail.com>.
After testing with different path formats (single-quoted,
double-quoted, with forward slashes and backslashes), I noticed that
File.expand_path always expands the path to "F:/project/pom.xml".

It seems the error has something to do with my local maven
configuration (M2_REPO, etc), based on the stacktrace. After setting
the M2_REPO environment variable, the stacktrace changed, but not the
final exception. I will investigate further and post results later.
Thanks for the help so far!

On Thu, Mar 8, 2012 at 3:12 PM, Antoine Toulme <an...@lunar-ocean.com> wrote:
> I think the path you pass along is invalid.
>
> The path in Windows is expected to use backticks, F:\project\pom.xml.
>
> jruby, trying to read this path, fails in the expand_path method.
>
> That's all I can tell at first sight (and without a Windows machine).
>
> You can try to read the JRuby source code for that method to find out more.
> https://github.com/jruby/jruby/blob/1.6.5.1/src/org/jruby/RubyFile.java#L1100
>
> On Thu, Mar 8, 2012 at 09:36, Khristian <de...@gmail.com> wrote:
>
>> I'm trying to read an existing Maven 2 POM file in an application I'm
>> developing. For this, I tried to use Buildr in the following ways:
>>
>> ----------------------
>> require 'rubygems'
>> require 'buildr'
>>
>> path="F:/project/pom.xml"
>>
>> # POM.load:
>> pom=Buildr::POM.load(path)
>>
>> # Generate:
>> Buildr::Generate::from_maven2_pom(path)
>> -----------------------
>> Both ways fail in the same way (from pom.rb:52):
>> >jruby  pom.rb
>> TypeError: can't convert nil into String
>>      expand_path at org/jruby/RubyFile.java:1100
>>        buildfile at
>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:171
>>        load_from at
>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:108
>>             user at
>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:76
>>            local at
>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:594
>>           locate at
>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:622
>>         artifact at
>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:758
>>             load at
>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:39
>>       initialize at
>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:74
>>             load at
>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:52
>>  from_maven2_pom at
>>
>> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/generate.rb:95
>>           (root) at pom.rb:7
>>
>> I am using Buildr 1.4.6 (JRuby 1.6.5.1).
>>
>> Any idea what might be happening/being done wrong?
>>
>> Thanks,
>> --
>> Khristian Alexander Schönrock
>>



-- 
Khristian Alexander Schönrock
http://derkosak.blogspot.com - Meu blógue!

Re: Reading POM files

Posted by Antoine Toulme <an...@lunar-ocean.com>.
I think the path you pass along is invalid.

The path in Windows is expected to use backticks, F:\project\pom.xml.

jruby, trying to read this path, fails in the expand_path method.

That's all I can tell at first sight (and without a Windows machine).

You can try to read the JRuby source code for that method to find out more.
https://github.com/jruby/jruby/blob/1.6.5.1/src/org/jruby/RubyFile.java#L1100

On Thu, Mar 8, 2012 at 09:36, Khristian <de...@gmail.com> wrote:

> I'm trying to read an existing Maven 2 POM file in an application I'm
> developing. For this, I tried to use Buildr in the following ways:
>
> ----------------------
> require 'rubygems'
> require 'buildr'
>
> path="F:/project/pom.xml"
>
> # POM.load:
> pom=Buildr::POM.load(path)
>
> # Generate:
> Buildr::Generate::from_maven2_pom(path)
> -----------------------
> Both ways fail in the same way (from pom.rb:52):
> >jruby  pom.rb
> TypeError: can't convert nil into String
>      expand_path at org/jruby/RubyFile.java:1100
>        buildfile at
>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:171
>        load_from at
>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:108
>             user at
>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/application.rb:76
>            local at
>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:594
>           locate at
>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:622
>         artifact at
>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/packaging/artifact.rb:758
>             load at
>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:39
>       initialize at
>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:74
>             load at
>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/java/pom.rb:52
>  from_maven2_pom at
>
> c:/prog/jruby-1.6.5.1/lib/ruby/gems/1.8/gems/buildr-1.4.6-java/lib/buildr/core/generate.rb:95
>           (root) at pom.rb:7
>
> I am using Buildr 1.4.6 (JRuby 1.6.5.1).
>
> Any idea what might be happening/being done wrong?
>
> Thanks,
> --
> Khristian Alexander Schönrock
>