You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by al...@o08.net on 2011/08/26 13:35:43 UTC
How to generate sources for/before compile?
Hello,
I've been stuck for a while now with this problem, neither googling
nor stackoverflow nor my strained brain could solve this: I would like
to generate sources and have buildr compile them with some other hand
written sources. I would also be happy if I could have a sub-project
that just deals with the generated classes and use them in other
project. So basically:
- buildr should call a generator (either a java program, or a shell
script, or even an ant script, whatever works)
- buildr should compile the resulting classes
- buildr should add those sources to eclipse
I have found an old thread from 2009 with the same title, but none of
the solutions there work (I'm getting so many errors that I wouldn't
even know where to start, or nothing happens). I assume that buildr
evolved quite a bit since then.
I've been very happy with buildr so far, but unfortunately I don't
know ruby and rake yet and now I want to do something slightly
non-standard, so I'm aware that I may have chosen the wrong build
system for me. Still, I'd rather not go back to ant at this point.
I would be grateful if someone could give me an example of a working
buildfile that does sth like what I've described. I've got an open
question on stackoverflow, so if you need some karma, I'm happy to
provide. (see: http://stackoverflow.com/questions/7091659/using-generated-sources-in-a-buildr-project
I just offered a bounty.)
Thanks!
alvi
Re: How to generate sources for/before compile?
Posted by Peter Donald <pe...@realityforge.org>.
Hi,
I don't know anything about the eclipse plugin, I use the idea plugin
and it just works if you add a path to compile.with. Below is a
snippet of one of my build files showing how I compile some generated
sources;
base_generated_dir = project._(:target, :generated, "main/jpa")
task = Domgen::GenerateTask.new(repository_key, "jpa", [:jpa_model,
:jpa_ejb], base_generated_dir) do |t|
t.description = 'Generates the Java code for the persistent objects'
end
java_dir = "#{base_generated_dir}/java"
file(java_dir => [task.task_name])
project.compile.from java_dir
--
Cheers,
Peter Donald
Re: How to generate sources for/before compile?
Posted by Alex Boisvert <al...@gmail.com>.
Ok, I created an issue to support "compile.from(task)" (without to_s) and
added a note on the "How To" page about this bug.
https://issues.apache.org/jira/browse/BUILDR-609
alex
On Sat, Aug 27, 2011 at 8:06 AM, <al...@o08.net> wrote:
> Thanks a lot for the answers. indeed I tried the example pointed out
> by alex, but I always got the error 'TypeError : can't convert
> Rake::FileTask into String'.
>
> Your suggestion here indeed fixed my problem! It works with
> 'compile.from generate.to_s' (I tried to put this to_s into other
> places, which made that error disappear, but other errors came up
> instead.)
>
> As for eclipse, it worked out of the box, the .classpath was extended
> automatically, as suggested by peter donald.
>
> Thanks very much!
> alvi
>
> On Fri, Aug 26, 2011 at 3:57 PM, masterzim.art@googlemail.com
> <ma...@googlemail.com> wrote:
> > There is some kind of bug. In this example should be "compile.from
> > generate.to_s", this to_s is significant.
> >
> > Thanks.
> >
> > 2011/8/26 Alex Boisvert <al...@gmail.com>
> >
> >> Did you try this?
> >>
> >>
> >>
> https://cwiki.apache.org/confluence/display/BUILDR/How+to+generate+sources+before+compilation
> >>
> >> alex
> >>
> >>
> >> On Fri, Aug 26, 2011 at 4:35 AM, <al...@o08.net> wrote:
> >>
> >> > Hello,
> >> >
> >> > I've been stuck for a while now with this problem, neither googling
> >> > nor stackoverflow nor my strained brain could solve this: I would like
> >> > to generate sources and have buildr compile them with some other hand
> >> > written sources. I would also be happy if I could have a sub-project
> >> > that just deals with the generated classes and use them in other
> >> > project. So basically:
> >> >
> >> > - buildr should call a generator (either a java program, or a shell
> >> > script, or even an ant script, whatever works)
> >> > - buildr should compile the resulting classes
> >> > - buildr should add those sources to eclipse
> >> >
> >> > I have found an old thread from 2009 with the same title, but none of
> >> > the solutions there work (I'm getting so many errors that I wouldn't
> >> > even know where to start, or nothing happens). I assume that buildr
> >> > evolved quite a bit since then.
> >> >
> >> > I've been very happy with buildr so far, but unfortunately I don't
> >> > know ruby and rake yet and now I want to do something slightly
> >> > non-standard, so I'm aware that I may have chosen the wrong build
> >> > system for me. Still, I'd rather not go back to ant at this point.
> >> >
> >> > I would be grateful if someone could give me an example of a working
> >> > buildfile that does sth like what I've described. I've got an open
> >> > question on stackoverflow, so if you need some karma, I'm happy to
> >> > provide. (see:
> >> >
> >>
> http://stackoverflow.com/questions/7091659/using-generated-sources-in-a-buildr-project
> >> > I just offered a bounty.)
> >> >
> >> > Thanks!
> >> > alvi
> >> >
> >>
> >
>
Re: How to generate sources for/before compile?
Posted by al...@o08.net.
Thanks a lot for the answers. indeed I tried the example pointed out
by alex, but I always got the error 'TypeError : can't convert
Rake::FileTask into String'.
Your suggestion here indeed fixed my problem! It works with
'compile.from generate.to_s' (I tried to put this to_s into other
places, which made that error disappear, but other errors came up
instead.)
As for eclipse, it worked out of the box, the .classpath was extended
automatically, as suggested by peter donald.
Thanks very much!
alvi
On Fri, Aug 26, 2011 at 3:57 PM, masterzim.art@googlemail.com
<ma...@googlemail.com> wrote:
> There is some kind of bug. In this example should be "compile.from
> generate.to_s", this to_s is significant.
>
> Thanks.
>
> 2011/8/26 Alex Boisvert <al...@gmail.com>
>
>> Did you try this?
>>
>>
>> https://cwiki.apache.org/confluence/display/BUILDR/How+to+generate+sources+before+compilation
>>
>> alex
>>
>>
>> On Fri, Aug 26, 2011 at 4:35 AM, <al...@o08.net> wrote:
>>
>> > Hello,
>> >
>> > I've been stuck for a while now with this problem, neither googling
>> > nor stackoverflow nor my strained brain could solve this: I would like
>> > to generate sources and have buildr compile them with some other hand
>> > written sources. I would also be happy if I could have a sub-project
>> > that just deals with the generated classes and use them in other
>> > project. So basically:
>> >
>> > - buildr should call a generator (either a java program, or a shell
>> > script, or even an ant script, whatever works)
>> > - buildr should compile the resulting classes
>> > - buildr should add those sources to eclipse
>> >
>> > I have found an old thread from 2009 with the same title, but none of
>> > the solutions there work (I'm getting so many errors that I wouldn't
>> > even know where to start, or nothing happens). I assume that buildr
>> > evolved quite a bit since then.
>> >
>> > I've been very happy with buildr so far, but unfortunately I don't
>> > know ruby and rake yet and now I want to do something slightly
>> > non-standard, so I'm aware that I may have chosen the wrong build
>> > system for me. Still, I'd rather not go back to ant at this point.
>> >
>> > I would be grateful if someone could give me an example of a working
>> > buildfile that does sth like what I've described. I've got an open
>> > question on stackoverflow, so if you need some karma, I'm happy to
>> > provide. (see:
>> >
>> http://stackoverflow.com/questions/7091659/using-generated-sources-in-a-buildr-project
>> > I just offered a bounty.)
>> >
>> > Thanks!
>> > alvi
>> >
>>
>
Re: How to generate sources for/before compile?
Posted by "masterzim.art@googlemail.com" <ma...@googlemail.com>.
There is some kind of bug. In this example should be "compile.from
generate.to_s", this to_s is significant.
Thanks.
2011/8/26 Alex Boisvert <al...@gmail.com>
> Did you try this?
>
>
> https://cwiki.apache.org/confluence/display/BUILDR/How+to+generate+sources+before+compilation
>
> alex
>
>
> On Fri, Aug 26, 2011 at 4:35 AM, <al...@o08.net> wrote:
>
> > Hello,
> >
> > I've been stuck for a while now with this problem, neither googling
> > nor stackoverflow nor my strained brain could solve this: I would like
> > to generate sources and have buildr compile them with some other hand
> > written sources. I would also be happy if I could have a sub-project
> > that just deals with the generated classes and use them in other
> > project. So basically:
> >
> > - buildr should call a generator (either a java program, or a shell
> > script, or even an ant script, whatever works)
> > - buildr should compile the resulting classes
> > - buildr should add those sources to eclipse
> >
> > I have found an old thread from 2009 with the same title, but none of
> > the solutions there work (I'm getting so many errors that I wouldn't
> > even know where to start, or nothing happens). I assume that buildr
> > evolved quite a bit since then.
> >
> > I've been very happy with buildr so far, but unfortunately I don't
> > know ruby and rake yet and now I want to do something slightly
> > non-standard, so I'm aware that I may have chosen the wrong build
> > system for me. Still, I'd rather not go back to ant at this point.
> >
> > I would be grateful if someone could give me an example of a working
> > buildfile that does sth like what I've described. I've got an open
> > question on stackoverflow, so if you need some karma, I'm happy to
> > provide. (see:
> >
> http://stackoverflow.com/questions/7091659/using-generated-sources-in-a-buildr-project
> > I just offered a bounty.)
> >
> > Thanks!
> > alvi
> >
>
Re: How to generate sources for/before compile?
Posted by Alex Boisvert <al...@gmail.com>.
Did you try this?
https://cwiki.apache.org/confluence/display/BUILDR/How+to+generate+sources+before+compilation
alex
On Fri, Aug 26, 2011 at 4:35 AM, <al...@o08.net> wrote:
> Hello,
>
> I've been stuck for a while now with this problem, neither googling
> nor stackoverflow nor my strained brain could solve this: I would like
> to generate sources and have buildr compile them with some other hand
> written sources. I would also be happy if I could have a sub-project
> that just deals with the generated classes and use them in other
> project. So basically:
>
> - buildr should call a generator (either a java program, or a shell
> script, or even an ant script, whatever works)
> - buildr should compile the resulting classes
> - buildr should add those sources to eclipse
>
> I have found an old thread from 2009 with the same title, but none of
> the solutions there work (I'm getting so many errors that I wouldn't
> even know where to start, or nothing happens). I assume that buildr
> evolved quite a bit since then.
>
> I've been very happy with buildr so far, but unfortunately I don't
> know ruby and rake yet and now I want to do something slightly
> non-standard, so I'm aware that I may have chosen the wrong build
> system for me. Still, I'd rather not go back to ant at this point.
>
> I would be grateful if someone could give me an example of a working
> buildfile that does sth like what I've described. I've got an open
> question on stackoverflow, so if you need some karma, I'm happy to
> provide. (see:
> http://stackoverflow.com/questions/7091659/using-generated-sources-in-a-buildr-project
> I just offered a bounty.)
>
> Thanks!
> alvi
>